Sign in to follow this  
rhumbaflappy

LWMViewer tool for FS2004

Recommended Posts

Hi all.I've put together a tool to display the FS2004 LWM files, as an aid to designers. It's still very much under development, but it can already help with showing where add-on scenery will have problems with the default FS2004 lakes/rivers/airport flattens. Locations are given as lat/long as well as the area and cell IDs.I'm looking at adding support for FS2004 VTP files, but haven't decoded the entire file format yet. If anyone has information on this, I'd appreciate a look.Download at http://www.jimkeir.co.uk/LWMViewer.zip . Controls are simple: keypad +/- for zooming, click or keypad arrows for scrolling around, keypad 5 to recenter and reset zoom.Regards,Jim Keir.

Share this post


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

Hi Jim:this is great - I just loaded up a FS9 HP9*.bgl file and a FS2002 HYP*.bgl file and both work perfectly, even if loaded at the same time; this will indeed be a big help for LWM editing tasks.Is there a reason why some polygons are outlined in red instead of black?One comment: I believe you have the legend backwards. LOD8 grid sections are called "Cells" and LOD13 sections "Areas". I find this very confusing myself, as in my cognitive world "areas" are bigger than "cells". Alas, apparently not in the mind of the person who came up with this convention ;-)Would it be possible to also display the elevation of the LWM polygon beneath the cursor?Thank you very much for this great tool!Cheers, Holger

Share this post


Link to post
Share on other sites

Hi Jim,I keep following your posts, although I'm not replying. I'm too busy converting my lakes at this stage. Once I have my whole GIS data (coast, lakes, poly rivers) in the correct GIS form that will export the whole lot to LWM polys in one mouse click, I can worry about the FS2004 format again. I actually thought I had it already, but then my GIS data crashed FS2004 in FS2004 format.Cheers, Christian

Share this post


Link to post
Share on other sites

Hello Christian-Which GIS are you using? I have often thought this would be the way to go... allow conversion of GIS data to what we need.Simpit

Share this post


Link to post
Share on other sites

Hi.> Is there a reason why some polygons are outlined in red instead of black?Yes - the red-outlined polys are what I think are the new-style variable height areas. It seems to fit, because they tend to show up on appropriate parts of rivers. As for the legend; yep, it's probably wrong :) I'll reverse the titles, and add an extra panel to show the height. FYI, my 'debug' version also loads and displays some VTP files. There are still things I don't understand in them though - there's a new VTPWidePoint command which I've not worked out fully.Regards,Jim Keir.

Share this post


Link to post
Share on other sites

ArcGIS 8.2. I've written a small module to do the job. The data needs a bit of preparation (has to be a shapefile and needs splitting into LOD13 quads, easy to do with the geoprocessing wizard though, I've written a small macro to generate a grid layer). The tools are really just developed to do the job for me with NZ data. Don't know if I will find the time to make it a tool that I could be easily distributable...Cheers, Christian

Share this post


Link to post
Share on other sites

Interesting.I was talking to Justin Tyme of Fsgenesis about his GIS, Manifold, and the potential of him writing a plugin for that particular program to do basically the same thing. I am an Autocad user from way back and have often thought about writing an export routine from that program.Do you think there is any way to come up with some open source "pseudocode" that anyone with a particular brand of GIS could use as the basis to come up with a translator/converter for that particular program? I'm thinking more on the algorithm level...Derek

Share this post


Link to post
Share on other sites

I'm not using any special algorithms really. My code just reads shapefile polys and writes them into BGLC code (so it simply reads coordinates and writes them into a text file). I'm using the inbuilt functionality of ArcGIS 8 to split the geographical data into LOD13 or LOD8 grid sized polygons. I was contemplating if I would program such an algorithm, but since there are a lot of special cases to be dealt with, I left it in the end, since it's much easier to use ArcGIS directly.Cheers, Christian

Share this post


Link to post
Share on other sites

Jim, many thanks for a *great* tool! I only wish I had it a year earlier. When developing AutoAsm I spent many happy hours constantly re-loading FS and slewing across to find all the errors. With your program it would have been much, much easier and would have saved countless hours of work. Best regards, Chris

Share this post


Link to post
Share on other sites

Hi.I've updated this a bit: it now shows which files it has loaded, supports drag-and-drop, optionally uses FSConnect or FSUIPC to 'track' the position in FS9 and shows most of the other files that come with the sim.I've worked out most but not all of the new VTP format, so all the corresponding objects are visible:- AB : airport polygons- FL : flattens (usually match the airports)- HL : Shorelines- HP : LWMs- RD : Roads- RR : Railways- ST : Rivers- UT : Utilities (power pylons etc)There are some others, such as PK9*.BGL, which it will also display. If nothing happens when you load a file, it contains no LWM or VTP data.There are still some places where it gets it wrong, so I'll post a full description of the format as soon as I fix those errors. In the meantime, enjoy and please be patient if it does occasionally display crazy paving over half the country :)Also, I don't have a registered copy of FSUIPC, so I've not been able to test that. Can someone let me know if it works?URL as before: http://www.jimkeir.co.uk/LWMViewer.zipRegards,Jim Keir.

