Jump to content
Sign in to follow this  
rhumbaflappy

VTPMacros and textured polygon example

Recommended Posts

Hi all.I finished the newer VTP terrain macros to go with the earlier LWM terrain macros for use with BGLC.I'll attach the macros and an example. These macros include the whole of VTP usage and match Microsoft's terminology.VTP = Vectored Terrain PolygonLWM = Land/Water Mask

Share this post


Link to post
Share on other sites
Guest christian

Hi Dick,I was doing the same over the last couple days! I wanted to send you a new version, but I haven't finished it yet, because my new computer system is causing my lots of grief...What do you say, we mostly got everything right. A few small mistakes, but nothing too major. I actually know one thing more, M$ hasn't revealed (ie how to get more than 127 texture groups). Also, the reserved bytes in the VTPWidePoints have a meaning, because I still can't decompile those files. And there must be a Poly1 in the LWM which corresponds to your CFS2 style polys...Still things to uncover...Cheers, Christian

Share this post


Link to post
Share on other sites

Hi Christian.I translated the C code to BGLC macros so we, and others, could explore the polys in better detail.It's going to take me a week or so to explore all the different types.A couple of interesting things... apparently there is an exclusion switch to wipeout the preexisting polys and lines in an LOD13 area. So you can re-do an area with a clean slate.Also, the CFS2-style line segments are useful, in that they can be expanded to cover 256x256 points, and allow a transparent texture to be draped over the mesh ( but no mention of this type in the SDK, as far as I can tell at this point).The mesh-clinging water is now accomplished by adding -9999 as the height field for LWM water... I 'll play with that today to see how the code differs from CFS2. I'm thinking it's different code in FS2002, and that's OK. I'll write a new CFS2 macro set for their code, as only a few brave souls will still rework CFS2... CFS3 will release in 2 months, and my focus will probably be in that direction, as it should support the full set of LWMs and VTPs.Also better explained is the concept of a data stream. I had an inkling of this, as I have swapped LWM masks back and forth in the same BGL, and the last switch in the 'stream' gets displayed.On another note, landclass has been more fully explained, but waterclass is still something of a mystery, other than the explanation of depth. Values #252 and #253 of landclass are for CUSTOM textures! which should allow designers to relace singular LOD13 photoreal bitmaps ( I suspect they use the "003101031303233Su.bmp" type naming convention ).So that's an interesting area to explore.Lee's discovery of the polys using a 255x255 array is refuted in the SDK... but I beleive Lee is right! 255 makes the calculations for the VTP polys' placement in the LOD8 cell fit perfectly. Maybe MS uses the 0 for overlap ( or maybe treats 0 as 1 to avoid some divide by zero errors ).Dick

Share this post


Link to post
Share on other sites
Guest

Hi DickI saved both of your example LWMmacros.inc from your other post and VTPMacros.inc from above along with both example .asm files. After renaming the LWMmacros.asm and VTPmacros.asm respectively neither would compile when droped onto BGLC.exe. I ran a batch file on each to determine the errors and got a long list of error A2008 sytax errors.Is there a command I can type at the BGLC prompt which will print the errors to a *.txt file? Thanks for any comments and suggestions your can give.Ken

Share this post


Link to post
Share on other sites

Hi Ken.LWMMacros.inc and VTPMacros.inc are the correct extentions. The are macro files and need the ".inc", and are referenced in the code as "include LWMmacros.inc" or "include VTPMacros.inc".These macros add "psuedo" commands to the BGLC compiler when called.3d7002ff414b0279.txt should be renamed VTPMacros.inc3d700317417e8067.txt should be renamed decaltest.asmGive it 2 weeks for a downloadable posting of these macros, with complete usage instructions ( but probably not quite a tutorial ). We need some time for experimentors, like you, and Christian, and Lee, and others, to see if the macros should be 'finalized'. I want time to find bugs, or M$ errors, before they become 'official', because once they are uploaded to the file library, they are, more or less, written in stone. We need a common terminology to share info and resources, so we need to get it right. By using these macros, we get M$'s terminology, that we can use to discuss TDF ( terrain data file ) polygons... see? They are actually TDF not TMF, according to the SDK. Does the naming make a difference? Oh, yeah!My tutorial will help understand the LWM polys ( land/water masks ). Not much has changed. We need to lean new terms, but that will come quick. As far as VTPs ( decals ), a lot of the structure has been altered... not much of a problem for Christian, Lee, and I, as we actually understand the hex code, but there is quite a translation for everyone else.I'll post examples of code to explore different types of VTPs and LWMs, so you can see how it's done in TDF-BGLC, and so you can get used to the new terminology.Also, as Gerrish has pointed out, there is now no reason for SCASM not to include these commands in it's next release.. or Airport, FSSC, or Architect. What we learn now will help in any format to come. *:-* DickP.S.Use the avsim forums email to get hold of me if you want. That way we can exchange attachments via the mail, to work out problems. I have a very keen interest in getting as many designers into TDF coding as I can.

