RigidBody::setKinematicObject

HiddenBek

22-11-2007 21:46:25

Hey all. I have some animated objects that need to interact with dynamic bodies, so I added a setKinematicObject method to OgreBulletDynamicsRigidBody.h. Here's the code:

inline void setKinematicObject(bool isKinematic);


inline void RigidBody::setKinematicObject(bool isKinematic) {
if (this->isKinematicObject() != isKinematic) {
//flip kinematic state
getBulletRigidBody()->setCollisionFlags(
getBulletRigidBody()->getCollisionFlags() ^ btCollisionObject::CF_KINEMATIC_OBJECT);
}
}


I also made a short video. The robots and the camera are kinematic objects, while the boxes are regular dynamic bodies.

What's the best way to submit changes like this? Should I email Tuan? Just post here? I'm not much of a C++ programmer, so I'm hesitant to ask for CVS access, but that would be an option if folks don't mind correcting me when I do something foolish.

Chaster

27-11-2007 16:07:10

I can add it, but just so you know - I'm currently debating whether it is a good addition since it's mostly a convenience function which people can easily code themselves outside of OgreBullet. There's nothing wrong with convenience functions of course (I've added some myself) but I just want to make sure it doesn't clutter up OgreBullet's interface unnecessarily..

Tuan, any thoughts?

Chaster

HiddenBek

27-11-2007 20:03:54

Understandable. Seeing isKinematicObject without setKinematicObject just struck me as odd, but the Bullet API works the same way. It's certainly easy enough to get by without it.

I believe that including convenience methods where possible is the way to go (why think when my API can do it for me?), but I come from the Ruby world, where the practice is followed to an almost comical degree. Leaving it out is probably closer to the Ogre way of doing things.

Thanks for taking a look Chaster. I appreciate it.

CHG123

07-12-2008 05:59:51

I want to preface this by saying that I am pretty new to bullet and ogre hence I am also pretty new to ogreBullet...

I have been struggling for some time now on getting the basic ninja.mesh from the ogre examples to process collision detection while animated...

I even went so far as to implement the MeshStrider class listed on one of the previous posts which allows you to share verticies. Then I used Entity->_getSkelAnimVertexData to share the animated vertex data... with the bttriangleMesh object.

That seemed to work ok... my test was just to shoot balls at the animated ninja it was about 50/50 sometimes the balls would hit and sometimes they would go through and hit the other side of the mesh and sometimes just go through completely...

Now I also tried your method of setting the object to be kinematic... Maybe that is "The method" but I just was ignorant to it...

That seemed to work ok too maybe a little better then shared animated vertex data... but I still ran into the problem when the balls would go through the animated mesh sometimes.

I also tried making the trianglemesh with shared animated vertex data kinematic and that yielded worse results.

Am I doing something inherently wrong?


does OgreBullet / Bullet have some way of detecting collisions on an animated object?

I am sure it must but so far a good solution eludes me.

Maybe i just need to use a different mesh for my testing instead of the ninja.mesh?

Thank you for all the help.

CHG123

07-12-2008 21:51:08

do I need to use a convex hull type instead of the bttrianglemesh?
I have read that triangle meshes cannot be kinematic? is this true? I was able to set the rigid body containing the trianglemesh as a bullet shape to be kinematic and it compiled and ran.... to get accurate ocllisions do I just need to use a convex hull instead of the triangle mesh? In your video how did you make your animated robots collide with the boxes so well?