how to make this character

Discuss any questions about BEPUphysics or problems encountered.
JimmSlimm
Posts: 5
Joined: Tue Dec 15, 2009 6:58 pm

how to make this character

Post by JimmSlimm »

I would like to create a "ragdoll" with these parts:
head
torso
upper right and left arm
lower right and left arm
upper right and left leg
lower right and left leg

but here's the hard part: I want it to be able to stand up like a real human

I was thinking of using capsules for the body part, but what joints should I use?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

Capsules will work for the body parts.

The joints to use depend on what kind of behavior you want. You could connect it together with a bunch of BallSocketJoints, though without further help the character will quickly collapse.

You could apply springy impulses on parts of the body that keep the pieces at the 'desired' position, and it will probably look acceptable.

If you're looking to do a realistic simulation of joints with friction, motors, and that sort of thing, you will need the features coming in v0.11.0. In v0.11.0, the constraint system is getting an overhaul and is quite a bit more powerful.
JimmSlimm
Posts: 5
Joined: Tue Dec 15, 2009 6:58 pm

Re: how to make this character

Post by JimmSlimm »

Norbo wrote:Capsules will work for the body parts.

The joints to use depend on what kind of behavior you want. You could connect it together with a bunch of BallSocketJoints, though without further help the character will quickly collapse.

You could apply springy impulses on parts of the body that keep the pieces at the 'desired' position, and it will probably look acceptable.

If you're looking to do a realistic simulation of joints with friction, motors, and that sort of thing, you will need the features coming in v0.11.0. In v0.11.0, the constraint system is getting an overhaul and is quite a bit more powerful.
ok thanks :) any ETA om 0.11 ?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

I've tried and failed to guess when it's coming out in the past multiple times, so I'll just say "as soon as possible." I think I can safely say that it's not going to be more than a month or two... I hope!
saturn1
Posts: 34
Joined: Thu Dec 24, 2009 11:14 pm

Re: how to make this character

Post by saturn1 »

I have the same problem,
i can't do my character stand up when it collide my map!

My character is described like that

Code: Select all

            List<Entity> oddShape = new List<Entity>();
            Box bottom = new Box(new Vector3(0, 0, 0), 0.3f, 1.2f, 1.2f, 1);
            Cylinder middle = new Cylinder(new Vector3(0, 0.2f, 0), 0, 0.1f, 1);
            Sphere top = new Sphere(new Vector3(0, 0.4f, 0), 0.2f, 1);
            oddShape.Add(bottom);
            oddShape.Add(middle);
            oddShape.Add(top);
            WrappedBody body = new WrappedBody(new Vector3(0, 1, -3), oddShape, 100);
            space.add(body);
            Matrix scaling = Matrix.CreateScale(0.5f);
            entModelHero = new EntityModel(body, heroModel, scaling, this);
            Components.Add(entModelHero);
But i don't know how to connect it with bunch of BallSocketJoints

Thank you for help .
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

If you just want to make your character stay upright, you can give it an infinite inertia tensor (or just around certain axes). This is accomplished by setting rows of the localSpaceInertiaTensorInverse to 0. Setting row 1 to zero makes it as if the inertia around the X axis is infinite, row 2 corresponds to Y, and row 3 corresponds to Z.

An example of this can be found in the demos character controller and vehicle. The character's inertia tensor is infinite, while the vehicle has a slightly modified inertia.

Character:

Code: Select all

body.localSpaceInertiaTensorInverse = Toolbox.zeroMatrix;
Vehicle:

Code: Select all

            //Increase the inertia parallel to the car to prevent rolling a little.
            Matrix inertiaTensorInverse = vehicle.body.localSpaceInertiaTensorInverse;
            inertiaTensorInverse.M31 *= .5f;
            inertiaTensorInverse.M32 *= .5f;
            inertiaTensorInverse.M33 *= .5f;
            vehicle.body.localSpaceInertiaTensorInverse = inertiaTensorInverse;
Constraints and the BallSocketJoint like this thread was talking about is targeted at getting physically simulated ragdoll characters working, where each section of a character's limb is a different object and it flops around like a... rag doll :)
saturn1
Posts: 34
Joined: Thu Dec 24, 2009 11:14 pm

Re: how to make this character

Post by saturn1 »

Thank you :)
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: how to make this character

Post by vintagegames »

Along these lines, lets say that I'm interested in fixing a character/model/entity to a specific xyz location, but they can have angularVelocity around a fixed point. (Think foosball or bubble hockey)

I've used the localSpaceInertiaTensorInverse which keeps my model upright, but if it is spinning and whacks another fixed item in my scene, then this model will react and fly all around my scene (remaining upright however). I'd like to be able to fix my model to a specific pivot point (which I will also want to move around using controller input).
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

You could do it by manually setting velocities, though this will be somewhat non-rigid when done outside of the solver. To deal with that non-rigidity, you could use a constraint (a connection which is a part of the solver).

If your entity can only rotate around the Y axis, one possibility is to vertically connect a simple BallSocketJoint between it and some attached kinematic entity. Since the piece can only rotate around the Y axis, the connected kinematic entity will keep it in place. If you need to move the piece around, you can change the connected kinematic entity's linear velocity and the piece will follow.

A more direct solution would be to make a special motor-like constraint that only operates on a single entity. Constraints that only operate on linear velocity are pretty simple; if I have time later today I'll see if I can whip one up as an example.
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: how to make this character

Post by vintagegames »

A more direct solution would be to make a special motor-like constraint that only operates on a single entity. Constraints that only operate on linear velocity are pretty simple; if I have time later today I'll see if I can whip one up as an example.
This would be really helpful.

I tried using 2 BallSocketJoints, but they just weren't rigid enough to pull my CompoundBody model around (which has a large mass of 90,000f units). The red line connecting my Cylinder Entity (the piece I manipulate around to move the attached CompoundBody) is the BallSocketJoint. As I manipulate the Cylinder Entity (with infinite mass), it moves properly, but the red line connecting the CompoundBody will stretch and SLOWLY pull the CompoundBody around.
Attachments
BallSocketJoint.jpg
BallSocketJoint.jpg (67.3 KiB) Viewed 8816 times
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

I'm working on the sample motor (tracking down a possible bug in v0.10.4 as well).

Are you moving the kinematic entity with velocities, or are you using move/moveTo? The constraints work on a velocity level; if the entity has no velocity, it will only use position correction which may appear significantly 'gooey-er.' This is part of the reason why having a specialized motor to do it is nicer.

By the way, using more normal mass numbers can help maintain numerical precision during simulation (as if they were kilograms in your game perhaps). You probably won't see issues with a mass of 90,000 since it's less sensitive than the general-case collision detection system, but it's a minor point to keep in mind.
vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: how to make this character

Post by vintagegames »

I tried using both linearVelocity and centerPosition properties of my Cylinder Entity.

It was better using linearVelocity, but still has quirks.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

Here's the sample SingleBodyLinearMotor. I haven't thoroughly tested it, but it should do what it needs to.

There's a bug in v0.10.4 that will cause a crash if you try to use it when multithreading is enabled, though. I'm going to be uploading v0.10.5 in a few minutes to address this.
Attachments
SingleBodyLinearMotor.zip
(2.58 KiB) Downloaded 245 times
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

vintagegames
Posts: 19
Joined: Wed Dec 16, 2009 4:36 pm

Re: how to make this character

Post by vintagegames »

Thanks for this, (and v.0.10.5) I'll try it out later tonight!
Post Reply