LWMDRAW

version 3  By: Ken Nelson

======================================================================

LWMDraw was originally developed (with allot of help from my friends) for my own use to create default type and with effects FS2002 water such as Lakes for FS scenery areas.  Seeing it was helpful for myself, and saved hours of consuming time, I decided to release it as (FREEWARE) for FS scenery designers and users alike.  If you've read through and completed the steps within the LWMDraw Quick Start Guide menu then you'll know at this point what the scope of LWMDraw was designed and developed to do.  With that intent, LWMDraw works quickly and accurately within any single LOD 13 Area and if you haven't read or completed the Quick Start Guide please do so before you continue reading this Help tutorial.  Doing that will give you a better understanding of the text below.

I've written this Help Tutorial to hopefully give you some more knowledge about what Cells, Areas, LWM's, and VTP's are and how they are used within FS.  I've also written this to show you how to manually edit the source files so that adjoining multiple LOD 13 Areas can be placed into one source file and then assembled into one FS scenery.bgl file.  Combining multiple Areas takes LWMDraw out of it's scope of development as it generates only one single Area source file for each Area and this is the reason manual editing becomes necessary (unless you'd rather have a pile of scenery.bgl's).  Actually, FS will read a multiple of assembled scenery.bgl files and manual editing is not really necessary but you will see in the following text that manually editing multiple Area source files is not really difficult and only takes a few minutes of copy-n-paste routine plus, placing the multiple Area source files together will result in having less total files to contend with making your scenery area easier to keep track of, not only for you but for your users as well.

At this point LWMDraw will generate a complete source file called LWMSource.asm that's ready to be dragged-n-dropped onto the BGLC.exe assembler (compiler) which will output as an FS scenery.bgl having a water area within any particular LOD 13 area and in any shape you wish.  Along with that and new to version 3, LWMDraw will also generate a separate VTPSource.asm file to place a shoreline at the same data points used for the LWM's.  There are other options available for both LWM's and VTP's that LWMDraw does not include at this time and I hope that the below text will help you understand where to find further information about other options as well as how to add them.  In time I hope to add more of the options to LWMDraw but until that happens, what you see is what you get.  Before we begin this Help tutorial please read the following text about LWM's, VTP's, Cells, and Areas.  The information contained will not only help you gain more knowledge but it will also give you an understanding of what's going on in the background as you design your scenery area with LWMDraw.

LWMPoly's (Land/Water Mask Polygons) and VTPPoly's (Vector Textured Polygons)

LWM's and VTP's are a part of the TDF (Terrain Data File) BGL graphic language that is default to FS2002 and the BGLC.exe assembler (compiler) that has been released within the FS2002 SDK's (Software Development Kits).  Although both LWMPoly's and VTPPoly's are part of the same TDF file structure and they have many similar appearances they both have options and limitations separate from one another, one of which is why LWMDraw generates their source files separately.

To get a more in depth understanding of LWM's and VTP's you could read the Terrain Vector Data.doc file found within the FS2002 Terrain SDK or you could download and read lwmtut.zip from the Avism file library.  This file is an LWM Tutorial by Richard Ludowise which explains the Terrain SDK document in a much easier to understand fashion, at least for me anyway and in fact it was Richard's example files found within this tutorial that got me to create LWMDraw.  The tutorial explains each line of the LWM source file, all the parameters, and explains the many other options that can easily be edited into the source file.  With that I'd like to recommend that you read Richard's tutorial.  It will show you what more you can do that LWMDraw does not include at this time.  There are three things about the LWM's that I really like one being no textures are required to upload with the scenery for the water or land areas created by LWM's because this technology uses existing default water and textures.   Two, there are NO frame rate hits that older technology brings.  And three, LWM's do NOT effect autogen around the LWM area simply because they are Default to FS2002.

VTP's are quite different from their LWM counterpart but VTP's are just as default to FS2002 as LWM's.  At this point my knowledge about VTP's is very basic since I have not yet seen a 3rd party tutorial released about them however I was able to implement VTP's into LWMDraw by converting an Airport 2.60 road/line source file (.sca) to a VTP source (.asm) file using Falko Dienstbach's SCM2VTP conversion tool.  I used the converted output.asm file as a template to experiment with and found more knowledge through Richard and again the Avsim scenery designers forum.  From the knowledge I have acquired however VTP's have two methods for it's usage and LWMDraw uses the method 2 type which is easier to work with as the FS scenery engine itself helps to work out many of the details for us.  In the text below I'll do my best to explain more about both LWM's and VTP's and with that I hope you find LWMDraw easy to use and helpful as well in your efforts to enhance your FS Experience.

