Placing on terrain

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
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Placing on terrain

Post 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.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Placing on terrain

Post 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.
Working on game: Marrbles (Currently stopped).
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Re: Placing on terrain

Post by Elfinitiy »

This I know very well.
My question was,IS there another way like the one I mentioned earlier ?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Placing on terrain

Post 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?
Working on game: Marrbles (Currently stopped).
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Re: Placing on terrain

Post 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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Placing on terrain

Post 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?
Elfinitiy
Posts: 21
Joined: Thu May 26, 2011 10:23 am

Re: Placing on terrain

Post 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 :(
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Re: Placing on terrain

Post by nespa »

try a collision response animator, will be done automatically.
Post Reply