Share this post


Link to post
Share on other sites

Hi again...OK, one last(?) update. I've fixed the remaining display bugs as far as I can tell, and added an 'autoload' option for the FS9 link. Same file, same place. I'll try to throw together a description of the file formats tonight.I've requested a program key for FSUIPC; if that gets issued, I'll build the key into the program and re-post. Also, if I can get a little feedback on its stability, I'll post it to the file download area here.Regards,Jim Keir.

Share this post


Link to post
Share on other sites

Hi Jim.Although I'm sure you'll get your key to FSUIPC, you may consider using FDSConnection from http://www.flightdecksoftware.com/They have code that is almost identical to FSUIPC's IPC, and you may distribute the module with the tool. Although it's still in development, it should work well for you. I used it in TCalc2004 without any problems.That avoids the key problem with FSUIPC. You may not be aware of it, but each version or name change of your program will require a new key... I found that annoying, and tool users would as well.Dick

Share this post


Link to post
Share on other sites

Hi Jim,In trying your tool, I tried pulling in an AP file and loading all the matching files. This caused an error resulting in a Send/Don't Send report to MS. I guess the AP files are the airport files that Lee Swordy looks at to do the AFCAD magic.If I pulled in the same file with the other letter extensions, i.e, HP, etc., I didn't get the error.The particular file I used was AP926210.bgl as a reference.You latest post indicates you have another update, but when I downloaded from your site, it was still the 11/25/2003 8:28AM version.W. Sieffert

Share this post


Link to post
Share on other sites

Hi.Er, yeah. Sorry - I uploaded it to the wrong folder :( I've fixed it now, so try again. If you still get the same version, try clearing your browser's cache.For information, I've now got a program key for FSUIPC, and the details for the other DLL mentioned in another post and I'll add them tonight, as well as checking the ??926210 files. BTW, the AP* files aren't shown anyway, they don't seem to contain any terrain-related information.Regards,Jim Keir.

Share this post


Link to post
Share on other sites

Hi Jim,Got the new version. Thanks! Just to let you know, I use a registered copy of FSUIPC and the functions seem to work.I put FDSConnection.dll in the modules folder but wouldn't know which one is providing the input/output if they are both in the loop. I need FSUIPC since I use WideFS.W. Sieffert

Share this post


Link to post
Share on other sites

Hi.I've fixed the bug with the file you mentioned; another ExtendedPoly I'd missed.Also, I've added support for FDSConnection in addition to FSConnect and FSUIPC. You only need one of the three installed for it to work, but there shouldn't be any problem with having more. FSUIPC is the first one checked in the program, since it is the only one that seems to support Write operations correctly.Incidentally, these DLLs are only needed to support the 'flight following' functions. The file viewer part still works fine without them.Another update (!) on the website, hopefully in the right place this time... BTW, my email address should be in the ReadMe.txt file. Feel free to email directly if you find further problems.I'll get round to documenting the file formats RSN.Regards,Jim Keir.

Share this post


Link to post
Share on other sites

Hi Jim.Would it be possible for LWMViewer to build a georeferenced bitmap file of the BGLs to a size specified by the user?That could be very helpful to users of Coastline Maker or Ground2K. Ground2K could use bitmaps of up to 8000 x 8000 pixels without trouble. A 1000 x 1000 size for each cell would be useful.It could also help designers with access to GIS programs, as they could load new vector data over the bitmap, and view the changes their data would make.Dick

Share this post


Link to post
Share on other sites

Hi.Yep, I think so. The height display I put in last week is based on a bitmap anyway, it's just a case of adding some scaling and saving it to disk.FYI, I've been asked to allow disassembly of the BGLs to disk, which I also plan to add soon. I think I'll add an 'Export' menu wth various options. And that reminds me, I've not posted details of the new VTPs yet. I prepared a document and then forgot about it :) I'll try and post that tomorrow. Briefest of brief summaries, from memory:=====================- VTPWidePoint.wReserved is now a point count, for following VTP3Points- VTP3Point is a signed 24-bit struct: X_Offset:11; Pad:1; Y_Offset:11; UseWidth:1;The offsets in the VTP3Point get added to the last plotted point. VTPWidePoint specifies a fixed location, as it used to. Both VTPWidePoint and VTP3Points count towards the total number of points in a poly. Like VTPWidePoint, each VTP3Point can also specify 'UseWidth' and be followed by an extra byte.=====================There are other small differences, but this struct was (for me anyway) the hardest part to work out.Regards,Jim Keir.

