View Full Version : overlay roads on terrain
08-30-2002, 12:27 PM
I have a terrain which I've drawn using elevation data. Now I want to draw roads on top of it using 2d data, which gives me the coordinates of the center of the road & the road's width. I can interpolate using the elevation data to get the z values of the coordinates but I want to use the road width to expand it & draw the whole road, not just a line. I need to find the coordinates of the road edges.
Any ideas on where I might find information on how to do this?
08-30-2002, 07:00 PM
Any Linear Algebra text book should suffice.
Road Direction Vector
your road edges can be found by crossing the direction vector with the surface normal and normalizing, then multiplying by HalfWidth and -HalfWidth respectively, and adding to RoadPoint.
Of course, if the terrain is undulating, this may put the edges inside or above your heightfield, so you probably want to raycast in the direction of the original surface vector to find the actual height of each edge. Or just run your favourite triangle clipper on the terrain mesh to generate the terrain-following-road mesh.
08-31-2002, 02:53 AM
The fastest way is often to create an overlay texture out of the road data and then project that texture ontop of the ground. E.g. ig you have terrain that changes like roam or LOD levels this is the best way.
08-31-2002, 08:29 AM
Unfortunately, your approach will stretch the road on sloped surfaces. Yes, it's faster (especially on fill-rate capable set-ups) but the quality is less.
If you're doing a game, it's probably good enough. If you're doing a GIS, it probably isn't.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.