[solved] Drawing a 3D line to terrain heightmap

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
trnrez
Posts: 28
Joined: Wed Dec 27, 2006 5:56 pm
Location: Murfreesboro, TN
Contact:

[solved] Drawing a 3D line to terrain heightmap

Post 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.
Last edited by trnrez on Thu Jan 15, 2009 10:34 pm, edited 1 time in total.
Jon Jones
Portfolio - needs updating
trnrez
Posts: 28
Joined: Wed Dec 27, 2006 5:56 pm
Location: Murfreesboro, TN
Contact:

Possible Solution

Post 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.
Jon Jones
Portfolio - needs updating
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post 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.
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post 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
trnrez
Posts: 28
Joined: Wed Dec 27, 2006 5:56 pm
Location: Murfreesboro, TN
Contact:

Post 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)?
Jon Jones
Portfolio - needs updating
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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? ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Post Reply