Page 1 of 1

Collision Detection

Posted: Sun Sep 28, 2008 6:13 am
by ashwin.lele
Hello guys


Well i am planning to implement a simple crowd
My steps were like this

I loaded the MD2 model "sydney" placed her in the world. I wanted here to move in any direction so i wrote a custom animator for her.

Now i used the collision response animator as said from the tutorial.

What i want to do is if the model collides with the object it should change its direction and try again.

What i am not understanding is how i use the collisionresponseanimator class. Is there something like OnCollision event. i couldnt find something in the API Manual

Any sample source codes,books etc will be greatly appreciated

Re: Collision Detection

Posted: Sun Sep 28, 2008 7:45 am
by rogerborg
ashwin.lele wrote:What i am not understanding is how i use the collisionresponseanimator class. Is there something like OnCollision event.
Unfortunately, there currently isn't. Collision detection is (by design) fairly basic in Irrlicht.

We could add an optional callback to ISceneNodeAnimatorCollisionResponse, but bear in mind that in an environment with gravity there will likely be a collision every frame with the floor or terrain.

So for the callback to be useful, you'd have to know what was collided with. Right now, ISceneNodeCollisionManager::getCollisionResultPosition() only returns the "last triangle causing a collision", so if there are multiple collisions (against a wall and the floor, for example) it won't be deterministic which triangle you'll get back. Also, there's no way (at the moment) to determine what scene node the collided triangle is associated with.

So it's possible, but it'll need both thought and work to do it in a useful manner.

Since what you do in response is application dependent anyway, you may be better just implementing collision entirely in your user app. You have all the Irrlicht source available, and are free to copy the relevant parts (e.g. CSceneNodeAnimatorCollisionResponse::animateNode()) to your user app and modify them as necessary.