Problem to put physics in the arm bones

mbvital

07-05-2012 10:16:02

Hi,
(I post this toppic also in Add-ons Forum - Mogre, but i'm not sure if is the right place)

I’m working with motion sensors, and I have a mesh with skeleton in my application.
I want to reflect my arm movements in a Virtual Human.
So I apply the orientation of the sensors to the bones of the arms.

However, I want to put physics in my mesh (ok, only on the arms at the moment).
At the beginning I applied physics to the mesh like this (code in C# for Mogre and MogreNewt):

Entity entHV = mSceneMgr.CreateEntity("Ent", "Victoria 4.2 QuickStart.mesh");
ConvexHull entity = new ConvexHull(world, entHV, 1, 1);
Body bodyEnt = new Body(world, entity, true);
bodyEnt.SetPositionOrientation(entHV.Position, entHV.Orientation);


But then I realized that wouldn't work very well since this would apply to the complete mesh and I would like to have something more close to each arm segment.
So I tried to create a Cylinder collision object and apply it to each segment, roughly like this:

Bone upArm = skeleton.GetBone("rShldr");
upArm.SetManuallyControlled(true);

colUpArm = new Cylinder(world, 7, 25, 10);
bd = new Body(world, colUpArm, true);
colUpArm.Dispose();
bd.SetPositionOrientation(upArm.Position, upArm.Orientation);


I thought that this could work but however, I see my physics object at the world origin instead of the correct location within the character's mesh. If I move the character's mesh to another location, the skeleton keeps in the same place, it doesn't move with the mesh.

My question is: does anyone has an idea on how i can apply physics to the bones of the arms?
Or does anyone has an alternative idea on how should I do this?

Thank you!

tod

08-05-2012 08:10:44

I think you should move the physics object, not the mesh. Maybe you could create some physics "body" and attach the arms with joints.

mbvital

08-05-2012 13:00:07

Yes, I agree with that! I make some experiences and I know how to move the physics object and with joints too. But the problem is:

--> When I put the physics body in the bone, it appears in the local position of the skeleton.

I move my mesh to another place but the skeleton stays in the original position and it does not follow the mesh. So the physics body stays far from the mesh.
Any idea of why this is happening?

Thank you for the answer

tod

09-05-2012 08:49:13

I don't really understand what the problem is. So you attach a bone to a physics body and then move the mesh but the body and skeleton stays behind?
Maybe you should separate the position of the entity from the bone movement of the hand, meaning move the mesh however you like but make sure you update physics body and , if needed, bone position when doing so.

mbvital

12-05-2012 18:07:56

Yes, is that what you said.

I'm gonna try to do what you said...After doing that i give you news.

Thank you

mbvital

24-05-2012 11:49:47

Hi...

I can´t attach a bone to a physics body because the bone is not a scenenode.
So I put the physics body in the position of the bone and when I move the bone I update the physics body’s position to the new bone´s position. But when I move the bone against a wall, the bone passes the wall although the physics body is there. It happens because I do not move the physics body and I move the bone. Do you have any suggestions?

Thank you