Jump to content
  • Advertisement
Sign in to follow this  
frogtag

OpenGL 3D rendering of Ordinance Survey Contours

This topic is 4248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The Problem As the title says i'm trying to come up with an accurate (or at least quite accurate) way of rendering in 3D the contours off an OS Map. I'm using OpenGL and simply translating coordinates like for like, for map to 3D coordinate. It seemed easy but every idea i've theorised doesn't work and has a degree of inaccuracy. Can anyone help me with either a theory or even better working code?

Share this post


Link to post
Share on other sites
Advertisement
Assuming you're using a heightmap or 3d mesh, then you can render contour lines quite easily by using a 1d texture containing marks at contour line intervals, and then using the height/z coord as the texture coord. You can do the last step manually or via automatic tex coord generation (and depending on your maps scale you'll probably need a constant scale factor to get the texture to repeat at the correct rate.

If you don't have a 3d mesh to start from then you're going to have to give us more details as to what and how you've got your map represented as.

Share this post


Link to post
Share on other sites
Yes i'm using a 3D mesh, 21x21 for simplicity until i can get the theory sorted, with height points at the bisecting of the lines (scale is all set up). However your method of marking the heights at each point doesn't work as the contours aren't symetrical and uniform in shape and so thats my problem, working out the precise height at any point with the mess.

Share this post


Link to post
Share on other sites
It'll work, but if you're only sampling at the grid cell corners it'll be pretty inaccurate.

See Nyquist frequency - the rate at which you're sampling heights is insufficient to reconstruct the original surface (the contours). To get accurate results you're going to have to take many more samples, depending on the actual map you might need upwards of 100 per grid cell. If you're unable (or unwilling) to do that, then you're going to have to get the information another way - such as grabbing the contours off the original map as a texture and stretching it across your 3d model.

Share this post


Link to post
Share on other sites
Always Willing to put the work in, thats the fun bit!

My first attempt at this problem saw me write a programme that allowed me to input every contour point on a 1000x1000 grid. Then it did the maths and filled in the gaps, creating a height at every point on the grid, the problem is it only sample from top to bottom, y-axis, and so didn't take into account the x-axis variations, this created inaccuracy. However if i sample one point on the grid for each direction, it will more often than not create two different height values for the same point, and if i mean those values it'll create another new height value.
I guess what i'm asking the long way round, is mathematically how do i get right height for anyone spot on the grid, keeping in mind that it will be affected by the contour spread of both the x and y axis?

Share this post


Link to post
Share on other sites
Are these maps printed or in data files? If they are data files in any sort of vector format, this is a problem from the realm of cartography. If they are printed, then please disregard the following.

There's lots of material on the subject of contour to TIN conversion out there. Here are a couple links I found with a quick google:

http://www.geovista.psu.edu/sites/geocomp99/Gc99/091/gc_091.htm
http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u39.html

I only gave them a quick scan but I imagine there's enough there to at least get you started. A really rigorous implementation of these sorts of processes will produce a really nice-looking surface terrain model.

A lot of these can work from a cloud of 3D points. Yours are associated into contour lines so you have a lot more data to work with.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!