LOD 8 "Cells" and LOD 13 "Areas"

Text from the FS2002 Terrain SDK document
To facilitate quick data retrieval in Flight Simulator, the earth is broken up into a grid with 512 rows and 768 columns.  Each Cell in the grid is 0.3515625 degrees latitude (180/512) by 0.46875 degrees longitude (360/768). (see Special Note)  The Cells are numbered from upper-left to lower-right.  The upper-left corner is located at 90 deg. latitude and -180 deg. longitude. Each Cell is divided into 32 x 32 areas.   On average, each area covers a little over one-and-a-half square kilometers.

From the dimensions given above, Cells are pretty large covering just a hair under 25 miles in both X and Y directions.  If you were to compare the decimal numbers above with the FS2000 SDK description of LOD (Level Of Detail), you’ll find that a Cell covers the exact same dimensions as the LOD 8 grid.   As mentioned, the 32 x 32 grid of Areas making up the Cell (numbered from 0 to 31 in both X and Y directions) is what the SDK refers to as the LOD 13 grid.  Areas on average are just a hair over three quarters of a mile square or pretty near 4,000 feet.

Special NoteFor me, trying to describe the X and Y distance of Cells and Areas in easy to understand terms is a little difficult but I want to give it a shot anyway because with a good understanding of this you'll have an understanding of what the FS scenery engine is doing for us in the background.

First, we all know that the earth is a sphere almost round ball and if you were to look up the meaning of a sphere you'd get the definition of a perfect round sphere. Being the earth (and FS earth) is not a perfect sphere the term Geoid comes into play to describe it's shape.

The earth geoid rotates on it's axis of the north and south poles and because of this the equator becomes somewhat enlarged making the earth wider west to east than it is tall north to south. Imagine if you will walking 360 degrees around the earths equator. This is going to take you a very long time to walk because the distance of each degree at the equator is 111.32 Kilometers. However, we can stick a pole directly into the north or south poles and walk 360 degrees around the stick in less than 5 seconds. With that you can see that the distance of a degree changes as we go north or south from the equator but walk in the same west to east direction. Sphere's and Geoid's both share this concept which is called the Cos factor of Latitude degrees.

Also for your knowledge, keep in mind that Longitude degrees do NOT and are NOT affected by the Cos factor so no matter where you are on the earth, walking north and south is always the same distance for degrees.

Hopefully I haven't confused you with the above explanation. The FS scenery engine keeps track of all Latitude and Longitude coordinate factors for us and for this reason you'll notice a squeezing (from west to east) of Cells and Areas giving you some different looking displays than you may have thought you would especially when you go far away from the equator north and or south. This is also the reason I use Richard's CellGrid files that display the Cell and Area boundaries on the FS earth. That way I can place an LWM or VTP accurately to the shape I want and keeping that in mind you'll be able to use photoreal images as well.

One similar element between Cells and Areas is that they both are made up of Data Points evenly spaced at a distance of 4.8 meters apart.  Cells, because they are larger than Areas, contain 8160 data points in both X and Y directions (numbered from 4080 to 12239).  VTP's use the Cell data point structure for the placement of roads/lines/shorelines.  Areas on the other hand contain only 256 data points in both X and Y directions (numbered from 0 to 255).  LWM's use the Area data point structure for the placement of land/water masks.  Although both Cells and Areas have a similar data point element you can see there is a major difference in the formatting of the point values and the amount of point values as well.  For me that knowledge itself describes the major difference between Cells and Areas.

Another similar element in both Cells and Areas is they both blend poly texture edges at the boarders and within their data point structures as well.  You’ll see proof of this blending upon LWM placement of a water area where the water begins to cover or overlap the shoreline edges.  The blending softens abrupt poly texture edges also and makes the transition to the default terrain textures nicer to look at as well.

