Skinned Ragdoll Content Processor

Discuss any questions about BEPUphysics or problems encountered.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

I don't know what it looks like in Maya, but here's what I'm seeing in the demo:
ragdollanchor.jpg
ragdollanchor.jpg (18.1 KiB) Viewed 14377 times
Edit: 'correct' anchor location is approximate. Could be a little off due to the sizes and such.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

By the way, there's a constructor of Capsule that takes a start and end position for the internal segment. It may be convenient.

There's an equivalent Capsule.GetCapsuleInformation static method too.
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

What I think I should be doing, but not entirely clear with though, is positioning the Capsules "position" to the mid-point of the two bones. Is this correct?

If so, then I would suspect something similar to the following:

delta = Vector3.Zero;
delta.X += sk.length / 2.0f;
sk.bone = new Capsule(sk.position + delta, sk.length - 1, sk.radius, mass);

Once I do this the capsules position is at the correct location:

sk.bone.Position {X:2 Y:0 Z:0} Microsoft.Xna.Framework.Vector3

But I need the capsule to be aligned along the X-axis, so I am providing a world transform as mentioned before:

sk.bone.WorldTransform = modelWorld;

Once that transform is set the bone position is changed though:

sk.bone.Position {X:0 Y:0 Z:0} Microsoft.Xna.Framework.Vector3

My thought process is that the joint has to reside safely between the two capsules (upperArm and lowerArm). So the upperArm capsule should extend from (0.5, 0, 0) to (3.5, 0, 0); and the lowerArm capsule should extend from (4, 0.5, 0) to (4, 2.5, 0). That would place the joint at (4, 0, 0).

Yes, No?
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

Should this be aligned along the X-axis then:

sk.bone = new Capsule( new Vector3(0.0f, 0.0f, 0.0f), new Vector3(4.0f, 0.0f, 0.0f), sk.radius, mass);
BEPU.jpg
BEPU.jpg (6.08 KiB) Viewed 14374 times
It seems like the only way to do so is by using the WorldTransform = Matrix.CreateRotationZ(MathHelper.PiOver2);
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

Should this be aligned along the X-axis then:

sk.bone = new Capsule( new Vector3(0.0f, 0.0f, 0.0f), new Vector3(4.0f, 0.0f, 0.0f), sk.radius, mass);
Yes, but there's a bug I just fixed a couple of seconds ago- you can grab the new development version here: http://bepuphysics.codeplex.com/SourceC ... evelopment

If it still doesn't seem to be properly oriented, make sure something else isn't transforming it.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

What I think I should be doing, but not entirely clear with though, is positioning the Capsules "position" to the mid-point of the two bones. Is this correct?
Yes, the position of an entity is at the center of mass of that entity.

The rest of the transforms can be simplified by the (fixed) segment-capsule construction method.
My thought process is that the joint has to reside safely between the two capsules (upperArm and lowerArm). So the upperArm capsule should extend from (0.5, 0, 0) to (3.5, 0, 0); and the lowerArm capsule should extend from (4, 0.5, 0) to (4, 2.5, 0). That would place the joint at (4, 0, 0).

Yes, No?
Basically yes. Though you don't need to worry if the constraint anchor lies within geometry; it's not something that can physically collide. It may look best if the entities do intersect a bit (and have a NoBroadPhase collision rule) so that there's not any gaps. This would mean you could extend the capsule from (0 to 4, 0, 0) and (0, 0 to 3, 0) if you wanted to.

Note that the capsule convenience constructor configures the *internal* segment though, which is then expanded by the radius.
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

Thank you for your help Norbo.

Now I'm getting a runtime error in the ModelDisplayObjectBatch::Draw method. I rebuilt the solution for the physics DLL's and copied them to the modified Ragdoll example. Am I missing something?

It's erroring out on the worldTransformsParameter.SetValue(worldTransforms) line. Maybe I have the wrong shader?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

Possibly- the InstancedEffect.fx was changed in the latest version; you can copy it over from the other source content into the RagdollDemo content.
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

That effect file fixed it. I'll perform a few more tests. . .
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

A lot better now :D
BEPU.jpg
BEPU.jpg (7.11 KiB) Viewed 14372 times
So, I should be able to go through all my joints, create the capsules in the same manner as described above, and place the joints right at the intersection points. Correct?

I will switch to different joints, and loosen up the constraints once I get a full body correctly placed in the scene.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Skinned Ragdoll Content Processor

Post by Norbo »

So, I should be able to go through all my joints, create the capsules in the same manner as described above, and place the joints right at the intersection points. Correct?
Hopefully, yes :)
r2d2Proton
Posts: 20
Joined: Fri Sep 03, 2010 5:02 pm
Contact:

Re: Skinned Ragdoll Content Processor

Post by r2d2Proton »

With any luck I'll post an image later. . . Again, thank you so much for all your help. I hope we can get something up on Creators Club over the summer to demo both our work ;)
Kataan
Posts: 10
Joined: Tue Mar 22, 2011 10:57 am

Re: Skinned Ragdoll Content Processor

Post by Kataan »

Hey r2d2Proton,

How did that turn out? Did you end up with the results you were chasing?

Any pretty pics to share?

-Kataan
Post Reply