Share this post


Link to post
Share on other sites
Guest

I just found my problem when I noticed in the BGLC dos window said I was using the older version 7 compiler so I switched to the new version 8 from the new SDK and they compiled perfectly.The "Terrain Vector Data.doc" found within the new Terrain SDK covers the Terrain Data File (TDF) with two methods of usage for VTP (Vector based Textured Polygons) and LWM (Land/Water Mask Polygons). I'm trying to understand the document terms and explainations but I can't seem to grasp the basic concepts and fundamentals for writing the BGL graphics language. I found your tutorial v1 much more informative and easier (copy-n-paste) to do and I'm hoping soon someone will come forth with an easy user interface for drawing our polygons within Cells (LOD8), and Areas (LOD13).I've installed Visual Studio 6 Pro which includes C++ but I'm finding it way over my head for usage and some online tutorials are confusing me as well. I would be great to have a tutorial to explain basic concepts and fundamentals of this as well.Catch Ya LaterKen

Share this post


Link to post
Share on other sites

Hi all.I found an error in the Terrain polygon SDK.It was stated that X,Y values of polygons is 0,0 in the northwest, and 255,255 in the southeast. This is true.It was then stated that the texture coordinates, U,V are the same... that is not true. Textures are vertically flipped. Here's the proper bglc coding for a Method1 Polygon, with a custom texture:; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -data_start_0 label word VTPDataArea 1, 0, 29, 28 ; count, 0 = Method1 AutoCalc, LOD13x, LOD13y VTPLayer 4, 0 ; Priority layer #4 ( land ), 1 = replace VTPNumTexturesInLayer 1, 0 ; This BGL has 1 texture, always 0 VTPTextureId 0, 0 ; Texture ID# ( starts with 0 ), always 0 VTPPolyCount 1, 0 ; 1 poly to draw here, always 0 VTPPolyMethod1 12, 0, 1 ; count, convex, XYUV formay VTPPointXYUV 0, 0, 0, 255 ; X, Y = polygon point U, V = texture point vertically flipped VTPPointXYUV 255, 0, 255, 255 VTPPointXYUV 255, 255, 255, 0 VTPPointXYUV 0, 255, 0, 0data_end_0 label word; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Attached is the code example for a Method1 VTP polygon. It covers an entire LOD13 quad. The texture is 8-bit mipped... and could have included a transparent alpha, to blend into the default landclass. Any shape, with transparancy is allowed... just translate the U,V points.

Share this post


Link to post
Share on other sites

Hi all.I discovered an error in my VTPMacros.inc concerning the texture naming:I had coding doing this.... TEXTURE_DATA "1197", 0, 1, 4When I should of had coding like this... VTPTextureName "1197" VTPTextureType 1, 0, 0, 4Names are simply character strings with a 0 byte added to the end ( the Macro adds the 0 ).Method1 polys simply use VTPTextureName. They are just Like CFS2 line segments, and can be of any size upto 256x256, and display a section of bitmap with any orientation... including mirror image, and alpha transparancy, within the confines of an LOD13 area. Unfortunately, the bitmap is limited to 256x256 maximum. The SDK was a little vague on this point. Method1 VTPs require a filename string for the bitmap, with no VTPTextureType structure.Method2 polys/lines use VTPTextureName, followed by VTPTextureType. Method2 polys/lines can reference a default bitmap by a number string, as well as a filename string. Lines must have a width. I believe this VTP also needs a 256x256 maximum bitmap size.Here's the corrected VTPMacros.inc:

