collision detection between two models
collision detection between two models
I'm wondering how to do a collision detection between two models. For example i have two players - and i wan't to check if they touches each other.
models = ISceneNodes
If your models are handled using the ISceneNode, just get the BoundingBox of those two nodes and check if they intersect.
For more information see:
http://irrlicht.sourceforge.net/docu/cl ... box3d.html
If you want to use advanced collision detection read the ODE (physic engine) tutorial, it uses OPCODE (collision detection engine) to calculate the collisions.
Code: Select all
// can be a meshnode or whatever...
ISceneNode* node1;
ISceneNode* node2;
if( node1->getBoundingBox().intersectsWithBox(node2->getBoundingBox()))
{
// collision detected
}
http://irrlicht.sourceforge.net/docu/cl ... box3d.html
If you want to use advanced collision detection read the ODE (physic engine) tutorial, it uses OPCODE (collision detection engine) to calculate the collisions.
Thanx a lot. I'm new in irrlicht so my question can be little lame
I think that i won't need advanced physics.
Back to collision detection. I thought that i could use something like in collision detection example. i mean let the irrlicht handle the collisions and don't let the two models go thu each other like in examples (you cannot walk thu the wall) but i don't know how to do this right now.
I would be very gratefull if someone would give me a clue
I think that i won't need advanced physics.
Back to collision detection. I thought that i could use something like in collision detection example. i mean let the irrlicht handle the collisions and don't let the two models go thu each other like in examples (you cannot walk thu the wall) but i don't know how to do this right now.
I would be very gratefull if someone would give me a clue
-
- Posts: 602
- Joined: Sat Aug 23, 2003 2:03 am
- Location: Pottstown, PA
- Contact:
aint the tutorial clear enough...
Just read the tutorial carefully again... it really should give you enough knowledge to solve your problem.
Well, you asked i try to give a short answer. There are many ways to come along with collision. As you want Irrlicht to handle the collision detection, just use the example in the tutorial .
You just create a triangle selector of the first node and add a collision response animator to the 2nd one. Thats all. I would create the triangleselector out of the BoundingBox of the node, not the mesh itself ( really reducing the triangles).
Well, you asked i try to give a short answer. There are many ways to come along with collision. As you want Irrlicht to handle the collision detection, just use the example in the tutorial .
You just create a triangle selector of the first node and add a collision response animator to the 2nd one. Thats all. I would create the triangleselector out of the BoundingBox of the node, not the mesh itself ( really reducing the triangles).
Code: Select all
// the two nodes
ISceneNode* node1;
ISceneNode* node2;
// the triangle selector
ITriangleSelector* selector1;
// the collision response animator
ISceneNodeAnimator* anim2;
// creating the traingle selector out of the bb
selector1 = smgr->createTriangleSelectorFromBoundingBox( node1);
// the same as in the tutorial
node1->setTriangleSelector(selector1);
selector1->drop();
// adding a collision response node
anim2 = smgr->createCollisionResponseAnimator(
selector1,
node2,
core::vector3df(30,50,30), // radius
core::vector3df(0,-100,0), // gravity
100.0f, // acceleration
core::vector3df(0,50,0)); // position
node2->addAnimator(anim2);
amin2->drop();
thx. I'll try this. I must check the whole collision system more carefully. Just to clearify this a little bit - does it really matter if i create triangle selector in node1 and check against node2, or if i create selector from node2 and check it against node1? In other words, cani reverse the nodes?
If i understand it good - if i want to check cd against multiple object i have to create selector and collisionresponse for each of the objects?
If i understand it good - if i want to check cd against multiple object i have to create selector and collisionresponse for each of the objects?