Page 2 of 2

Re: Skinned Ragdoll Content Processor

Posted: Sun Jun 05, 2011 11:05 pm
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 14392 times
Edit: 'correct' anchor location is approximate. Could be a little off due to the sizes and such.

Re: Skinned Ragdoll Content Processor

Posted: Sun Jun 05, 2011 11:11 pm
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.

Re: Skinned Ragdoll Content Processor

Posted: Sun Jun 05, 2011 11:38 pm
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?

Re: Skinned Ragdoll Content Processor

Posted: Sun Jun 05, 2011 11:53 pm
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 14389 times
It seems like the only way to do so is by using the WorldTransform = Matrix.CreateRotationZ(MathHelper.PiOver2);

Re: Skinned Ragdoll Content Processor

Posted: Sun Jun 05, 2011 11:57 pm
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.

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:04 am
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.

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:20 am
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?

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:24 am
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.

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:33 am
by r2d2Proton
That effect file fixed it. I'll perform a few more tests. . .

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:40 am
by r2d2Proton
A lot better now :D
BEPU.jpg
BEPU.jpg (7.11 KiB) Viewed 14387 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.

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:43 am
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 :)

Re: Skinned Ragdoll Content Processor

Posted: Mon Jun 06, 2011 12:46 am
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 ;)

Re: Skinned Ragdoll Content Processor

Posted: Fri Jun 17, 2011 4:33 am
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