Jump to content
Sign in to follow this  
rhumbaflappy

FS9 LWM file structure

Recommended Posts

Hi all.In an earlier post, I suggested an INC that would allow us to create LWMs in the FS9 style. That INC seems to work fine:http://forums.avsim.net/user_files/50476.jpgLWM3.inc:; LWM3.inc; --------------------------------------------------------------------------------LWMPoly3 Macro PointCount, Reserved, Attrib, HeightStart, FractionStart, HeightEnd, FractionEnd; BYTE bPointCount:6 ; // Up to 62 points; BYTE bReserved:1 ; // Must be 0; BYTE bAttrib:1 ; // Polygon fill attribute, 0 = water, 1 = land BYTE ( Attrib * 80h ) + ( Reserved * 40h ) + PointCount SWORD HeightStart ; // Whole elevation value in meters BYTE FractionStart ; // Fractional elevation value in 1/128 meters SWORD HeightEnd ; // Whole elevation value in meters BYTE FractionEnd ; // Fractional elevation value in 1/128 metersEndM; --------------------------------------------------------------------------------LWMPoly3Ex Macro PointCount, Reserved, Attrib, HeightStart, FractionStart, HeightEnd, FractionEnd, ExPointCount; BYTE bPointCount:6 ; // Must be 63; BYTE bReserved:1 ; // Must be 0; BYTE bAttrib:1 ; // Polygon fill attribute, 0 = water, 1 = land BYTE ( Attrib * 80h ) + ( Reserved * 40h ) + PointCount SWORD HeightStart ; // Whole elevation value in meters BYTE FractionStart ; // Fractional elevation value in 1/128 meters SWORD HeightEnd ; // Whole elevation value in meters BYTE FractionEnd ; // Fractional elevation value in 1/128 meters BYTE ExPointCount ; // Number of polygon points = 63 + bExPointCountEndM; --------------------------------------------------------------------------------LWMPoint3 Macro x, y, z BYTE x ; BYTE y ; BYTE z ; 0-225 fraction of difference between HeightStart and HeightEndEndM; --------------------------------------------------------------------------------Here's the code:include TDFMacros.incinclude TDFHeaders.incinclude LWM3.incBGLHeader 43, 41, -87, -89, LWMHeader , TerrainHeaderStartLWMHeader label word LWMFileHeader 300h, LWMIndexStart, LWMStart, LWMEndLWMStart label word datamark_0 label word LWMDataAreaDrawPolygons 1,3,1,1,23 LWMPoly3 4,0,0,295,123,600,0 LWMPoint3 0,0,0 LWMPoint3 255,0,0 LWMPoint3 255,255,255 LWMPoint3 0,255,255 datamark_1 label word;----------------------------------------- Cell_195_134 EQU LWMCellID 0,0,3,195,134 LWMIndexStart label word LWMIndexHeader 1,LWMIndexData LWMIndexData label word LWMIndexEntry Cell_195_134,LWMStart,datamark_0,datamark_1LWMEnd label wordThe line "LWMPoint3 Macro x, y, z" shows it's the z-byte that controls the height of the points as a fraction... 1/256th of the span between HeightStart ( and it's fraction ) and HeightEnd ( and it's fraction ). The line "LWMFileHeader 300h, LWMIndexStart, LWMStart, LWMEnd" defines this as 300h... FS9 LWM.This can lead to all sorts of mischief... especially in use as remeshing. I haven't explored all the possibilities, but we should be able to use something like TCalc2004 to retrieve mesh heights.If the HP9* bgls are deactivated by renaming them as OLD, rather than bgl, then we can view the scenery without water, and its flattens. By slewing to the LOD mesh verticies, we can then read what height we'd want for the 4 corners of those remesh points. Those mesh altitudes could also be grabbed from TMFViewer by using the lat-long jump function, to jump to the right mesh points.Mesh can be thought of as a series of squares, with each vertex defined as an elevation... exactly what the new LWM3 can do.The mesh LOD points can be derived as the verticies of the LOD level. CellGrid2004a, for example, would define the mesh verticies of LOD5.A cellgrid-like utility could be made to ID the vertex points of LOD8, or LOD9 or LOD10... or perhaps all three defined by color. Then we could slew to the coordinates and read the elevations needed for each square's corners, in order to remesh.It should also be possible to build sloping runways ( of a sort ) with these LWM3 polys. Or undo the effects of default roads and streams that cut into the underlying mesh.Sorry for the long post.Dick

Share this post


Link to post
Share on other sites

Hi Dick,Nice info :).But what are the main difference compared to the Fs2002 LWM polygons? Is it only that we are able to set the height for each point?


Arno

If the world should blow itself up, the last audible voice would be that of an expert saying it can't be done.

FSDeveloper.com | Former Microsoft FS MVP | Blog

Share this post


Link to post
Share on other sites

Hi Arno.Yes, the difference is that we can set the height of the poly points... otherwise they behave the same.There still is no way to return to the default or underlying mesh. We still have to simulate the mesh with "remeshing".I haven't done a lot of testing with this, but now we know the meaning of the new bytes. What the upper and lower limits of LODs are is unknown... LOD13?? or LOD11 ( like mesh )??Dick

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