Jump to content
Sign in to follow this  
ahuimanu

Mapping with GDI+?

Recommended Posts

I'm wondering if anyone can point me in the right direction to learn more about creating vector-graphics maps?If you look at a program like FSBuild or FSNavigator, you'll see that background maps are vector graphics where coastlines and such are drawn. Also, things like airports and navaid symbols are drawn as line graphics too.These features adhere to a geographic lat/long system and I'd like to be able to do something similar for a SimConnect client.I am looking for tutorials, tips or pointers for creating these vector/line graphics. I'd like to learn about I can take a Display area on a Windows Forms canvas and make a map that is spatially proportionate.I hope I've expressed what I am looking for in an understandable manner.Thanks...


Jeff Bea

I am an avid globetrotter with my trusty Lufthansa B777F, Polar Air Cargo B744F, and Atlas Air B748F.

Share this post


Link to post
Share on other sites
Guest ziporama

I wouldn't use GDI because it's probably a little slow for a full map, although entirely workable on today's hardware.There are several things you can do. Head over to fsdevelopper.com here http://www.fsdeveloper.com/forum/showthread.php?t=2938 for a couple of options.The main issue today seems to be getting the source data for the map, now that DAFIFF is defunct.Cheers,E.

Share this post


Link to post
Share on other sites

The vector data you are looking for can be found in the BGL scenery files. It is possible to extract it in a usable form using BglAnalyzeX (google search for this). Map data, rivers, and coastlines can be rendered with good performance using GDI+ and managed C# (Pentium 2.4 or AMD 3000+). GDI+ is not a bad choice and the quality is pretty good. It is not as fast as direct X or other choices, but at the coastline resolution in the BGL files, it can render it fast enough. Hint: be sure to "clip" the data not in the view window, or all performance bets are off. I have moved on to Windows Presentation Foundation and its been a while since I did this kind of thing using GDI+.To render the data, you apply the three basic transforms:1. Use a "translate" transform to go from lat/lon to window coordinates.2. Use a "scale" transform to zoom in and out.3. Use a "rotate" transform to rotate the map (as in track up).These transforms are available in GDI+. However, you may need to roll your own for really fancy maps. Translating is simple addition/subtraction. Scaling is a simple multiplication. Rotating involves sine and cosine functions.Regards,Rich

Share this post


Link to post
Share on other sites
Guest cmontans

>Hint: be sure>to "clip" the data not in the view window, or all performance>bets are off. >Hi Rich, Just a little bit of help... what do you exactly mean with "clip the data not in the view window" ?I have working with GDI+ and C# and its performance with complex gauges is not quite satisfactory, maybe your hint can help me out!Thanks, cmontans.

Share this post


Link to post
Share on other sites

I should clarify. A gauge running *inside* of FSX, and a mapping application running on a separate computer over SimConnect are two very different scenarios. My performance assertions were based on a mapping application on a separate computer per the original post. Gauges on the other hand typically run inside the FSX or FS9 process. In this case, there is very little CPU time available for the gauge to do its thing. If possible, you want to run outside of the FSX process, on a separate thread/core (assuming the current state of FSX) or on a separate machine. As part of a home cockpit project, I have had good success building gauges and maps running on a separate computer driven by SimConnect data (similar to Project Magenta). In addition to looking nice, this has the added benefit of increased FPS since FSX does not have to draw gauges or GPS. However, this is an all or nothing proposition as you can not easily integrate this method into native FSX panels.With respect to map drawing, I probably should have used the word "cull", as GDI+ will "clip" on its own. The amount of map data in the BGL files is huge. It is essential to cull every data element that is outside of the view window before GDI+ renders it. Otherwise, GDI+ will have to consider every element in the entire data set; this a guaranteed recipe for poor performance.Finally, I have switched from GDI+ to Windows Presentation Foundation. This will probably be the 2D API of choice of many for many years to come. Since it is built on top of DirectX, it has the added benefit of hardware acceleration and performance in the range of 60 FPS on a modest computer. Using XAML and high level framework elements, you can accomplish a lot with very little effort.Regards,Rich

Share this post


Link to post
Share on other sites

Hey Brian,Thanks for the heads up on XNA Express 1.0 being released. I didn't see any internal emails about this finally releasing, I had to learn about it over here on AVSim :->Time to see what they broke (err changed :-> ) since the beta release I've been using (the august release).Tim

Share this post


Link to post
Share on other sites

