How Irrlicht Detects Collision Help?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
starsgt
Posts: 19
Joined: Tue Jun 29, 2010 3:49 pm

How Irrlicht Detects Collision Help?

Post by starsgt »

I've been reading the collision tutorial over and over, but I can't quite pinpoint the exact codes that allow the Irrlicht engine to detect a collision. I understand that they implement a "ray" that can detect the triangle polygons of an object and a enumerated constant that allows the ray to determine whether an object is "pickable", but other than that, I don't see how everything comes together.
CuteAlien
Admin
Posts: 9648
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How Irrlicht Detects Collision Help?

Post by CuteAlien »

Maybe check also documentation for ITriangleSelector: http://irrlicht.sourceforge.net/docu/cl ... ector.html
Basically the rays collide with those. ITriangleSelector is just an interface, Irrlicht does not care how it is implemented and has actually itself several different implementations with different characteristics. But in general triangleselectors have a copy of all triangles making up the meshes and are usually updated whenever the mesh changes. Special triangleselectors like OctreeTriangleSelector can optimize certain tasks - in this case for example collision to static meshes can be faster. Also metattriangleselectors allow merging different triangleselectors so they can be accessed through a single object.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
starsgt
Posts: 19
Joined: Tue Jun 29, 2010 3:49 pm

Re: How Irrlicht Detects Collision Help?

Post by starsgt »

So is it safe for me to assume that the rays "collide" with the triangles when the ray length = 0 (distance from object to triangle)? If that's the case, I also take it that there are multiple rays that stream from the object that detects these polygons all around it? (so moving an object side to side and/or backwards can't slip through a wall)
CuteAlien
Admin
Posts: 9648
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How Irrlicht Detects Collision Help?

Post by CuteAlien »

Rays are just rays. When you talk about object collision you probably mean ISceneNodeAnimatorCollisionResponse: http://irrlicht.sourceforge.net/docu/cl ... ponse.html
This does not use rays at all but works with a ellipsoid-triangle collision instead. Basically it's working with ISceneCollisionManager::getCollisionResultPosition: http://irrlicht.sourceforge.net/docu/cl ... 71191aca23
Additionally it implements some collisions response (sliding along the collision plane). If you want more detail you can always take a look at the source (CSceneNodeAnimatorCollisionResponse.cpp/.h).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
starsgt
Posts: 19
Joined: Tue Jun 29, 2010 3:49 pm

Re: How Irrlicht Detects Collision Help?

Post by starsgt »

Ah I see. So the Collision manager detects not only an object collision, but also a mesh collision at the same time. Additionally, there are multiple collision responses that can also be implemented.

Out of curiosity, is there a way for this collision type to distinguish a collision in the "front" or "back" (Head, body, leg, etc.)?

As always, thanks for the help.
CuteAlien
Admin
Posts: 9648
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How Irrlicht Detects Collision Help?

Post by CuteAlien »

For figuring out body-parts I would probably use invisible nodes which are around the real body and check for those.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply