Page 1 of 1

[solved] Drawing a 3D line to terrain heightmap

Posted: Wed Jan 14, 2009 9:27 pm
by trnrez
Edit: Question needed rephrasing.

I am rendering a set of terrain based on a heightmap and then loading in xyz points that I would like to generate lines from. I would like the data's Y to stick to the terrains Y. Is there a simple method to do this? I looked at getCollisionPoint(...) but this requires me to give a ray when all I want to know is if the point is above or below. If so draw at the terrains Y. I am having a hard time wrapping my head around this so any insight would be awesome.

Thanks and hope I explained that well.

Possible Solution

Posted: Wed Jan 14, 2009 9:51 pm
by trnrez
If anyone can give me a better solution that would be awesome but how bad does the below sound.

I make a collision point to test against that is extremely way up in the Y and one that is extremely way down in the Y. Then use getCollisionPoint(...) to find out if that ray has an intersection to the terrain.

Thanks.

Posted: Wed Jan 14, 2009 10:13 pm
by Eigen

Code: Select all

terrain->getHeight(f32 x, f32 y)
?

If not, then sorry, I don't quite get what you're trying to do.

Posted: Wed Jan 14, 2009 11:19 pm
by zillion42
In a 3d application that would be called projecting a spline.... Unfortunately I can only guess on how one would go about to do ths... Starting with the 3d lines which itself can be quite difficult from my experience.... See this thread. I would think something like get closest vertice... maybe check out how mouse picking determines its position. Sorry haven't looked into it...
good luck

Posted: Thu Jan 15, 2009 3:23 pm
by trnrez
Eigen wrote:

Code: Select all

terrain->getHeight(f32 x, f32 y)
?

If not, then sorry, I don't quite get what you're trying to do.
How did I not notice this in the documentation?! Must of skipped over cause that is exactly what I was looking for! Thanks for the help Eigen. Works perfect now.

But what I don't get is why it is called getHeight yet names the vars (x,y) shouldn't this be (x,z)?

Posted: Thu Jan 15, 2009 3:30 pm
by rogerborg
trnrez wrote:But what I don't get is why it is called getHeight yet names the vars (x,y) shouldn't this be (x,z)?
Quite probably. By default, the coordinates will be X,Z and the height will be Y. However, the terrain could be rotated.

How about longitude and latitude? ;)

Posted: Thu Jan 15, 2009 3:51 pm
by vitek
Well, X and Y are traditionally used when talking about a 2d coordinate system, and in this case that is exactly how it is being used. I personally think it should remain that way.

Travis