They changed a LOT from Beta 1 to Beta 2, the Design view went away (didn't fit with the direction they were going in) as well as some alterations to the Game class, adding in some things, and an interface to GameComponent. Pretty cool, all together. I especially like the inclusion of GameTime as a parameter in the update and draw functions. It adds a completely inclusive game timing mechanism, just another step towards making my life easier.I had a lot of fun interacting XNA and SimConnect, as one is a structured loop with no WinForms support and one is completely event based. It took some work to get them to play nice.

Share this post


Link to post
Share on other sites

<>its been awhile since I played with that stuff, but I remember it being pretty pointless anyway :-><>I actually wasn't using most of that either :->. Mostly I wanted some stuff that looked more or less like what MDX 1.1 and 2.0 Beta had available, so I basically just create my own Graphics Device object, associated with one of my windows - which allows me to have multiple 3D windows visible at the same time (basically I've got a WinForm UserControl that encapsulates all the DirectX device creation and hooking to a window stuff, and has some lists for putting objects on (conceptually similar to what the Game class and GameComponent are trying to do, without the single window/viewport or fullscreen limitations inherent with those).<>This might also have been one of the reasons I wrote my own framework :-> I included these in my version, hard to do any time based animations without them :->.If I get my UserControl working again with the 1.0 release (assuming it still makes since, have to see what else changed :-> ), I'll send ya a copy to play with if ya want.Tim

Share this post


Link to post
Share on other sites

Hi all,I couldn't remember where I had posted this... *duh*Thanks for the replies...I am not married to GDI+ necessarily save for the fact that it is what is driving Windows Forms, which is still the De Facto 2D graphics rendering approach in .NET 2.0 and Windows Forms.I've only begun to become aware of XNA and I've downloaded it after reading about it on NotASenator's blog.I've also picked up the Petzold book on on WPF...Rich, I'd really like to learn more detail about these operations:[em]To render the data, you apply the three basic transforms:1. Use a "translate" transform to go from lat/lon to window coordinates.2. Use a "scale" transform to zoom in and out.3. Use a "rotate" transform to rotate the map (as in track up).These transforms are available in GDI+. However, you may need to roll your own for really fancy maps. Translating is simple addition/subtraction. Scaling is a simple multiplication. Rotating involves sine and cosine functions.[/em]Can you point me in the right direction? I know that there are method calls to do all of this in System.Drawing, but I am not sure how to use them correctly...Also, will WPF replace Windows Forms entirely? In the preface to Petzold's newest book, he doesn't seem to think so.WPF, XNA, DirectX, GDI+/GDI... sheesh, it's all in flux ain't it?Seriously, thanks for the initial guidance folks, I appreciate it. Any links would be super-duper welcome... :-)


Jeff Bea

I am an avid globetrotter with my trusty Lufthansa B777F, Polar Air Cargo B744F, and Atlas Air B748F.

Share this post


Link to post
Share on other sites

>I wouldn't use GDI because it's probably a little slow for a>full map, although entirely workable on today's hardware.>>There are several things you can do. Head over to>fsdevelopper.com here>http://www.fsdeveloper.com/forum/showthread.php?t=2938 for a>couple of options.>>The main issue today seems to be getting the source data for>the map, now that DAFIFF is defunct.>>Cheers,>>E.I've seen SharpMap and follow the author's blog (who has since moved on to work for ESRI). I suppose I could use that, but I wanted to learn more of the "how to" on my own.Thanks for the tip!


Jeff Bea

I am an avid globetrotter with my trusty Lufthansa B777F, Polar Air Cargo B744F, and Atlas Air B748F.

Share this post


Link to post
Share on other sites

>Thanks E.>>I really really don't like GDI+, so I was hesitant to>respond.Brian,It is my understanding that the System.Drawing contains classes which essentially wrap around GDI+. So, I guess when I specified GDI+ it is because I would be making this as a Windows Forms application. So my question is really:"How do I make vector graphics, which are specified in a Lat/Long coordinate system, map proportionately to an area on Windows Form using the objects such as Graphics, Pen and Brush."Thanks for the feedback! :-)


Jeff Bea

I am an avid globetrotter with my trusty Lufthansa B777F, Polar Air Cargo B744F, and Atlas Air B748F.

Share this post


Link to post
Share on other sites

>You might also consider the new XNA framework released today>by Microsoft:>>http://msdn.microsoft.com/directx/XNA/default.aspxSo is this XNA an abstraction for Direct X and GDI stuff? It sounds like it is making game design easier? It doesn't sound like a replacement for Windows Forms or WPF in terms of desktop applications? It seems like we'd want to make your standard Desktop Application for SimConnect .EXE (in this case managed) applications?I'll be messing around with the new 3.0 stuff in order to update a course I teach in .NET and C#. It sounds like I need to look into XNA in addition to WPF...


Jeff Bea

I am an avid globetrotter with my trusty Lufthansa B777F, Polar Air Cargo B744F, and Atlas Air B748F.

Share this post


Link to post
Share on other sites

XNA is a completely new framework, separate, however very similar to Managed DirectX. It's not actually a wrapper on top of anything.There's no WinForms support built in, but it is possible to slam them together.

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