Bullet skeletal animation

Post Reply
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Bullet skeletal animation

Post by paokakis »

Hello to the group,

I'm using opengl and want to implement skeletal animation on imported objects. Currently the animation will be handled on the gpu(vertex shader) and I need to synchronize this with the rigid bodies. Any ideas on how to proceed?

P.S I don't have any code yet for this as I am doing an analysis first
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Bullet skeletal animation

Post by drleviathan »

This sounds much like a robot simulation project. Are you planning on using pyBullet or the C++ library? If pyBullet I suggest you move your question to the pyBullet forum. If C++ then you're in the right place.

When it comes to how to proceed... it is a pretty broad question and since I haven't done exactly what you're doing I have only vague ideas about how I would try it. Perhaps you should elaborate on what you're doing, and hopefully someone else has pertinent experience and advice.
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Re: Bullet skeletal animation

Post by paokakis »

Thanks for the quick answer. I'm using the C++ library indeed :) . To elaborate a bit, I am developing a game and I am using a 3D object with bones with animation information in an .fbx file. I am using OpenGL for graphics and as many sources exist on OpenGL skeletal animation this is happening in the GPU not the CPU. The problem is that after I apply the animation, the vertices of the mesh have changed positions and I would like to keep also bullet in sync with the changes. So one question is what kind of shape should I use for the individual meshes (Box, Capsule, Convex Hull)? And the second and most important question is how to keep in sync the rigid bodies positions and orientations with the current animation phase? Maybe you could share your vague ideas, they are better than nothing.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Bullet skeletal animation

Post by drleviathan »

If you're animating a set of rigid shapes and want things to collide against them but don't need any collision feedback guiding the animation then that would be kinematic motion and you could do it the normal way: use custom MotionStates to communicate the body transforms to Bullet. That is, you would represent your "mesh" with a convex decomposition and use a RigidBody per part: each part gets a transform update through its MotionState. Note: for more correct collisions your MotionState must measure the effective velocity of the relevant RigidBody and set accordingly.

Alternatively you could use one RigidBody and put all the sub-shapes into a btCompoundShape and then update the sub-shape local transforms. This strategy has limitations since you can't assign a velocity to a sub-part and you will necessarily get slightly incorrect collision info (e.g. not quite right velocity) when dynamic objects hit them -- this might be ok for slowly animating shape but not for fast motion. Also you'd have to either (a) constantly rebuild the AABB of the compound shape, or (b) manually assign it a larger-than-necessary AABB that it will never exceed.

If you're animating a single mesh kinematically then... things get tricky. It is possible to use a btBvhTriangleMeshShape and give it a custom btStridingMeshInterface which points to mesh data that is managed/modified outside of Bullet. From there it would be possible to "animate" the triangular mesh between simulation steps however... you probably wouldn't want to use the Bvh tree feature of that shape since it would be changing all the time and recomputing it is not a good fit for a real-time simulation. Also, you'd end up similar problems as when animating btCompoundShape sub-shapes: bad velocity and rebuild AABB.

It is possible to "animate" a btHeightfieldTerrainShape, however it is a heightfield and so its values must be functional in its plane and you still have similar problems with "not quite right velocity" and making sure the AABB is correct.

If you want your GPU animation to guide dynamic rigid bodies and you want either (a) some collision feedback to the animation or just (b) non-infinite mass response when other dynamic objects hit the moving parts... then there are ways to do that but explaining it is a bit more work than I want to write up right now.
paokakis
Posts: 29
Joined: Mon Jan 04, 2021 10:31 am

Re: Bullet skeletal animation

Post by paokakis »

Thank you for the extended answer. Did not have the time to test this yet. By the way did you think to make some Bullet tutorials on Youtube? You are one of the most active members here
Post Reply