Jump to content
Sign in to follow this  
Guest christian

decal polys

Recommended Posts

Guest christian

ok, I just decided to have another go at a decal poly exporter for ArcGIS.I just wanted to check (Rhumba, Lee?), do you know if polys have to be concave or can they be convex. I doubt they can be convex, but I hope they can be, otherwise I'd have to program a tesselator (in the long run I need one anyway, I guess, for water polys).Lee, have you thought (or done) something on the poly splitting? My idea was to insert new vertices as required and redefine the polys. Haven't really thought about how to implement that yet though...Cheers, Christian

Share this post


Link to post
Share on other sites
Guest christian

Lee, I guess you have your own code by now, but this is how my stuff looks so far (not much there yet):

double lon;point->get_X( &lon );double lat;point->get_Y( &lat );double LOD8_lon = ( lon + 180. ) / 0.46875;double LOD8_lat = ( 90. - lat ) / 0.3515625;int LOD8_x = (int) LOD8_lon;int LOD8_y = (int) LOD8_lat;double LOD10_lon = ( LOD8_lon - (double) LOD8_x ) * 4.;int LOD10_x = (int) LOD10_lon;int LOD13_x = (int) ( ( LOD10_lon - (double) LOD10_x ) * 8. );int LOD13_y = (int) ( ( LOD8_lat - (double) LOD8_y ) * 32. );// FIXME: I have no clue where the 4080 (0x0FF0) is coming from...int x = (int) ( ( LOD8_lon - (double) LOD8_x ) * 255. * 32. ) + 4080;int y = (int) ( ( LOD8_lat - (double) LOD8_y ) * 255. * 32. ) + 4080;fprintf( file, "%f %f %d %d %d %d %d %d %dn", lon, lat,	LOD8_x, LOD8_y, LOD10_x, LOD13_x, LOD13_y, x, y );point = NULL;

Don't worry about the 'point' that's just the data points I'm reading in. Next, I'll write polys within a LOD8 quad out to asm, so they compile. Then, I'll have to handle polys that will cover multiple LOD8 quads and split them. And maybe I'll also have to add a tesselation algorithm for concave polys.I'm not sure about the entries for LOD10_x, LOD13_x, LOD13_y that'll go into the header. I don't think the polys have to be split down to that level for the decal polys, so I'll have to experiment a bit. The entries don't seem to do much for the decals anyway...BTW, the above code is untested, there may be bugs in it...Cheers, Christian

Share this post


Link to post
Share on other sites

Hi Christian.It would make sense if concave polys were not allowed, but I have not run into trouble,yet. There is a maximum number of points... I think it's 16... but perhaps that applies to line decals only. You might want to test that.I ran an experiment using downloadable coastline data, in bitmap form, for an LOD8 area, and splitting it into 32 x 32 LOD13 sets... then manually getting points from the resultant bitmaps... very tedious.4080? Is that Bill Gates home address? :)Dick

Share this post


Link to post
Share on other sites

Hi all.I believe the point limit is 255. If the edge of a decal crosses itself, it will compile, but looks wrong. So as long as it doesn't cross, or fold, on itself, you should be OK. Spent the day playing with FS2002 shorelines. A trick I have been using is to change the Group Y value... increasing it by one LOD8 area. That moves the whole shore to the East. I do it with a hex editor, and then save the result by a different name.bglThen I play with the values through the hex editor, and sometimes write a BGLC code which will match the *.bgl when compiled.An odd occurance is this:When I view the moved shoreline, there are no wave effects! The only difference in the new location, is the underlying landclass is already covered by 'worldwc.bgl', whereas the original location was placed on landclass, then trimmed by water-polys to create the coast.So maybe waves must occur over a water-trimmed landclass, or the shoreline won't trigger it? doesn't sound right.Christian:I also find odd insertions to code as I snoop into TMF bgls. It must be maddening trying to get a decompiler working correctly. I can now read FS2002 shorelines pretty well, but I still need to understand the bounds of the start-point of segments.

Share this post


Link to post
Share on other sites

Hi Christian.In order for a shoreline to have a wave, it must lie over land! Placing a decal under the shoreline, but over the water is the way to go... I use a priority of 8 for the decal, and 9 for the shoreline. I'm finding all kinds of oddities in the shoreline codes.Also, I like the looks of CFS2-style shores better! Maybe I can overlay them on the FS2002, for the effect I want. :-eek

Share this post


Link to post
Share on other sites
Guest

If you mean by how to create a large poly over several LOD 13 blocks, I do have a method, I'm coding it out now to see if it really works.Basically I'm taking the two coordinates of a ploy segment and first determining how far I need to go. 1. Are the coordinate pairs within the same LOD 13 block? 2. Are the coordinate pairs within the same LOD 8 block?Based on the answer to these two questions, I determine my coord distance between the pairs. Next I create a coordinate system with the origin at the upper left corner of the lod 13 block housing the first coordinate. Then I translate the coordinates X,Y values in terms of the new origin I just created. Now all I have to do is create new X,Y pairs as needed along the LOD 13 boundries (X = 256, 512 etc, Y = 256, 512) using standard line and slope formulas. Then I determine what side of the coord the poly is on and close it up along the LOD 13 boundries. I do this for every segment of the poly until I get back to the beginning. Once I have a set of X,Y coordinate pairs, I can create the flatten poly.The decal that goes around lakes will use the same X,Y set, but only pairs that define the outer poly edges. I then create another X,Y set based on the width of the decal and place it inside the flatten poly to create the beach effect. For airports, I just place a copy of the flatten points on an airport decal with a texture.The only part that still needs to be worked out is if the poly returns upon itself back into the same LOD 13 block. I do expect this to happen with runways and penninsulas so I'll have to work out the algorithm for it. But that will come after I get this working.Hope this is what you were asking Christian.Lee.

Share this post


Link to post
Share on other sites
Guest christian

That was my question. I had a bit of a think as well, but nothing coded yet:Similar to you, I was thinking to go around the polygon and insert vertices on the LOD13 edges. After that I have a loop that takes all vertices and puts them into the corresponding LOD13 quads. eg:x y row col233 16 23 25244 133 23 25 31 23 23 26144 44 23 25If I cycle through the row/cols I get:233 16 23 25244 133 23 25new vertex on bordernew vertex on border144 44 23 25andnew vertex on border 31 23 23 26new vertex on borderThis algorithm is really handy, as all polys will end up being the right polys again each in their LOD quad.However, there is a problem if a new vertex doesn't lie on the edge, but inside the polygon (and hence doesn't get inserted by the above algoritm). I had an idea there as well:If I insert a vertex to split the polygon, the poly line has to come back, because the polygon is closed. This means, I check if I have 2 new vertices along the LOD13 boundary. If not, the line must have crossed at some other LOD13 boundary, so I have to insert a corner vertex. This also is an easy loop. However, it works only clockwise or counterclockwise, eg I have to know which way the vertices go, otherwise I'll insert corners on the wrong side. I don't know how to determine which way round polygons go, but the ones I have go counterclockwise, so I'll assume that for the meantime.Another troublemaker are vertices on LOD13 borders. You have to know on which side the polygon is. New ones you obviously have to insert 2 vertices for each LOD13 quad, but existing ones, that don't cross, but lie spot on the border have to be tested somehow...Also, I have to implement a test in case the input polygon has a higher resolution than FS2002 allows, basically just loop through and test if there are any doubled up vertices...I'll send you some code once I've implemented something. Something are hard to explain just with text...Cheers, Christian

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...