As mentioned above LWMDraw was originally developed with LWM's in mind hence the name LWMDraw.  LWMDraw represents the Area data points (numbered from 0 to 255 in both X and Y directions) with a loaded 256x256 pixel sized image which has the same amount of data points as each Area and this is where LWMDraw is within it's developed scope and works best.  In a few moments you'll be reading the below tutorial which will eventually show you that, for multiple adjoining Areas within the same Cell,  you'll have to generate an LWMSource.asm file for each adjoining LOD 13 Area.  After that step I'll show you in the next step how to edit them together into one file.

Keeping that in mind, please take note that new to this version of LWMDraw is the VTP's for roads, lines, and shorelines and the VTP data points are calculated within the LOD 8 Cell which have 4080 to 12239 data points in both X and Y directions.  Along with that VTP's have other FS limitations and their data point structures are represented much differently in the VTPSource.asm file and with a different format than LWM data points as well.  For these reasons we'll have to generate the VTPSource.asm file one time only which is after we've finished generating all the LWMSource.asm files for the scenery area.  Just doing that and a little tweaking of the VTP ListBox and TextBox, that I'll be showing you below, you'll be successful in designing and creating any sized water area with shorelines within any particular Cell.  I'd also like to add at this point that if your adjoining Areas that are not within a single Cell (like this help tutorial shows) then you'll have to visit the Avsim scenery designers forum to find information on how to place them into the same source file as I haven't gotten that far yet with my own knowledge.  In time I hope to add these features and open the scope of LWMDraw farther to include an entire LOD 8 Cell and all the Areas that make up the Cell.

======================================================================

Let's Get Started

For the Help tutorial below I'll be rebuilding my old FS98/FS2000, Bush Lake scenery area.  Originally it was created with the older type "stretch the points" polygon method placing a water texture onto the old FS ground surface.  This was great for it's time as FS Floatplanes had no problem landing on ground poly textures but now in FS2002 old ground textures of water are NOT default water.  If you try landing a floatplane on a ground image texture you'll certainly skid and crash.  FS2002 now gives us much more realistic water to play with.  As a matter of fact, we have more FS water than what we know what to do with as the FS developers covered the entire FS earth with an LWM mask of Water before placing landclass and default terrain ground textures onto it so you might think of this LWM process as excluding an area of default texture's and landclasses to expose the underlying FS default water.

======================================================================
Files and Tools Needed:

LWMDraw:  Got it:

lwmtut.zip: From the Avism file Library: Download
Again, I feel this tutorial by Richard Ludowise is a must read document for your knowledge and understanding of LWM's and that part of the BGL graphic assembly language.  You'll find the information within it very helpful as well as interesting. I promise!!!!

cellgrid2.zipFrom the Avism file Library: Download
Created by Richard Ludowise again, I'll use Richard's CellGrid files to easily place the colored grid lines onto the FS ground surface defining the LOD 8 and LOD 13 boundaries for my scenery area.

BGL_Compiler_SDK:  From the FS2002 web site: BGL Compiler
From within this download extract the assembler (compiler) BGLC.exe and place it into the CellGrid2 directory and another copy into the LWMDraw directory.

TDFHeaders.inc and TDFMacros.inc:
Both of these files are found within the CellGrid2 directory mentioned above and I've also copy-n-pasted these files into the LWMDraw directory as well because they are needed when I assemble my lake and shoreline source files.

======================================================================
Step 1: CellGrid Setup

I first went into FS and located the near center for my Lake area using the FS top down view option.  At that point I recorded the coordinates (latitude and longitude) and the altitude then used the Save Flight option so I could return later in the exact same place.

Now I'll open LWMDraw and type my FS coordinates and press the Calculate button.  Take note that instead of using letter values like N, S, E, and W that I use a minus (-) for South and West coordinate entries.  At this point I'm only interested in getting the Cell information.  As you can see below, the Cell indicated is  65 81.

After unzipping and reading the Readme.txt file found within the CellGrid2 folder, I created a notepad file and called it Bushgrid.txt and typed the two necessary lines and saved the changes:

