how to make this character

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

Re: how to make this character

Post by JimmSlimm »

ok long time since I started this thread, but now that 0.12 is out, what motors should I use for the neck, shoulders, elbows, start of legs(from the lower body), and knees?

I have played around some with these:
AngularMotor
LinearAxisMotor
RevoluteMotor
TwistMotor

but I am not sure about how to use them correctly, is it one of these motors I should use? (for "realistic" limbs movement)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

There's a ragdoll demo coming out soon (once I get v0.12.1 done) which shows one way of setting it up in detail. The Unfortunate One-Armed Guy demo in the BEPUphysicsDemos project shows a starting point (a ragdoll with one arm).

Basically, you start with ball-socket joints to restrict linear motion, and add in further angular restrictions. For an elbow, you could use a HingeJoint, or a SwivelHingeJoint with a TwistLimit, or a variety of other combinations depending on how you want it to look.

To make a character realistically 'stand up' on it's own, there's a whole other batch of difficulties. Usually when you see this sort of thing, it's faked. One way to fake it is to push and pull the ragdoll entities around based on an animation to blend between 'full animation mode' and 'ragdoll mode.' This is probably one of the easiest ways to get convincing 'physical' motion. If your character gets smashed, it can go ragdoll, then blend some animations to get back up again.

You can scale the 'realism' of this approach down to pushing around only certain parts of the character (like torso, hands, and feet) as well.

Some of the more realistic alternatives are exceptionally hard. Figuring out lifelike bipedal balance is still the domain of research and high end focused middleware. Obviously some approximations or less realistic approaches are much more feasible, but they would likely behave less convincingly than animation blending.

If you'd like to try a constraint-motor approach, they are relatively simple. There are some demos in the BEPUphysics demos project (saw contraption, robotic arm) that show different kinds of motors in action.

I also plan on making some in-depth documentation covering the new constraint types once I have some time after v0.12.1.
JimmSlimm
Posts: 5
Joined: Tue Dec 15, 2009 6:58 pm

Re: how to make this character

Post by JimmSlimm »

thanks for the good reply :)

I was actually thinking of making them stand up(and later walk and run) using motors(like, using AI to activate different muscles/motors when needed to keep the balance)

this should work right? if I understand the meaning of motors this should be do-able(english isnt my main language)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

Yes, the motors could be used in that way. The main difficulty is the AI/control needed to tell the motors what to do in that situation. If you're ready for that and that's where you want to go, it's guaranteed to be a very interesting project :D
JimmSlimm
Posts: 5
Joined: Tue Dec 15, 2009 6:58 pm

Re: how to make this character

Post by JimmSlimm »

hi, I'm having some trouble with the character

All motors work fine except the one between hips and torso for some reason :\
here is what the ragdoll looks like: http://img97.imageshack.us/img97/3982/myrag.jpg

the best motor for me seems to be LinearAxisMotor , I force the legs to go DOWN with these motors and it works(idea is that it should stand up)
but without a "spine" he will just end up in this position:
http://img684.imageshack.us/img684/3188/myrag2.jpg <--- legs are forced down but no spine

when trying to add a LinearAxisMotor between the torso and hips and set the axis to DOWN it starts acting strange and it looks like the character freaks out :\
code for spine:
gSpine = new LinearAxisMotor(gBody, gHips, gBody.centerPosition, gHips.centerPosition, Vector3.Down);
gSpine.settings.mode = MotorMode.velocityMotor;
pSpace.add(gSpine);
in each update I do this to make is stay the same:
gSpine.axis = Vector3.Down; <---- also tried Vector3.Up
gSpine.settings.velocityMotor.goalVelocity = 1f;

anyone know why it acts strange just between these 2 body-parts? the other motors works, I don't know what I'm doing wrong :(
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: how to make this character

Post by Norbo »

The LinearAxisMotor acts on a linear degree of freedom. Since your ragdoll is presumably connected by BallSocketJoints also which restrict all linear degrees of freedom, it's possible for your LinearAxisMotor to push the bones towards a configuration that the BallSocketJoints disallow. Once it reaches that point, you can start seeing instability if your motor is strong enough (which by default, it is).

By the way, the motor's goal velocity will not change by itself so you don't need to set it each frame.

You could increase the motor's softness or give it a maximum force so that it doesn't try to apply massive impulses to achieve its goal. You may find that using such linear motors produce some strange behavior (since they are not exactly how the 'real' body works :)), though; AngularMotors and the other angular degree of freedom motors may produce more pleasing results. For example, a set of AngularMotors in servo mode could be used to match any desired pose by targeting the relative rotations at each joint. The entire body could be separately hoisted in a very controlled manner at certain central entities to keep it upright and oriented properly.
Post Reply