Share this post


Link to post
Share on other sites

Hi Jim.Great news. A save to bitmap function would be great.Here's the macro I've been using:; --------------------------------------------------------------------------------VTPChildPoint Macro ChildX, ChildY, WidthFlag WORD ( WidthFlag * 8000h ) + ( ( ChildX MOD 800h ) * 10h ) + ( 0 * 8h ) + ( ( ChildY MOD 800h ) / 100h ) BYTE ( ( ChildY MOD 100h ) ) EndM; --------------------------------------------------------------------------------The term I used was VTPChildPoint ( "VTPChildPoint 21,333,16" ), small difference in semantics... but if you would rather use the VTP3 term, I think that would be fine. I'll update the TDFMacros.inc after you publish your info.I also have used:; --------------------------------------------------------------------------------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; --------------------------------------------------------------------------------I think these structures are right, and they show fine in the sim and in your LWMViewer.If I wait for the SDK to add these terms, it might be a long wait. :(Dick

Share this post


Link to post
Share on other sites

Hi,in these times of ungratefulness to freeware developers, just a few words to thank you for your useful tool. It makes flatten removal so much easier ! :)

Share this post


Link to post
Share on other sites

Jim, I just wanted to say how extremely useful LWMViewer has proved to be, particularly over the last week. I've been working to find a solution for islands (polygons inside polygons), a major problem when importing TerraScene images into AutoAsm. The good news is that I have a working solution (I plan to release AutoAsm before Christmas). But naturally during development the program generated lots of interesting LWM problems. Using LWMViewer to check for problems is much faster and more convenient than firing up FS. Over the last week or so it's saved me a lot of time. Many thanks! Best regards, Chris

Share this post


Link to post
Share on other sites

Hi Jim:I wholeheartedly agree with Chris' and HotShot's praise - this is one cool tool ;-)To make it even cooler (just kidding) here's a tiny request: would it be possible to add a function that allows one to enter lat/long and then computes the name of the FS9 LWM file for that region? I assume you know the formulae but here they are again, just in case:**9xxyy0.bgl, with xx (longitude) = TRUNC((180+long)/3.75)yy (latitude) = TRUNC((90-long)/2.8125)Note: enter negative values for western longitudes and southern latitudesUsually, I know the LOD5 coordinates of the areas I'm working in but occasionally I'd like to check out other areas quickly. I have the formulae in my EXCEL toolbox (as does TCalc2004) but it would be nice to have it integrated in LWMViewer as well.Cheers, Holger

Share this post


Link to post
Share on other sites

Hi.Yes, I think that could be added. Even better, what about a 'load file by lat/long' dialog box, which displayed the filename before loading? You could always cancel the box if you don't want the files loaded.I've uploaded a new version which includes the 'export bitmap' function that was requested. BGL disassembly is in the pipeline too, but not in place yet.Many thanks to the folks who are posting here saying they like the tool! It's always good to hear that people are finding it useful.Regards,Jim Keir.

Share this post


Link to post
Share on other sites
http://forums.avsim.net/user_files/51535.jpgHi Jim,I also want to thank you for your LWM Viewer tool (and also a belated thanks to Christian for his Ground2K4). I am a beginner,and this is the first scenery project I've ever attempted. With tools like yours to work with, it makes it possible for a beginner like me to create some really high quality work. I'd also like to thank all of you regular contributors, and I will try to be more active in offering my assistance to anyone else who is just getting started. Anyway, I am enclosing a picture from my scenery project I'm working on of Buckeye Lake in east central Ohio. There is nothing really spectacular about this lake. In real life, it is just an overgrown pond. I believe its maximum depth is less than 10 feet. What makes it unique is that it spans two LOD5 cells. In order to get it to display correctly and eliminate the default LWM, I had to disable HP925170 and HP926170, which are found in two different folders (Namc and Name). Of course, this also took out most of Lake Erie and every smaller body of water across four states. I don't think I could attempt this without your LWMViewer to find and replace all thost. Thanks again.Paul

Share this post


Link to post
Share on other sites

>I've uploaded a new version which includes the 'export bitmap'>function that was requested. BGL disassembly is in the>pipeline too, but not in place yet.Wow, great news. lwmviewer will get the popularity it deserves for sure. (Btw how did you come to this as there is no SDK available yet ?)>Many thanks to the folks who are posting here saying they like>the tool! It's always good to hear that people are finding it>useful.I guess our mums once taught us to thank people for their presents. ;)>Regards,>Jim Keir.Greetings from the other shore of the Channel =)

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