With the files,  Cell_Grid.inc, TDFMacros.inc, TDFHeaders.inc, and BGLC.exe within the CellGrid folder directory, I dragged-n-dropped Bushgrid.txt onto BGLC.exe and the outcome was a compiled Bushgrid.bgl.  Now I placed my new bgl into the CellGrid2\scenery folder, started up FS (in my saved location), and used the FS Scenery Library to add this scenery.  Pressing the spacebar in FS orients my view to North.  The screenshot below now shows grid lines which are the LOD 13 Areas within the LOD 8 Cell boundary.  I decided here to use 4 LOD 13 areas.  (6, 2 - 7, 2 and 6, 3 - 7, 3)

After taking a screenshot of this (shown above) I exit FS and enter my paint program to display the screenshot image.

======================================================================
Step 2: Setting up Images for LWMDraw

I could easily just hand draw any shape of a lake I want to create on a 256x256 pixel image and call it good enough but for this example I'm using my old Bush Lake top down view screenshot.  Here I've already extracted (cropped), resized, and re-colored my lake area from an older screenshot using the "Magic Wand" tool within Paint Shop Pro prior to this point and placed it on a transparent background.  I then saved the image in psp format so the lake image layer itself stays separated form the transparent background.  Like this:

Now I just paste the image of Bush Lake onto my FS screenshot with the CellGrid Lines showing.  Like this:

Now I'll merge the image layers above to lock everything in place then I'll  zoom to the outside corner locations for each of the 4 LOD 13 areas (NW 6, 2 - NE 7, 2 - SE 7, 3 - SW 6, 3) and cut this out of the screenshot.  Like this:

As explained within Richards LWM tutorial, each LOD 13 area is recognized by the FS scenery engine as having a 256x256 pixel grid numbered from 0 to 255 (top to bottom) and 0 to 255 (left to right).  With that I resize my cutout image (containing the 4 LOD 13 areas) to a 512x512 pixel sized image.  Doing this will stretch the lake area out of shape but that's ok because the FS scenery engine will put all the data points (LWMPoints and VTPPoints) in the right position when it reads the data from the final assembled scenery.bgl's.  (see Special Note above)

Now I slice the 512x512 pixel image into 4 equal 256x256 pixel images giving each image a name corresponding to it's numbered LOD 13 area.  Like this:

  

  

======================================================================
Step 3: Creating the Source File

NOTE 1The Combo-Box just below the calculate button, for selecting the type of road/line/shoreline, lists all the possible selections available by default.  You'll find more specific information on each type selected within the "terraintextures.cfg" file found within the main FS2002 directory folder.  I have not tried all the optional lines available but there is a large selection and many of these options include seasonal and autogen behaviors as well.  Again, see the terraintextures.cfg for more details.

