Collision between nodes (using triangles ?)
Collision between nodes (using triangles ?)
Hello !
I'm having trouble with Irrlicht collisions. I would like to detect when a node (a mesh) collides with another node (another mesh).
The best solutions suitable that I've found is using bouding boxes :
http://irrlicht.sourceforge.net/phpBB2/ ... =collision
But I would like to have something more precise, like when you're using createCollisionResponseAnimator : a createOctTreeTriangleSelector.
But I've only found a collision detection method between a TriangleSelector and a Sphere... but not between 2 TriangleSelector.
Does anyone have a solution?
Thanks!
I'm having trouble with Irrlicht collisions. I would like to detect when a node (a mesh) collides with another node (another mesh).
The best solutions suitable that I've found is using bouding boxes :
http://irrlicht.sourceforge.net/phpBB2/ ... =collision
But I would like to have something more precise, like when you're using createCollisionResponseAnimator : a createOctTreeTriangleSelector.
But I've only found a collision detection method between a TriangleSelector and a Sphere... but not between 2 TriangleSelector.
Does anyone have a solution?
Thanks!
Code: Select all
bool collision(ISceneNode* one, ISceneNode* two) {
aabbox3d<f32> b1, b2;
b1 = one->getBoundingBox ();
b2 = two->getBoundingBox ();
one->getRelativeTransformation().transformBoxEx( b1 );
two->getRelativeTransformation().transformBoxEx( b2 );
return b1.intersectsWithBox( b2 );
}
Re,
--------------------------------------------------------
Code:
bool collision(ISceneNode* one, ISceneNode* two) {
aabbox3d<f32> b1, b2;
b1 = one->getBoundingBox ();
b2 = two->getBoundingBox ();
one->getRelativeTransformation().transformBoxEx( b1 );
two->getRelativeTransformation().transformBoxEx( b2 );
return b1.intersectsWithBox( b2 );
}
--------------------------------------------------------
That's the code I'm using.
"Use physics engine or collision library"
Ok. Any other way? And where do I find the collision library?
Thank you!
--------------------------------------------------------
Code:
bool collision(ISceneNode* one, ISceneNode* two) {
aabbox3d<f32> b1, b2;
b1 = one->getBoundingBox ();
b2 = two->getBoundingBox ();
one->getRelativeTransformation().transformBoxEx( b1 );
two->getRelativeTransformation().transformBoxEx( b2 );
return b1.intersectsWithBox( b2 );
}
--------------------------------------------------------
That's the code I'm using.
"Use physics engine or collision library"
Ok. Any other way? And where do I find the collision library?
Thank you!
First of all, you are using the relative transformation matrix to transform the box. If your node is the child to another node, this transformation is not guaranteed to be absolute. Thus you need to derive your transformation matrix from the concatenation of your relative transformation and the transformations of your parents, grandparents, etc.
Thus, this is the correct code (given the code you have above):
Luckily you have a function that already does all this for you:
and this can be shortened to a convenient one-liner:
Thus, this is the correct code (given the code you have above):
Code: Select all
bool collision( ISceneNode* sn1, ISceneNode* sn2 ) {
aabbox3d<f32> b1 = sn1->getBoundingBox();
aabbox3d<f32> b2 = sn2->getBoundingBox();
sn1->getAbsoluteTransformation().transformBoxEx( b1 );
sn2->getAbsoluteTransformation().transformBoxEx( b2 );
return b1.intersectsWithBox( b2 );
}
Code: Select all
bool collision( ISceneNode* sn1, ISceneNode* sn2 ) {
aabbox3d<f32> b1 = sn1->getTransformedBoundingBox();
aabbox3d<f32> b2 = sn2->getTransformedBoundingBox();
return b1.intersectsWithBox( b2 );
}
Code: Select all
bool collision( ISceneNode* sn1, ISceneNode* sn2 ) {
return sn1->getTransformedBoundingBox().intersectsWithBox( sn2->getTransformedBoundingBox() );
}
TheQuestion = 2B || !2B
Hello Halifax, and thank you for your great answer.
But, as I said, this is the code i'm using now. I'm looking for something more precise, because this is only collision detection with bounding boxes.
I would like to be able to detect a collision between two nodes using the triangles. Is that possible? If yes, how? Using what functions/lib?
Thanks again.
But, as I said, this is the code i'm using now. I'm looking for something more precise, because this is only collision detection with bounding boxes.
I would like to be able to detect a collision between two nodes using the triangles. Is that possible? If yes, how? Using what functions/lib?
Thanks again.
Hmm id say the easiest ways for better collision would be to use one of the wrappers around ode or physx.
irrOde:http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=33292
irrPhysx:chris.j.mash.googlepages.com/irrphysx
You could also try bullet but im not sure if there is a irr wrapper around it.
irrOde:http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=33292
irrPhysx:chris.j.mash.googlepages.com/irrphysx
You could also try bullet but im not sure if there is a irr wrapper around it.
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do
<Programming is a way of life>
If at first you don't succeed press the delete key till you do
Fisrt node is static, but second is dynamic? Why You can't use standard shapes for Your dynamic object?
If You need more presision in colision, so TriangleMesh vs TraingleMesh You should use external physic engine (in irrlicht it's not supported I think, but I don't use built-in Irrlicht physic, so maybe I'm wrong). I'm using Bullet, so in this engine You can use:
btCompoundShape (with multiple convex hull, look on ConvexDecomposition example) - better solution
btGimpactShape
This is two avaiable solution in Bullet for TriangleMesh vs TriangleMesh, but I don't know why You need thats precision.
If You need more presision in colision, so TriangleMesh vs TraingleMesh You should use external physic engine (in irrlicht it's not supported I think, but I don't use built-in Irrlicht physic, so maybe I'm wrong). I'm using Bullet, so in this engine You can use:
btCompoundShape (with multiple convex hull, look on ConvexDecomposition example) - better solution
btGimpactShape
This is two avaiable solution in Bullet for TriangleMesh vs TriangleMesh, but I don't know why You need thats precision.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
First, thank you all for your answers
Both nodes can be dynamic, or one dynamic one static. I need that kind of precision because I'm actually not developing a game, but a 3D view for a simulation software (train, factory, ...).
Sometimes, I need to be very precise because, for example, the simulation have to detect when an object is in contact with a sensor. The object can have holes int it, be of any shape...
That's why I'm looking for precision, and not boxes
Moreover, if I have a precise collision API, I'll be able to detect collision first on the bouding boxes of the 2 objets, and if there's a collision, I'll look more precisely on the triangles.
Thanks again.
Both nodes can be dynamic, or one dynamic one static. I need that kind of precision because I'm actually not developing a game, but a 3D view for a simulation software (train, factory, ...).
Sometimes, I need to be very precise because, for example, the simulation have to detect when an object is in contact with a sensor. The object can have holes int it, be of any shape...
That's why I'm looking for precision, and not boxes
Moreover, if I have a precise collision API, I'll be able to detect collision first on the bouding boxes of the 2 objets, and if there's a collision, I'll look more precisely on the triangles.
Thanks again.