Hi NewbTon,
Both hinge and ball.
Bullet Physics has recently made improvements to the ConeTwist joint.
(http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=18&t=3177)
Had these improvements been available in JBullet, I’d preferred to use
the new ConeTwist constraint, instead of my current approach,
with 2 constraints per biped parent-child limb joint.
My current approach:
Each joint has 2 constraints: (1) A passive ConeTwist or HingeJoint
constraints that restricts movement, and (2) a Generic6DoFConstraint,
that applies muscle actuation. To apply muscle actuation, I rotate the
frame of the 2nd body attached to the Generic6DofConstraint. I
don’t use the setAngular{Lower/Upper}Limit functions.
(I had to add a function that allows modifying this second frame
after the creation of the Generic6DofConstraint.)
(I think the reason I used 2 constraints was:
- Easier to define max-rotation-limits using ConeTwistConstraint
(than with Generic6DofConstraint).
- (JBullet’s current version of) ConeTwistConstraint doesn’t allow defining both
max-rotation-limits and a different desired rotation. So
I used a second constraint, the Generic6DofConstraint, for this.
(I.e. for muscle actuation.))
// Below, childPart might be an upper arm,
// and parentPart would then be the torso.
// Or the child part could be the left shin leg;
// the parent part would then be the left thigh.)
// The constraint that just limits movement.
if (constraintType == HINGE_CONSTRAINT_TYPE) {
childPart.joint = new HingeConstraint(
parentPart.physics(), childPart.physics(),
new Transform(parentFrame), new Transform(childFrame));
}
else if (constraintType == CONETWIST_CONSTRAINT_TYPE) {
childPart.joint = new ConeTwistConstraint(
parentPart.physics(), childPart.physics(),
new Transform(parentFrame), new Transform(childFrame));
}
...
// The muscle actuation constraint.
childPart.motor = new Generic6DofConstraint(
parentPart.physics(), childPart.physics(),
new Transform(parentFrame), new Transform(childFrame), true);
// To apply muscle actuation, the motor child frame is rotated
// (relative the parent frame); the motor limits remain 0, always.
childPart.motor.setLimit(3 + 0, 0, 0);
childPart.motor.setLimit(3 + 1, 0, 0);
childPart.motor.setLimit(3 + 2, 0, 0);
// And in some function, to rotate the child body part
// relative the parent body part:
childPart.motor.setFrameBaseB(newRotation);
// Function is not present in JBullet, but see below:
public class Generic6DofConstraint extends TypedConstraint {
...
public void setFrameBaseB(Quat4f basis) {
frameInB.basis.set(basis);
}
...
}
And then there are functions that set the childPart.joint limits.
I’ve seen that game before
(You’re the author, I gather?) I like
that approach, mainly physics and gameplay, rather than graphics.
My bipeds only walk forwards, slowly. No quick movements, as of now.
So I do not know if it’s possible. But I guess it is, and that it
would work as well as with PhysX.