Now it's time to startup LWMDraw and type the FS coordinates in the input textboxes provided, again use minus (-) for S and W coordinate entries, then adjust the Altitude and press the Calculate button.  After that I'll also go ahead and select the type of shoreline I wish (NOTE 1 above) and then adjust the shoreline width and set the Layer value (NOTE 2 below) in the places provided under the calculate button.  You will notice in the screenshot below that my original coordinate entry is within LOD 13 area 7, 2 (that's the NE corner).

NOTE 2I've copied the tables from the FS2002 Terrain SDK document (page 6) below so you can adjust your Layer accordingly.

The following table lists how the layer values are distributed.

Type of Data
Layer ID

Water Texture

0 – 3

Land Texture

4 – 7

General

8 – 100

The following table lists the layer values used in Flight Simulator 2002.

Type of Data
Layer ID

Airport Skirtings and Parks

4

Shorelines

8

Streams

16

Dirt and Minor Roads

31

Major Roads

32

 

Although I don't think it matters which area we do first, (the order of areas), I prefer to start with my 6, 2 area (NW corner) just for my own order of things and I'll work in a clockwise direction from there.  With that take note I easily move to the NW corner by increasing the Longitude Minute (Min) value in small amounts until my desired area shows within the Area LOD 13 box.  Increasing and decreasing Latitude moves north and south as well.

NOTE 3:When clicking around the water parameter area it's important to work in a clockwise direction in order to place the VTP shoreline correctly otherwise the shoreline will be reversed.

Now I'll click the Load 256x256 Image button and load image 6, 2 and start clicking clockwise around the parameters, shoreline area, (NOTE 3 above) within the image.  Please note the screenshot below showing the Starting Point for both LWM and VTP points (farthest lower left of the 256x256 image).  I'll click at that starting point and work up and around (clicking on the lake edge) going to the right direction (clockwise) and after I've clicked the VTP Ending Point (upper right 256x256 image) I still have one more click in the bottom right corner (LWM End Point 255, 255) which is used to complete the circle of points which is needed for LWM's so they'll merge to the other LOD 13 areas we're going to add.  Having clicked that needed last point for LWM's however has caused that data point to be added to the VTP colored ListBox and if this VTP data point is left alone, it will cause a shoreline to run into the middle of the lake water.  Therefore, that last VTP data point MUST be selected and removed within the VTP ListBox and after doing that the VTP2 Lines/Points TextBox (top right corner of LWMDraw window) MUST also be edited to reflect one less line/point.  (NOTE 4 below)

NOTE 4The TextBoxes provided for LWM and VTP2 Lines/Points increase a single point/line value with each click of your mouse on the image.  It will sometimes be necessary to edit these boxes.  For one reason is when you remove a selected line within a respective colored larger ListBox mentioned above.  If one line is removed from a ListBox then you MUST subtract 1 from the total value shown in the Lines/Points TextBoxes and edit the change manually.  Also, with earlier versions of LWMDraw there was a maximum of LWM points set at 62 points but now LWMDraw adds the Extended option which will increase the point value to 317 lines/points allowed.  When the Extended option is reached (63 points) the numbered text within the textbox will turn RED showing you that your over the standard point count and running in Extended mode.  Likewise the VTP2 Lines/Points TextBox will also turn RED when Extended mode is reached however VTP2's have a standard of 31 points.  When 32 points is reached the numbered text will turn RED and work in Extended mode but I do not know what the maximum point value is at this time for the VTP lines/points.  Please let me know it you figure that out as I've had upwards of 130 points without any problems yet.  Along with that, upon the first mouse click the LWM Lines/Point value will be 1 (one) while with the same first click the VTP Lines/Point will equal 3 (three) and when you see this you'll also notice 5 lines auto-inserted into the VTP ListBox.  Do NOT BE ALARMED by this weird happening, the three longer lines (VTPWidePoint) all represent the first click and MUST be counted as 3 data points.  (that's an FS limitation for the format of default type VTP source files)

  

If you've made it to this point having loaded and clicked around the first image (6, 2) then edited the VTP ListBox and Lines/Points Textbox it's then time to click the "Create LWMSource.asm" button (do not create the VTPSource.asm file yet).  After doing this I'll leave LWMDraw open and then look into the LWMDraw directory and rename the created LWMSource.asm file to something that more reflects my Bush Lake and the LOD 13 area image.  How about "Bushlk62.asm".  Having finished area 6, 2 I'll bring LWMDraw back up then Clear the LWM ListBox and LWM Lines/Points TextBox and then load the next image in clockwise order which is 7, 2.  It's important here to NOT clear the VTP information from either the VTP ListBox or VTP2 Lines/Points Textbox because we only need to create the VTPSource.asm file after completing ALL the LOD 13 LWMSource.asm files.

With image 7, 2 opened within LWMDraw I'll start clicking on the new image at the same point as the VTP Ending Point from image 6, 2 and continue around clicking in a clockwise direction.  Again when I've reached the last shoreline point I'll have to create another corner point and just like I did with image 6, 2, I'll have to remove that last data point line from the VTP ListBox and edit it's TextBox again as well.

I would imagine that your now beginning to get the picture of what I'm doing here.  Anyway just in case, when I've completed image 7, 2 (just like I did 6, 2) I just go through the same process for the next image in clockwise order 7, 3 and then 6, 3 after that.  Once the last LWMSource.asm file has been generated and all has been completed with the VTP ListBox and TextBox for all images then it's time to generate the VTPSource.asm file.  At this point the VTPSource.asm file is ready to rename and assemble with BGLC.exe which gives me a shoreline scenery.bgl file.  As an example for you I've renamed the VTPSource.asm file to "bushshore.asm" and I've placed a copy of this file within the Bush Lake Example folder of LWMDraw's main directory.  You can use it as a template for comparing your own source files to it and if you wish to experiment go ahead and drop bushshore.asm onto BGLC.exe and go check it out in FS.

