Collision Detection

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
ashwin.lele
Posts: 7
Joined: Mon Sep 22, 2008 2:16 pm

Collision Detection

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

Re: Collision Detection

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply