Jump to content
Sign in to follow this  
Guest cwright

Making an Island with VTP Method2 Polygons and Lines

Recommended Posts

Hi all.Here's some code that makes an island in the ocean... with no landclass beneath, using VTP Method2.

include TDFMacros.incinclude TDFHeaders.inc;  VTP Method2 island		N16*44.38'	W169* 2.11'BGLHeader	17, 15, -168, -170, TerrainHeaderStart, VTPHeader							VTPHeader	label	word	VTPFileHeader	256, VTPIndexStart, TextureStart, VTPEndVTPStart		label	word	datamark_v0	label 	word		VTPDataArea		1, 1, 0, 0			VTPLayer			8, 0			VTPNumTexturesInLayer	1, 0			VTPTextureId		0, 0			VTPPolyCount		1, 0			VTPPolyMethod2		4, 0, 0				VTPPointXY2 	7027, 7202				VTPPointXY2	7044, 7179				VTPPointXY2	7027, 7156				VTPPointXY2	7009, 7179		VTPDataArea		1, 1, 0, 0			VTPLayer			9, 0			VTPNumTexturesInLayer	1, 0			VTPTextureId		1, 0			VTPPolyCount		1, 0			VTPPolyMethod2		6, 1, 0				VTPWidePoint 	7027, 1, 7202, 0				VTPWidePointWidth	1				VTPWidePoint	7044, 1, 7179, 0				VTPWidePointWidth	63				VTPWidePoint	7027, 0, 7156, 0				VTPWidePoint	7009, 0, 7179, 0				VTPWidePoint	7027, 0, 7202, 0				VTPWidePoint	7044, 1, 7179, 0				VTPWidePointWidth	0	datamark_v1	label	word; ---------------------------------------------------------------------------------------------------------Cellv_23_208	EQU	VTPCellID 0, 23, 208	VTPIndexStart	label	word		VTPIndexHeader	1, VTPIndexData, VTPStart	VTPIndexData	label	word		VTPIndexEntry		 Cellv_23_208, VTPStart, datamark_v0, datamark_v1; ---------------------------------------------------------------------------------------------------------TextureStart	label	word	VTPTextureListHeader	2, TextureIndexStart, TextureDataStart, TextureDataEndTextureIndexStart	label	word	VTPTextureListEntry	TextureDataStart, texturemark_0, texturemark_1	VTPTextureListEntry	TextureDataStart, texturemark_1, texturemark_2TextureDataStart	label	word	texturemark_0	label	word		VTPTextureName 	"1194"		VTPTextureType	1, 0, 0, 4	texturemark_1	label	word		VTPTextureName 	"1045"		VTPTextureType	2, 0, 0, 4	texturemark_2	label	wordTextureDataEnd	label	word; ---------------------------------------------------------------------------------------------------------VTPEnd		label	word

Share this post


Link to post
Share on other sites

Also note:In the Shoreline code:VTPLayer 9, 0VTPNumTexturesInLayer 1, 0 VTPTextureId 1, 0 VTPPolyCount 1, 0 VTPPolyMethod2 6, 1, 0 VTPWidePoint 7027, 1, 7202, 0 VTPWidePointWidth 1 VTPWidePoint 7044, 1, 7179, 0 VTPWidePointWidth 63 VTPWidePoint 7027, 0, 7156, 0 VTPWidePoint 7009, 0, 7179, 0 VTPWidePoint 7027, 0, 7202, 0 VTPWidePoint 7044, 1, 7179, 0 VTPWidePointWidth 0I tag the first WidePoint with a width of 1, the next line goes to a width of 63, and the line stays there until I want to close it with a width of 0. The shape of the line is a worm.Also, I wrap the line around itself so the appearance is of a width of 63 all around, even though it is a tapered shape.This is the way Microsoft seems to do lines.Dick

Share this post


Link to post
Share on other sites
Guest christian

