Hello!
I would like to know how i would have to integrate an animated mesh with Bullet Physics in a way that i can control it easily.
In the bullet examples the bullet kinematic character controller is just one convex object. But if i have an animated model (Human with Bones) i thought i would have to use the rotations/translations of the bones in the mesh-animation-frame and set the physics-ragdoll bones to this rotations/translations. But the convex object from the kinematic controller already interacts with the other physics object in the scene, so it makes no sense to me, but this may be because i don't have much knowledge of bullet right now.
I would like to get a tip on how something like this would be implemented. Or is it possible to connect the character controller with an animatd mesh? I am just at the beginning and need a hint in which direction i have to explore.
How can i control the movements of the animated human-model and let him physically interact with the scene?
Is the idea taking the animation from the mesh and setting the ragdoll to this animation the right way? But then still how do i integrate the character controller?
Any help is highly appreciated!
Animated Mesh and Character Controller
-
- Posts: 28
- Joined: Sun Jul 31, 2011 11:20 pm
Re: Animated Mesh and Character Controller
I may be recommending only one way here and I'm sure there are many. From my perspective so far, the purpose of the Kinematic Character Controller is that you are controlling the forces through the setWalkDirection. From that perspective, you know when it's walking, running, and jumping because you are telling bullet that this is happening (e.g., from keyboard input in the example of a first person or third person player character). You could set your animations to match what you are telling bullet to do.
Collision is reported back through a callback to let you know which other objects you are colliding with so you can trigger appropriate animations in the context of that collision.
As an example of one way, I use an FPS camera and calculate it's rotation and position to derive the setWalkDirection (if I look to the right moving forward, that is fed to setWalkDirection). The fact that I'm telling it to walk that way, let's me enable the walking animation. Bullet provides me back the transformation in the update following the stepSimulation and I update the camera position as a result (could be the character, and indeed, I have a character and a weapon which I update at that point with appropriate position and rotation). Between those two points, there are ample chances to fire off appropriate animations. In the call back, I determine if that character has collided with other objects, if so, I can make a decision whether to fire off further animations. For example, if the collision shows that it was a bullet, I'd fire off a fall back or perhaps a dying animation.
Forgive me if I missed the intent of your question. I'm new to bullet and I think on simplistic terms.
Collision is reported back through a callback to let you know which other objects you are colliding with so you can trigger appropriate animations in the context of that collision.
As an example of one way, I use an FPS camera and calculate it's rotation and position to derive the setWalkDirection (if I look to the right moving forward, that is fed to setWalkDirection). The fact that I'm telling it to walk that way, let's me enable the walking animation. Bullet provides me back the transformation in the update following the stepSimulation and I update the camera position as a result (could be the character, and indeed, I have a character and a weapon which I update at that point with appropriate position and rotation). Between those two points, there are ample chances to fire off appropriate animations. In the call back, I determine if that character has collided with other objects, if so, I can make a decision whether to fire off further animations. For example, if the collision shows that it was a bullet, I'd fire off a fall back or perhaps a dying animation.
Forgive me if I missed the intent of your question. I'm new to bullet and I think on simplistic terms.
-
- Posts: 2
- Joined: Sat Aug 27, 2011 3:48 pm
Re: Animated Mesh and Character Controller
Hi eagletree!
Thanks a lot for your answer! You understood my question very well. But i think, you are only combining the animated-mesh-graphics-model with the character controller. My main problem is, that if i am moving the character, and for example in the "Go" Animation of the 3D-Model the foot hits a box. I want the foot to physically interact with the box. If "only" the character controller interacts with the box, there will be a difference in the graphics and physics representation, as in graphics the foot already hit the box, while in physics the box only reacts to the simple body of the character controller. So i need to make the ragdoll-physics-model move like the animated-mesh-graphics model. But the point where i am stuck is: How do i integrate the character controller? How do i let a model physically correct walk up the stairs?
As you said, i also think there are multiple solutions to this "problem". So i would love to hear some more advises (from a pro?).
Thanks a lot for your answer! You understood my question very well. But i think, you are only combining the animated-mesh-graphics-model with the character controller. My main problem is, that if i am moving the character, and for example in the "Go" Animation of the 3D-Model the foot hits a box. I want the foot to physically interact with the box. If "only" the character controller interacts with the box, there will be a difference in the graphics and physics representation, as in graphics the foot already hit the box, while in physics the box only reacts to the simple body of the character controller. So i need to make the ragdoll-physics-model move like the animated-mesh-graphics model. But the point where i am stuck is: How do i integrate the character controller? How do i let a model physically correct walk up the stairs?
As you said, i also think there are multiple solutions to this "problem". So i would love to hear some more advises (from a pro?).
-
- Posts: 52
- Joined: Wed Sep 28, 2011 8:36 am
- Location: France
Re: Animated Mesh and Character Controller
Hi,
Did you try to set a shape and a body to each bone for your character's skeleton, configure them all in kinematic mode, and set the motion state of the body at each update loop ?
It allow the character to have an effect in the physic world (but not the opposite)
Did you try to set a shape and a body to each bone for your character's skeleton, configure them all in kinematic mode, and set the motion state of the body at each update loop ?
Code: Select all
btTransform transform;
transform.setOrigin(convert(touchEntity().getPosition()));
transform.setRotation(convert(touchEntity().getEntityRole()->touchTransformation().getQuaternion()));
_motionState->setWorldTransform(transform);
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: Animated Mesh and Character Controller
I think you can point this post to the BVH discussion we had just a moment ago. This is much similar topic. Personally, kinematics control (I mean, directly controlling over the rotations and translations of each body part) is definitely easy, than design a dynamic controller.Yann wrote:Hi,
Did you try to set a shape and a body to each bone for your character's skeleton, configure them all in kinematic mode, and set the motion state of the body at each update loop ?It allow the character to have an effect in the physic world (but not the opposite)Code: Select all
btTransform transform; transform.setOrigin(convert(touchEntity().getPosition())); transform.setRotation(convert(touchEntity().getEntityRole()->touchTransformation().getQuaternion())); _motionState->setWorldTransform(transform);