; VTPMacros.inc	BGLC includes for Vectored Terrain Polygons; --------------------------------------------------------------------------------; --------------------------------------------------------------------------------VTPFileHeader		Macro	Version, IndexHeader, Textures, End	LOCAL	startstart	LABEL	word   UINT32 	20				;				// Size of this header (20 bytes)   UINT32 	Version				;				  // Version (must be 0x0100)   SINT32 	( OFFSET IndexHeader ) - ( OFFSET start );	 		// Relative offset to index   SINT32 	( OFFSET Textures ) - ( OFFSET start );	  // Relative offset of the Texture List Header   SINT32 	( OFFSET End ) - ( OFFSET start )	;		 		// Size of all data plus VTP headersEndM; -----------------------------------------------------------VTPIndexHeader		Macro	NumberIndexEntries, Index, Data	LOCAL	startstart	Label 	word   UINT32 	16				;	   	// Size of this header (must be 16)   UINT32 	NumberIndexEntries		;	// Number of entries in the index   SINT32 	( OFFSET Index ) - ( OFFSET start )	;	   	// Relative offset to the index list   SINT32 	( OFFSET Data ) - ( OFFSET start )	;	   	// Relative offset to the dataEndM; -----------------------------------------------------------VTPIndexEntry		Macro	VTPCellID, start, Data, End   VTPCellID 				;	// ID for cell   SINT32	  ( OFFSET Data ) - ( OFFSET start );		// Offset of data cell from VTPIndexHeader.lDataOffset   SINT32	  ( OFFSET End ) - ( OFFSET Data );	 	// Size of data cellEndM; -----------------------------------------------------------VTPCellID		Macro	Padding, U, V;	UINT32 m_dwPadding:12;		// Reserved, must be zero;	UINT32 m_dwU:10;				// The column (from 0 to 767) in the 768x512 world grid;	UINT32 m_dwV:10;				// The row (from 0 to 511)	UINT32	( V * 400000h ) + ( U * 1000h ) + PaddingEndM; -----------------------------------------------------------VTPTextureListHeader	Macro	NumberTextureEntries, Index, Data, End	LOCAL	startstart	LABEL	WORD   UINT32 	20			;	   	// Size of this header (must be 20)   UINT32 	NumberTextureEntries	;	// Number of entries in the index, (0 to 127)   SINT32 	( OFFSET Index ) - ( OFFSET start );	   	// Relative offset to the index list   SINT32 	( OFFSET Data ) - ( OFFSET start );	   	// Relative offset to the texture names   UINT32 	( OFFSET End ) - ( OFFSET Data );		  // Total size of all the texture namesEndM; -----------------------------------------------------------VTPTextureListEntry	Macro	Start, Data, End	UINT32  ( OFFSET Data ) - ( OFFSET Start )	;	// Offset from the beginning of the name data	UINT32  ( OFFSET End ) - ( OFFSET Data )	;	// Length of the filename in bytes including the terminating zeroEndM; -----------------------------------------------------------VTPTextureName	Macro	Name	BYTE	Name	BYTE	0EndM; -----------------------------------------------------------VTPTextureType		Macro	Type, HasEffect, Reserved, Size;	UINT8	uType:4	;	// Type of formatting used in the texture file;	UINT8	fHasEffect:1;	// Flag for determining if an effect will be used.;	UINT8	uReserved	:3;	// Unused, must be 0.;	UINT8	uSize	;	// Meters per pixel of source texture.	BYTE	( Reserved * 20h ) + ( HasEffect * 10h ) + Type	BYTE	SizeEndM; -----------------------------------------------------------VTPDataArea	Macro	LayerCount, AutoCalc, U, V;	enum{ MaxLayerCount = 31 };;	UINT16 wLayerCount:5;	// The number of layers in this area up to 31;	UINT16 wAutoCalc:1;	// 0 = Method 1, 1 = Method 2;	UINT16 wU:5;			// Column location relative to the cell;	UINT16 wV:5;			// Row location relative to the cell	UINT16	( V * 800h ) + ( U * 40h ) + ( AutoCalc * 20h ) + LayerCountEndM; -----------------------------------------------------------VTPLayer		Macro	Layer, Replace;	enum{ MaxLayer = 63 };;	UINT8 bLayer:7;	 // The layer ID, from 0 to 63.;	UINT8 bReplace:1;   // 0

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