hmm, I wondered why M$ did that (the zero widths with the lines I mean)...I think you earned yourself another one of those: :-beerchug Cheers, Christian

Share this post


Link to post
Share on other sites
Guest cwright

Dick, I compiled it okay and popped it into the scenery folder as always - but no sign of an island! Maybe the sea level's rising faster than we thought.... Best regards, Chris

Share this post


Link to post
Share on other sites

Hi Chris.I'm guessing you are using the original TDFHeaders.inc.That macro has a problem with the Western Hemispherego here for an update.Also, I was told many of the code examples must be cut'n'pasted into WordPad... not NotePad. Try that as well.Works on my system with a WordPad txt save, and the new TDFHeaders.incDick

Share this post


Link to post
Share on other sites
Guest cwright

Dick, that fixed it. Many thanks! Best regards, Chris

Share this post


Link to post
Share on other sites
Guest cwright

Hi, Dick I wonder if you or any of the other experts can help me? My program is quite well advanced. I can draw a line, save as a .raw file and the program will convert it to a coastline. Also, by taking a screenshot of an area in map view, I can draw a line over it and quite accurately lay a coastline that matches existing scenery. I'm quite pleased, because at last I've been able to add real (though highly experimental!) coastlines to my Karakam scenery. There's one outstanding issue, and that's when the polygon visits a given square more than once (e.g. a narrow river) - the problem applies both to LOD8 and LOD13 squares. I should be able to solve that, but I've come up against a problem. Basically, if the line goes through more than one LOD8 square, it usually fails. Either nothing shows, or a very small segment. Or 3 out of 4 LOD8 squares show correctly, but one is blank. As far as I can see the data in the ASM file for the individual LOD8 and LOD13 squares is okay. By the way, the input line is open, like a river, so it's not a closed polygon - that's necessary to stop it visiting the same square twice. It may be that this problem only shows with larger numbers of points - using the program I can generate lots of points without having to hand code it. I'm using the old method as in the first tutorial. Is it possible it might work better with the new VTP method? So my question is this: are there any rules that have to be followed with multiple LOD8 squares? E.g. are there limits on the numbers of points or the numbers of LOD13 squares? Many thanks. Best regards, Chris

Share this post


Link to post
Share on other sites

