Sign in to follow this  
Guest artmartin

.agn file format revisited

Recommended Posts

Did some programming last night that got deeper into examining the structure of an autogen .agn file created by the Annotator program and found some strange results applying the format that had been printed here previously. Everything works out really well in regards to the house floor densities, the bytes holding the number of houses, vegetation types, etc. The strange stuff comes when one looks at individual house data. To do this test I created an extremely simple .agn file using annotator that had but one house defined and one vegetation area. The house records in the file that resulted from that simple horizontally aligned house were as follows using the supposed format: Point 1 X: -.4435096 (on a scale of -.5 to .5) Point 1 Y: -.3653846 "" Point 2 X Vector: 0 Point 2 Y Vector: 1 Point 3 X: 0.015625 Point 3 Y: 0.1322115 Now here's how the I've been told to interpret this data from previous posts:4 bytes float: X position of first point4 bytes float: Y position of first point4 bytes float: X vector to the second point4 bytes float: Y vector to the second point4 bytes float: X position of third point4 bytes float: Y position of third pointValues of position are -0.5 for left or upper side and 0.5 for bottom or right side. That means that upper left corener has value of <-0.5,-0.5>, center has value of <0,0> and upper right has value of <0.5,-0.5>.Vectors have values from 0 to 1. Vector < 1,0 > means horizontal line, vector < 0,1 > vertical line, vector < 0.5,0.5 > means line with angle 45 deg from upper left to lower right.So we have an image that's 256 X 256 bits in size. I had placed my house definitiion down in the lower right of the image in Annnotator. Multiplying the X and Y amounts (after adjusting them for the -.5 to +.5 range) by 256 gave me starting points for my rectangle of X = 240.64 and Y = 222.72. Those made complete sense knowing where I placed the house. The X and Y vectors came out right for the horizontally aligned house. Where the format falls down is in the calculation of the third point X and Y. If we take these amounts as actual X and Y pixel positions, the third point ends up near the center of the image, not closer to the bottom right corner as it should be. Since the house I drew was probably no more than a few pixels across both horizontally and vertically, I suspect instead that the the last two byte sets instead define the horizontal and vertical offset of point 3 from point 1 on a scale of 0 to 1. If I multiply the Point 3 X value of .015625 by 256 I get a value of 4. Now of course I'm going to have to confirm these findings by redoing this test with a much larger defined house in a different area of the image and also test it against a house rectangle angled away from horizontal but I'm expecting similar results. I also need to know exact pixel positions of the rectangles I draw in Annotator. Guess I'll do screen captures of the program, trim the image to 256 X 256, and find the corners.Next stumbling block I've come up against is this: I've managed to put a zoomed in picture of the scenery tile I want to work on in an Image control in VB6 but have no idea now how to draw little non-destructive boxes on it for selection rectangles. Any developers know of any great freeware controls I can use for my image editing that have built in area selection routines? Found a couple pre-packaged things yesterday but they don't have the low-level code with them for removing the stuff I don't need. Art Martin

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

AGN vectors are not normalised, the vector components have a length. For instance, it you are at (-0.5,0.5), the lower left corner, a vector [0.75, -0.5] will place the position at (+0.25,0.0).George

Share this post


Link to post
Share on other sites

I think you just said what I'd discovered already, that those last 2 byte groups actually contain vectors and not the point 3 x and y locations as they were so labeled in the original document. From the point 1 X position I found of -.4435096, I combine it with the Point 3 X vector of .015625 to come up with -.4278846 which ends up about 4 pixels off from the first point. That sounded right. In order to make a visual interface similar to Annotator the representations in the agn file have to be put into the terms of pixel position on the reference image I'm presenting to the user or none of this is worthwhile. Now all these assumptions are based on what constitutes Points 1, 2 and 3. I'm guessing this for a horizontal drawing. Pt 1 Pt 2 .________________. | | | | .________________. Pt 3Art

Share this post


Link to post
Share on other sites

Sorry, the extra spaces I put into the box drawing didn't stay in the text. Pt 1 is upper left corner. Pt 2 is upper right. Second series of vertical lines is the right side of the box.Art

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