# Projecting 2d vector roads onto 3d terrain at surface height?

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

## Recommended Posts

Hi, I wonder if anyone can help me out here Basically I have height data that is at a certain level of detail plotted to a 3d terrain map. (lots of triangles). I then want to add roads which are at a greater level of detail to this map. The roads would have verticies at x,y locations not on the height data. They are 2d vectors so the PrimitiveType.Linestrip would suit them perfectly. I think it would be very difficult to go through and culculate heights for the road line points from the height data. Is there any way to project it onto the 3d at all? THanks!

##### Share on other sites
Quote:
 I think it would be very difficult to go through and culculate heights for the road line points from the height data. Is there any way to project it onto the 3d at all?
If I understand you correctly, this sounds like a variation of the 'how do I find the height at a specific xy point on my terrain' question that comes up occasionally. Search for 'bilinear interpolation' or 'barycentric coordinates'. If you have a ray-triangle intersection test, you could also just project a ray straight up or down at a given xy, and find out what triangle it intersects and where the intersection point is.

##### Share on other sites
Thanks for the pointers, will look into it. I'm using direct3d mobile so the app will work on WM2005 when its available. I've never heard of the ray triangle intercept thing before. You got the right idea - but ist not as if I want to go coding this stuff, i hope there is a function of some sought in directx that would do it for me.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634060
• Total Posts
3015300
×