Page 1 of 1

Placing on terrain

Posted: Thu Jun 30, 2011 1:17 pm
by Elfinitiy
Ok so suppose I have a terrain from a heightmap and it has a hill.
How can i place a AnimatedMesh,without setting the y pos.
Like just specify x/z and it locates the y of the hill and places the model (tree for example) on top of it.

Re: Placing on terrain

Posted: Thu Jun 30, 2011 1:35 pm
by serengeor
Hm, by doing something called programming.
1) Open up irrlicht api if you don't know what things can you do with each class/function or don't know if there is a class/function for that.
2) Find class/function. (http://irrlicht.sourceforge.net/docu/cl ... _node.html)
And this might be just the function you need:
virtual f32 getHeight (f32 x, f32 y) const =0
Get height of a point of the terrain.
Use it to get the height and place your tree or w/e you want there.

Re: Placing on terrain

Posted: Thu Jun 30, 2011 1:40 pm
by Elfinitiy
This I know very well.
My question was,IS there another way like the one I mentioned earlier ?

Re: Placing on terrain

Posted: Thu Jun 30, 2011 1:54 pm
by serengeor
Elfinitiy wrote:This I know very well.
My question was,IS there another way like the one I mentioned earlier ?
And what exactly did you mention?

Re: Placing on terrain

Posted: Thu Jun 30, 2011 1:56 pm
by Elfinitiy
Like just specify x/z and it locates the y of the hill and places the model (tree for example) on top of it.
Something similar to
Attaching a weapon to the camera.
I don't locate the camera position and then set the weapon pos to camera.pos+weapon.pos,but specify the weapon position from the camera perspective directly.
Something similar here

Re: Placing on terrain

Posted: Thu Jun 30, 2011 2:24 pm
by hybrid
Well, it does not work automatically, but adding just two calls (one getHeight on the proper position and then the setPosition on the node with the new height) seems to be pretty easy. Why don't you use that?

Re: Placing on terrain

Posted: Thu Jun 30, 2011 3:12 pm
by Elfinitiy
hybrid wrote:Well, it does not work automatically, but adding just two calls (one getHeight on the proper position and then the setPosition on the node with the new height) seems to be pretty easy. Why don't you use that?
Because when I think of something,I always know there has to be a better way.

Too bad its the only way thou :(

Re: Placing on terrain

Posted: Thu Jun 30, 2011 3:26 pm
by nespa
try a collision response animator, will be done automatically.