======================================================================
Step 4: Merging the LWMSource Files into ONE file

Each of the four source files could assemble into four separate scenery.bgl files and FS will read them ok this way but I would rather manually edit my first source and copy-n-paste the LWMPoint data from the other three source files so that ALL are merged into one source file.  With that I'll now open my first source file (Bushlk62.asm) and scroll to the bottom of the LWMPoint data lines and then I'll skip ONE line under that and place the blinking cursor there.  Like this:

Now I'll open my second source file (Bushlk72.asm) and scroll to the line that says: "LWMDataAreaDrawPolygons 1, 3, 1, 7, 2" and copy-n-paste that line and down to the last LWMPoint line into the cursor location I've just mentioned above.  Like this:

Now I'll simply do the same process as shown above for my last two source files (Bushlk63.asm and Bushlk73.asm) adding all four areas to the first original source file.  After completion, I'll rename Bushlk62.asm to a file name to reflect completion.  How about simply "Bushlk.asm" and I've uploaded this source file along with LWMDraw as well so you can see exactly what I've done.

======================================================================
Step 5: Assembling the Source File

Once you've completed editing the source files together as one file just drag-n-drop your source onto BGLC.exe making sure all the necessary Include (.inc) files are present (TDFHeaders.inc and TDFMacros.inc) within the same directory folder.  If you like, you can assemble my example source file "Bushlk.asm" in the same way.

======================================================================
Some Comments

After you've gone through the above steps a couple of times you'll see how quick and easy it really is to create a default type Lake (water) area.  It's even way easier if you wish to experiment with only one LOD 13 area drawing out your outlined water area onto a 256x256 pixel image.  LWMDraw does have a disadvantage at this time as it only deals with a single LOD 13 area at a time causing you to manually edit the source file for multiple areas.  Also please take note that many other options are available with LWMPoly's & VTPPoly's and once you've read Richard's LWM Tutorial, (lwmtut.zip), you'll have a much better understanding of all the possibilities that you can edit into the source file.  Again, I hope to add some of those options to LWMDraw as time goes on.

======================================================================
ACKNOWLEDGEMENTS

Richard Ludowise
I have to give a BIG thanks to Richard (Rumba or Rumbaflappy) for sharing his knowledge as he does at the Avsim scenery designers forum and providing me with his personal comments of help and encouragement. I'd like to recommend that you visit the forum and read the message threads by Richard and others as you'll gain valuable knowledge about TDF scenery designing.

Christian Stock
Also, I want to thank Christian for all his earlier experiments and sharing his knowledge with Richard and others as well.  Again, you'll find Christian's message posts at the Avsim scenery designers forum. Those message threads go back a long way so you may wish to search earlier dates.

Chris Wright
Thanks goes to Chris for helping me with some of the mathematical elements placed into LWMDraw. I hope you'll also read his message comments and try his AutoASM program found at Avsim. Thanks Chris!!

VBCity Forums
I visit the VBCity.com forums to help me learn to develop applications such as LWMDraw and more. Being fairly new to VB (visual basic) I have allot to learn still and I'll no doubt visit VBCity allot more and I want to thank all the experienced and helpful programmers there for all their BIG help to me.

======================================================================
Disclaimer

This Author (ME), or any other names listed on this file, are not responsible for any problems or damage resulting from the installation or use of these files.  They seem to work fine on my Windows XP.  Because LWMDraw is written in visual basic 6 you will need to download and install the VB6 runtime library files if your using Windows 98 and earlier Windows versions.

Copyright and Distribution Notice

This package, (archive), is released as Freeware. Copyright (C) Ken Nelson.  As freeware you are permitted to distribute this archive subject to the following conditions,
* The archive must be distributed without modification to the contents of the archive. Redistributing this archive with any files added, removed or modified is prohibited.  ONLY AS IS !
* The inclusion of this package, (archive), or any individual file from this package onto any removable disk drive, (Example: cd-rom or floppy disks), or into another archive for the purpose of distribution for profits, gains, or money is STRICKLY prohibited.
* No charge may be made for this package, (archive), or any part of this package.  THIS IS FREEWARE ONLY !
* The authors' rights and wishes concerning this archive must be respected.

======================================================================
I hope you find LWMDraw helpful

Ken Nelson
Bushlake@aol.com