Zurzaza and serengeor (this may interest you cause i'm rotating bodys).
The isbodycolliding function doesnt work with the precision of getbodycollidingpoint. I mean, I get isbodycoliding true really before the two bodies collides, but with getbodycollidingpoint, it returns true when the body actually collides and has a colliding point. Although, with isbodycolliding I only know if the body is colliding, but it didn't tell me with witch other body is colliding.
This method works good for me, I was asking if there is a better way to check if two specific objects has collided.
And well, my principal problem now, is that I want to move and rotate a body totally manually, and check collision with other objects.
First I have some code that I saw in this forum, to make rotations, something like this:
Code: Select all
void rotate(irr::scene::ISceneNode *node, irr::core::vector3df rot)
{
irr::core::matrix4 m;
m.setRotationDegrees(node->getRotation());
irr::core::matrix4 n;
n.setRotationDegrees(rot);
m *= n;
node->setRotation( m.getRotationDegrees() );
node->updateAbsolutePosition();
}
With the functions roll,yaw and pitch to rotate in each axis, just like:
Code: Select all
void yaw(irr::scene::ISceneNode *node, irr::f32 rot)
{
rotate(node, irr::core::vector3df(0.0f, rot, 0.0f) );
}
First, I change the node in the rotate function, to be a CIrrBPRigidBody, so I can use rotate with any type of body in the scene. Wihout any changes, the rotation works well if you rotate from (0,0,0) in any axis, but when you rotate more axis, then it get crazy rotations.
So I change the form of getting the current rotation to node->getIrrlichtNode()->getRotation()
Now the rotation is done well. But what was my surprise, that if I roll de object, the collision detection fails!. If I don't roll the object, it works great, but the moment I roll it, then is like the object is in another position than the one you are seeing the object is. And I see how the object is colliding but I don't get any colliding point and the other object doesn't move of the collision.
So I believe the method of rotation is wrong. First I have a convexhull body, so I tried to make a simple cube and a rigidcube body, and the result was the same.
The rotation code I have now is this:
Code: Select all
void rotate(CIrrBPRigidBody *node, irr::core::vector3df rot)
{
irr::core::matrix4 m;
m.setRotationDegrees(node->getIrrlichtNode()->getRotation());
irr::core::matrix4 n;
n.setRotationDegrees(rot);
m *= n;
node->setRotation(m.getRotationDegrees());
node->getIrrlichtNode()->updateAbsolutePosition();
}
Something is wrong in all of this and I don't know what is. And I'm using irrBP 0.30(r35)