Hi Chris.You should try to convert your thinking to the terrain SDK and the LWM Tutorial.There are limitations to the way Christian and I used to handle the masks... heck, we didn't even know they were masks for quite some time!By switching your thinking to the new terminology, you're able to make concrete examples of what the SDK refers to.I understand you are trying to get a Visual Basic program together to create Land/Water Masks by entering data or a RAW file.The SDK states the structure 'LWMDataAreaDrawPolygons' can only handle 6 separate polys per LOD13 area... You need to use 'LWMDataAreaDrawPolygonsEx' to draw 7 or more ( up to 259 ).Also the actual entry of points after 'LWMPoly2' is limited to 62 points... if you are going to have over 62 you must use 'LWMPoly2Ex' before you actually name the points.All the above aside, if you have more than 259 polys in the LOD13 Area, you can use more than one structure.... so basically you can have as many polys and points as you desire in an area, as long as you use the right data structures... hence the need for the newer macros, as the old ones were made before we knew of any limitations.Whew!I'm not writing this off the top of my head, but from re-reading the SDK. Right now, the only difference betwen our undersanding is I'm comfortable with the SDK's terms, and know where to look for the answer. :)The info in the LWM part of the SDK is right on the mark... except they don't mention the use of invisible flattens.The VTPs? Enough errors in the SDK to tell me the writers and proofers have not used the terrain engine. And that's why they have no examples of code, and some of the VTP info is just plain wrong.LWMs must always be cut off at the edge of the LOD13 Area, by default they must then always be cut off at the edge of the LOD8 Cell. It doesn't matter how many polys you place onto the Area's 256x256 grid. The datastream will decide how the Area will look in the end, with the last poly drawn having preference.I'm suspecting your problem is directly related to the number of points in the individual polygons ( limit of 62 for the basic 'LWMPoly2' structure.If you are using the old TMFMacros.inc, then you are using FLATTEN_POLYGON 62, 1000, 0( with a height of 1000 meters and a fraction of 0 ).If you had 62 points this would be OK... with 63 bytes, you'd need FLATTEN_POLYGON MACRO 62, 1000, 0BYTE 1See how I made a space for the extra count by adding a byte, and placing 1 in it? Now you have 62 + 1 ( = 63 ). By adding the BYTE command, you can now have up to 317 points in a poly... but don't add the byte if you have 62 or less.Dick

Share this post


Link to post
Share on other sites
Guest cwright

Dick, many thanks for the info. My next obvious step is to convert to the new method. I've been through the SDK a couple of times but it's aimed at experts (which I'm not!) and it's pretty confusing. That's why your tutorials are like gold dust! However.... I only have one polygon per LOD13 area and the maximum number of points in each LOD13 area is less than 35, so it should be well in. I include part of the asm text below. I can't see anything wrong with it but I may be missing something. But it's probably not worth spending much time on it as it's effectively obsolete. I'll use your example in the second tutorial as a template to convert the program to the new method and report back!Many thanks. Best regards, Chris***********************************************; TERRAIN FLATTEN POLYGON HEADERflatten_header label word FLATTEN_HEADER 513, flatten_list, flatten_data, flatten_end; TERRAIN FLATTEN POLYGON DATAflatten_data label worddata_start_0 label wordFLATTEN_DATA 1, 0, 1, 16,1,1,1 FLATTEN_POLYGON 19, 0,0FLATTEN_POINT 1, 69FLATTEN_POINT 131, 44FLATTEN_POINT 131, 58FLATTEN_POINT 131, 71FLATTEN_POINT 131, 84FLATTEN_POINT 131, 98FLATTEN_POINT 131, 111FLATTEN_POINT 131, 125FLATTEN_POINT 131, 138FLATTEN_POINT 131, 151FLATTEN_POINT 131, 165FLATTEN_POINT 131, 178FLATTEN_POINT 131, 192FLATTEN_POINT 131, 205FLATTEN_POINT 131, 218FLATTEN_POINT 131, 232FLATTEN_POINT 131, 245FLATTEN_POINT 131, 255FLATTEN_POINT 1, 255data_end_0 label worddata_start_1 label word FLATTEN_DATA 1, 0, 1, 17,1,1,1 FLATTEN_POLYGON 23, 0,0FLATTEN_POINT 131, 1FLATTEN_POINT 131, 4FLATTEN_POINT 131, 17FLATTEN_POINT 131, 30FLATTEN_POINT 131, 44FLATTEN_POINT 131, 57FLATTEN_POINT 131, 70FLATTEN_POINT 131, 84FLATTEN_POINT 131, 97FLATTEN_POINT 131, 111FLATTEN_POINT 131, 124FLATTEN_POINT 131, 137FLATTEN_POINT 131, 151FLATTEN_POINT 131, 164FLATTEN_POINT 131, 178FLATTEN_POINT 131, 191FLATTEN_POINT 131, 204FLATTEN_POINT 131, 218FLATTEN_POINT 131, 231FLATTEN_POINT 131, 244FLATTEN_POINT 131, 255FLATTEN_POINT 1, 255FLATTEN_POINT 1, 1data_end_1 label word......................etcdata_start_89 label word FLATTEN_DATA 1, 5, 1, 16,1,1,1 FLATTEN_POLYGON 14, 0,0FLATTEN_POINT 24, 255FLATTEN_POINT 24, 245FLATTEN_POINT 24, 232FLATTEN_POINT 24, 218FLATTEN_POINT 34, 205FLATTEN_POINT 34, 192FLATTEN_POINT 34, 178FLATTEN_POINT 44, 165FLATTEN_POINT 44, 151FLATTEN_POINT 44, 138FLATTEN_POINT 44, 125FLATTEN_POINT 44, 111FLATTEN_POINT 255, 69FLATTEN_POINT 255, 255data_end_89 label word; TERRAIN FLATTEN POLYGON LISTflatten_list label word FLATTEN_LIST 4, flatten_groupsflatten_groups label word FLATTEN_GROUP 252, 474,flatten_data,data_start_0,data_end_15 FLATTEN_GROUP 253, 474,flatten_data,data_start_16,data_end_40 FLATTEN_GROUP 253, 473,flatten_data,data_start_41,data_end_70 FLATTEN_GROUP 252, 473,flatten_data,data_start_71,data_end_89flatten_end label word

Share this post


Link to post
Share on other sites

Hi Chris.A quick guess here...Use find and replace to replace ',' with ', '...you may need spaces after all the comma delimiters... if so that would explain a lot of problems.Dick

Share this post


Link to post
Share on other sites
Guest cwright

Dick, I've converted my program to the new method. The good news is that it works and seems to generate a valid asm file that compiles okay. The bad news.... After dropping the bgl into the scenery folder FS2002 refused to run! Before it even reached the first options screen it informed me that my computer had run out of memory! After a bit of head-scratching I removed the bgl and FS ran okay. There were several hundred points in one LOD8 square. I reduced the points but FS still won't run. I'll add the asm for the reduced points at the bottom. After reading your post I added spaces but no joy. As far as I can see it follows your tutorial example with two LOD8 squares. Can you spot the deliberate mistake? It's also amazing that a dodgy bgl can make FS fail to load. Many thanks. Best regards, Chris********************************************** include TDFMacros.inc include TDFHeaders.inc BGL Header 3, 1, 43, 40, LWMHeader, TerrainHeaderStart LWMHeader label word LWMFileHeader 513, LWMIndexStart, LWMStart, LWMEnd LWMStart label word datamark_0 label word LWMDataAreaDrawPolygons 1, 3, 1, 9, 27 LWMPoly2 5, 0, 0, 0, 0 LWMPoint 2, 1 LWMPoint 92, 126 LWMPoint 2, 255 LWMPoint 1, 255 LWMPoint 1, 1 LWMDataAreaDrawPolygons 1, 3, 1, 3, 19 LWMPoly2 3, 0, 0, 0, 0 LWMPoint 254, 1 LWMPoint 27, 19 LWMPoint 2, 1 LWMDataAreaDrawPolygons 1, 3, 1, 7, 9 LWMPoly2 5, 0, 0, 0, 0 LWMPoint 254, 255 LWMPoint 153, 75 LWMPoint 254, 1 LWMPoint 255, 1 LWMPoint 255, 255 LWMDataAreaDrawPolygons 1, 3, 1, 15, 11 LWMPoly2 3, 0, 0, 0, 0 LWMPoint 2, 255 LWMPoint 114, 231 LWMPoint 254, 255 LWMDataAreaDrawPolygons 1, 3, 1, 0, 0 LWMPoly2 5, 0, 0, 0, 0 LWMPoint 2, 1 LWMPoint 85, 225 LWMPoint 254, 255 LWMPoint 1, 255 LWMPoint 1, 1 datamark_1 label word Cell_473_250 EQU LWMCellID 0, 0, 3, 473, 250 LWMIndexStart label word LWMIndexHeader 1, LWMIndexData LWMIndexData label word LWMIndexEntry Cell_473_250, LWMStart, datamark_0, datamark_1 LWMEnd label word

Share this post


Link to post
Share on other sites

Hi Chris.This is getting pretty far off topic. :)I'm hoping the error wasn't deliberate... meaning you did it on purpose!BGL Header should be BGLHeaderIf you want to post about LWMs, let's start a new thread.Dick

Share this post


Link to post
Share on other sites
Guest cwright

Thanks, Dick, that did it. I don't know how I missed it. It's amazing that a single space can bring FS to its knees! Best regards, Chris

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...