skinned mesh and capsule collider not alligned

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cosmo
Posts: 17
Joined: Sat May 06, 2017 1:29 pm

skinned mesh and capsule collider not alligned

Post by cosmo »

Hi,
I'm trying to implement a little game/physics framework using Irrlicht as Render system and Bullet for Physics simulations.
At present, I'm experimenting with a basic Controller, which main porpuse is takes care of moving the character rigidbody along the scene and registering Physics interactions with the ground, other objects, building and so on.
The problem is that the skinned, animated mesh (imported via Blender in .b3d format) apperars to be not perfectly enclosed into the Capsule Collider, so that there is a gap between the feet of the mesh and the ground.
I think the issue is caused by the Skeleton Rig (from Mixamo), which has the RootMotion positioned between the feet of the character and not to the hip bone. So the center of mass position is not in the right place, relative to my code.
Infact, if I modify the code for Rendering the Player from:

btVector3 Point = iter->second->getCenterOfMassPosition();
iter->first->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));

To:

btVector3 Point = iter->second->getCenterOfMassPosition();
iter->first->setPosition(vector3df((f32)Point[0], (f32)Point[1]-2, (f32)Point[2]));

my character is enclosed into the Capsule Collider ad is alligned with the ground correctly.

Is my assumption right?
Is there a better and less arbitrary way to solve this kind of issue?



Cosmo
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Re: skinned mesh and capsule collider not alligned

Post by devsh »

Yes there is, you should pre-compute a transform (matrix) that puts the mesh's center of mass at origin (0,0,0) ... you can easily do that by importing the mesh into blender, moving the thing by hand to have the origin passing through the belly or whatever bullet thinks is the center of mass and seeing what 3d transform is.

Save that matrix and apply it to the transform (orientation+translation) that Bullet is reporting for your object before you set it on the irrlicht node.

The other and better way would be to export your skinned animated mesh so that the root bone is always where the center of mass is for every animation frame.
It makes it really convienient when you want to play flailing animations while a character is "falling", etc.

P.S. I've just released a new version of my Irrlicht fork yesterday, that has CEGUI and Bullet integration examples in the repo http://irrlicht.sourceforge.net/forum/v ... 40#p304772
cosmo
Posts: 17
Joined: Sat May 06, 2017 1:29 pm

Re: skinned mesh and capsule collider not alligned

Post by cosmo »

Thanks devsh.
What I meant is what you advice to me as "other and better way...". But I think this is possible using a software like MotionBuilder, that let's you set up a Control Rig from the ground up and then apply Motion Capture data (animations) to it.
I'm very interested in your Irrlicht fork, I will take a sneak peek as soon as possible.
Bye :D
Post Reply