A terrain collision issue!

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
renegadeandy
Posts: 122
Joined: Sun May 25, 2008 11:14 pm
Location: Scotland
Contact:

A terrain collision issue!

Post by renegadeandy »

Hey long time no posting from me!

Im back with another problem however!

This time I have remodelled my terrain using a 3ds max scene instead of a boring heightmap - i like that better.

Since doing so I think my collision has stopped working properly for my sydney object who is running along the terrain - and the terrain wall which sydney is running towards. For some reason sydney continues to run through the wall and along the same axis for an infinite distance, here I have a before the wall, and after the wall picture!

Before the wall:

http://img247.imageshack.us/my.php?image=beforefo6.jpg

After the wall:

http://img514.imageshack.us/my.php?image=afterdr6.jpg

This is not meant to happen.

The code for my object - which is Buster.cpp which is the sydney model is here :

http://pastebin.com/m5d16a488

And the code which deals with the terrain collision setup and the rest of the malarky like instantiating the Buster is the main:

http://pastebin.com/m1446ad21

I create an octtreeselector on the mesh of my .3ds file for the terrain - which is used for the collision detection of Buster model - but it doesnt appear to be working!

Please help me!

Thanks in advance for any help!

Andy :evil: :evil:
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

Warning: the one who is going to write this message didnt touch c++ or the irrlicht engine for 300 years so his reply is 99.9% wrong ,thanks
I THINK The problem is here :P

Code: Select all

#
 ISceneNodeAnimator* anim3 = smgr->createFlyStraightAnimator(node->getPosition(),
#
                                   node->getPosition()+ core::vector3df(0,0,100000),50000, true);
as it's movement is set to increase by"100000". so it moves and moves and then when it gets near the wall it moves its next move where it passes the wall
so it doesnt hit it! :lol:
And as we said it is just a stupid answer :?
renegadeandy
Posts: 122
Joined: Sun May 25, 2008 11:14 pm
Location: Scotland
Contact:

Post by renegadeandy »

em what?!

Please explain, and how do I correct!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The fly straight animator will put the node (sydney) behind the terrain sometimes. The calculation of the node's position will continue, whatever results a collision might give. And at some point in time the node will be positioned at x% of the way (due to time advancing) where x is large enough to return a point behind the terrain. Then, sydney will be moved beneath the collision mesh and won't collide anymore, so continue until reaching the target.
renegadeandy
Posts: 122
Joined: Sun May 25, 2008 11:14 pm
Location: Scotland
Contact:

Post by renegadeandy »

Ahh right - so how do i stop this from happening, as thats a bit rubbish!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Don't use the fly straight animator, or change the animator to only advance a little from the current position, instead of moving it to some precalculated place.
renegadeandy
Posts: 122
Joined: Sun May 25, 2008 11:14 pm
Location: Scotland
Contact:

Post by renegadeandy »

well if i dont use a flystraightanimator I will need to use a different animator - but they will do similar things no?

By u saying move it a smaller amount, are you suggesting like 4000 instead of 10000?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, the fly straight animator simply interpolates the position over time, so it might even be the case that or some time the collision will block the fly straight. But at some point in time the interpolated position of the scene node will be so far behind the wall that collision won't happen. Reducing the distance will not help, unless the new position is only shortly behind the wall. You have to write an animator which moves the node into the direction towards the target, but not interpolating over time, but constantly adding a precalculated offset which is small enough to let the the collision happen.
renegadeandy
Posts: 122
Joined: Sun May 25, 2008 11:14 pm
Location: Scotland
Contact:

Post by renegadeandy »

Ok i understand that now - how do you suggest to do this then.
Post Reply