Jump to content

Contours instead of a height map?


qqdarren
 Share

Recommended Posts

I want to take contour data (e.g.) from maps, and make a WebGL 3D explorable landscape; I am posting here, as my current plan is to build on top of Babylon.

 

I believe the contour data is stored as vectors, most likely bezier curves. My plan up until now was to built a raster image (i.e. a 2D height map) from the contour data, initially using straight line interpolation between the contours (then, later, some kind of curve fitting algorithm to smooth it out). Then I take the height map and use CreateGroundFromHeightMap().  That, in turn, will make a plane from triangles, and adjust the y-coord of each triangle corner.

 

That got me wondering if I am taking the long way round? Is there some way to build a 3D surface directly from contour vectors?

 

Link to comment
Share on other sites

yes sir : ribbons

http://doc.babylonjs.com/page.php?p=24847

http://doc.babylonjs.com/page.php?p=25088

 

Each of your contour line is a path : a series of successive points.

In a given path, they all have the same altitude, say, z coordinate values.

You will just have to set x and y for each point on a given contour, right ?

 

So just fill as many contour arrays as needed with points of the same contour in each array.

Please try to put the same number of points in each array, even if you have to set them in the same position x,y,z, this will ease the final ribbon rendering.

 

Then put each of your contour array in another unique contours array, and finally construct your ribbon.

var contour2500 = [p1, p2, ..., pN];  // all vector3 have z = 2500 herevar contour2000 = [q1, q2, ..., qN];  // all vector3 have z = 2000 here...var contourN = [...]; // all vector3 have z = N herevar contours = [contour2500, contour2000, ..., contourN ];var myRelief = BABYLON.Mesh.CreateRibbon("relief", contours, false, false, 0, scene);
Link to comment
Share on other sites

  • 2 weeks later...

Hi guys.  I think...

 

mesh.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight)

 

and...

 

mesh.applyDisplacementMap(url, minHeight, maxHeight, onSuccess)

 

...might apply.  Got a url for a grayscale contour map?  Then it might be easy to make a heightMap terrain from it.  But ribbons are cool, too.  :)

Link to comment
Share on other sites

Curse you Wingnut: more things to study ;-)

 

BTW, I don't think Google is indexing the docs.babylonjs.org site? It was quite hard to track down those functions... but even when I did there was no explanation there. Thank goodness for open source, so I can get this: https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Mesh/babylon.mesh.js#L801   But it is still not clear how to choose to use this instead of CreateGroundFromHeightMap(), (or over the ribbon approach).

 

(This sub-project is currently stalled due to lack of test data - it turns out understanding the map data formats is more like a week's job, rather than the hour's job I was hoping it was.)

Link to comment
Share on other sites

please let us know if you achieve to get elevation data

I'm really interested in this.

A friend of mine in south of France just bought a small antena for 30 € and set it on his house. Thus he catches all live flight data of planes flying within a 500 km radius : direction, speed, altitude, plane number and some other transponder public data.

I asked him to set up some server (he's a sysadmin) to publish his live data on-line (http, websocket, or any tcp protocol he can).

I intend to display then each plane flying in 3D ... just like http://www.flightradar24.com/ but in 3D and with animated planes (right speed and altitude).

 

If I could moreover show the planes on a real 3D map, it would just be fine  :)

We could, for instance, have the view from a real plane as it is flying above us !

 

I'd like to do the same also for my father who is a great mountain hiker and GPS tracking addict :P : to display his walk on a 3D relief from his own GPS data.

 

Arrg, so many things to do and so little time  :(

Link to comment
Share on other sites

You guys are interesting... I love listening to your ideas.

 

You are right, qqd.  It appears that the displacementMap feature didn't get documented, or it's hidden somewhere.  Maybe you would like to write about it, and we can make sure it gets added to a section in heightMaps, maybe.  Just jot down the things you discover or find interesting, if you do more experiments.  Hell, just post about them here, and we'll use this thread to make the displaceMap docs.

 

Here's our tiled grounds tutorial.  Playground #6 there... is map stuff.  No shaded relief, but hey, its live-querying of map data from within the playground, and that gets awarded a 2 foot lawn statue, by default.  (some hero worship for Kostar111)  :)  Maybe if the map IMAGES can be queried and tiled, so can the elevation data.  Maybe. 

 

Here's a PG demo where I used displacementMaps.  If you notice, I brought both of the "Big-2" displacementMap functions into the playground editor (from the framework).  I think I only did one modification... lines 34/36. 

 

All in all, this might be a good playground to zip-up or make new saves-from... do some testings.  It might be wise to compare my localized applyDisplacementMap() and applyDisplacementMapFromBuffer() with the "official" BJS framework versions... someday... just to make sure I didn't modify mine...  too non-standard.

 

At minimum, when the Big-2 displacement methods are put into the PG itself like that, we can put many console.log messages within them, and watch them work, and we can learn... and steal stuff.  :)

 

What was this bezier curve stuff?  Were you guys talking about smoothing operations?  I think we have some Catmull-Rom and cubic hermite code on-board.  I'll let you read about them and dig-up the BJS functions yourself.  :)  I don't know if those things are apropos to your ideas, but maybe.

 

I find that one of the best heightMap/displaceMap smoothing methods... is a blurring technique I call Jack Daniels.  ;)  It's not easy to provide THAT level of functionality for all the users of your scene, though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...