Assertion failed using TriangleMeshCollisionShape

jonathanblacknight

28-07-2010 10:27:52

When i run this:


OgreBulletDynamics::RigidBody *pernaDirRigid;
OgreBulletCollisions::TriangleMeshCollisionShape* pernaDirShape;

trimeshConverter = new OgreBulletCollisions::StaticMeshToShapeConverter(pernaDir);
pernaDirRigid = new OgreBulletDynamics::RigidBody("PernaDirRigidBody", world);

pernaDirShape = trimeshConverter->createTrimesh();
pernaDirRigid->setShape(pernaDirNode, pernaDirShape, 0.1f, 0.8f, 2.5f);
pernaDirRigid->setKinematicObject(true);


in debug mode i have an assertion failed in ....\bullet-2.76\src\BulletCollision\CollisionShapes\btTriangleMeshShape.cpp
line 188

when i run in release its ok..

obs: I'm using SVN version of ogreBullet, and if i ignore this assertion problem the game runs well

Fish

30-07-2010 01:26:05

I'm not really sure what you're trying to accomplish by creating a static mesh and then making it a kinematic object, but remember that Static Meshes are not movable, so you need to either call setShape() with a mass of zero or call setStaticShape().

If this is for a kinematic character controller, then you'll probably want to use a CapsuleCollisionShape or one of the other generic collision primitives not a trimesh.

- Fish

jonathanblacknight

30-07-2010 13:27:55

Thank you...

I was trying to make a character, with movements and animations.

i'll change for non static meshes and for CapsuleCollisions Shapes..

You have any tips about how is the best way to do this?

jonathanblacknight

02-08-2010 17:10:39

Hi thanks you solve one of my problems, now I'm using a convex shape (AnimatedMeshToShapeConverter), with a kinematic body, with 0 of mass, in this way the shapes are perfect to me.
I have one last problem, my character is composed for 6 node (head, body, arms, legs) i have one Rigid body for each Node, this works perfectly, but when I activate the animations, the shapes does not update.

I think i need something like an update the shape in my frame started method or somethin like this.

Anyone know how i can do this, or can, show me somethin in bullet wiki that can help.

thanks

dodgydan2001

02-08-2010 19:35:26

I think that if you make the mass 0, it makes the physics object into a static object. This may or may not be why it doesnt update properly.

jonathanblacknight

02-08-2010 19:45:33

According of bullet user manual, A kinematic object has zero mass, and
"can be animated by the user, but there will be only one-way interaction: dynamic objects will be pushed away but there is no influence from dynamics objects"

but i'll try to change the mass and i'll post the result asap, thanks :D

shaolin

22-08-2010 13:08:10

It would be interesting to know what your approach is for updating your animated (kinematic) mesh for physics. Does AnimatedMeshToShapeConverter help in updating the bullet shape with the latest blended (changing according to skeletal animation) mesh? Are you doing this as needed for collisions?

jonathanblacknight

23-08-2010 04:59:58

This is my code to make a shape


animConverter = new OgreBulletCollisions::AnimatedMeshToShapeConverter(mainChar->bracoDir);
mainChar->bracoDirShape = animConverter->createConvex();



I'm have a char, and i need to update the shape when, for example, he uses a punch move

thanks

shaolin

24-08-2010 15:08:35

If you need more accuracy, you could make several shapes (one for each bone) from the mesh using createOrientedCapsuleCollisionShape or so and add them as kinematic objects to the physics world. you can then update their position and orientation from the ogre skeletal animation bones as they move.

This should give you more accurate results for hit tests etc.

jonathanblacknight

24-08-2010 15:43:12

I think that i understand, if i'm right i need design the shapes according to my skeleton and bones, and not according with my nodes and entities.

The problem is how easy or how hard is to update a shape of the result of animation.

I'm so new, how to do this in bullet, but i think that i'll be easy

If you have any suggestion will be very welcome

thank very much.

jonathanblacknight

31-08-2010 06:13:55

I found a easy way to update shape in animation...

When i activate the animation i do this


void Util::updateShapeFromEntity ( OgreBulletCollisions::CollisionShape* shape , OgreBulletDynamics::RigidBody* corpoRigido, Ogre::Entity* entidade ){
OgreBulletCollisions::AnimatedMeshToShapeConverter* animConverter =
new OgreBulletCollisions::AnimatedMeshToShapeConverter(entidade);
shape = animConverter->createConvex();
corpoRigido->getBulletRigidBody()->setCollisionShape(shape->getBulletShape());
delete animConverter;
}


But the debug drawer doesn't update =/

shaolin

02-09-2010 09:13:29

Sorry to hear that the debug display doesn't update. That's weird...

When are you activating animation (and so, calling this code)? Are you doing this every frame when the animation is active (playing)? I am not sure if that will be optimal for a continuous animation that keeps playing for a while.

If you want to use skeleton (bones) to move your collision objects (that you created offline in a modeling application or using createOrientedCapsuleCollisionShape), you can "attach" the collision objects to the skeleton's bones. This way, the collision objects will closely follow your skeletal animation and thus your mesh's geometry.

These collision objects can be kinematic bodies if you want other objects in your world to collide and respond to your collision objects (character) more accurately.

For hit tests (to check if a bullet hit the character, etc), you can use a collision object with no collision response and run ray queries to check for hits. If you only needs to check for hits, it's better to construct the collision shape as needed like you are doing now. This way, you should get a more accurate result. Also, I would use a GImpact shape (concave) for more accuracy.

Hope this helps.

jonathanblacknight

02-09-2010 17:29:00

check:
http://yfrog.com/f/eh2onp/

the punch animation is actived, but the debug display of the right arm is still in the start position

I don't know i'm right, i'll need first create a shape according of my skeleton and then updating when the animation is actived

I'll need do something like OgreBulletCollisions::AnimatedMeshToShapeConverter to convert the skeleton...

but i'm really don't know how to update bullet according the animation callback