Search in sources :

Example 1 with RotationalLimitMotor

use of com.jme3.bullet.joints.motors.RotationalLimitMotor in project jmonkeyengine by jMonkeyEngine.

the class SixDofJoint method gatherMotors.

private void gatherMotors() {
    for (int i = 0; i < 3; i++) {
        RotationalLimitMotor rmot = new RotationalLimitMotor(((Generic6DofConstraint) constraint).getRotationalLimitMotor(i));
        rotationalMotors.add(rmot);
    }
    translationalMotor = new TranslationalLimitMotor(((Generic6DofConstraint) constraint).getTranslationalLimitMotor());
}
Also used : Generic6DofConstraint(com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint) TranslationalLimitMotor(com.jme3.bullet.joints.motors.TranslationalLimitMotor) RotationalLimitMotor(com.jme3.bullet.joints.motors.RotationalLimitMotor) Generic6DofConstraint(com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)

Example 2 with RotationalLimitMotor

use of com.jme3.bullet.joints.motors.RotationalLimitMotor in project jmonkeyengine by jMonkeyEngine.

the class SixDofJoint method write.

@Override
public void write(JmeExporter ex) throws IOException {
    super.write(ex);
    OutputCapsule capsule = ex.getCapsule(this);
    capsule.write(angularUpperLimit, "angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY));
    capsule.write(angularLowerLimit, "angularLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY));
    capsule.write(linearUpperLimit, "linearUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY));
    capsule.write(linearLowerLimit, "linearLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY));
    int i = 0;
    for (Iterator<RotationalLimitMotor> it = rotationalMotors.iterator(); it.hasNext(); ) {
        RotationalLimitMotor rotationalLimitMotor = it.next();
        capsule.write(rotationalLimitMotor.getBounce(), "rotMotor" + i + "_Bounce", 0.0f);
        capsule.write(rotationalLimitMotor.getDamping(), "rotMotor" + i + "_Damping", 1.0f);
        capsule.write(rotationalLimitMotor.getERP(), "rotMotor" + i + "_ERP", 0.5f);
        capsule.write(rotationalLimitMotor.getHiLimit(), "rotMotor" + i + "_HiLimit", Float.POSITIVE_INFINITY);
        capsule.write(rotationalLimitMotor.getLimitSoftness(), "rotMotor" + i + "_LimitSoftness", 0.5f);
        capsule.write(rotationalLimitMotor.getLoLimit(), "rotMotor" + i + "_LoLimit", Float.NEGATIVE_INFINITY);
        capsule.write(rotationalLimitMotor.getMaxLimitForce(), "rotMotor" + i + "_MaxLimitForce", 300.0f);
        capsule.write(rotationalLimitMotor.getMaxMotorForce(), "rotMotor" + i + "_MaxMotorForce", 0.1f);
        capsule.write(rotationalLimitMotor.getTargetVelocity(), "rotMotor" + i + "_TargetVelocity", 0);
        capsule.write(rotationalLimitMotor.isEnableMotor(), "rotMotor" + i + "_EnableMotor", false);
        i++;
    }
    capsule.write(getTranslationalLimitMotor().getAccumulatedImpulse(), "transMotor_AccumulatedImpulse", Vector3f.ZERO);
    capsule.write(getTranslationalLimitMotor().getDamping(), "transMotor_Damping", 1.0f);
    capsule.write(getTranslationalLimitMotor().getLimitSoftness(), "transMotor_LimitSoftness", 0.7f);
    capsule.write(getTranslationalLimitMotor().getLowerLimit(), "transMotor_LowerLimit", Vector3f.ZERO);
    capsule.write(getTranslationalLimitMotor().getRestitution(), "transMotor_Restitution", 0.5f);
    capsule.write(getTranslationalLimitMotor().getUpperLimit(), "transMotor_UpperLimit", Vector3f.ZERO);
}
Also used : OutputCapsule(com.jme3.export.OutputCapsule) Vector3f(com.jme3.math.Vector3f) RotationalLimitMotor(com.jme3.bullet.joints.motors.RotationalLimitMotor) Generic6DofConstraint(com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)

Example 3 with RotationalLimitMotor

use of com.jme3.bullet.joints.motors.RotationalLimitMotor in project jmonkeyengine by jMonkeyEngine.

the class SixDofJoint method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule capsule = im.getCapsule(this);
    Transform transA = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotA, transA.origin);
    Transform transB = new Transform(Converter.convert(new Matrix3f()));
    Converter.convert(pivotB, transB.origin);
    constraint = new Generic6DofConstraint(nodeA.getObjectId(), nodeB.getObjectId(), transA, transB, useLinearReferenceFrameA);
    gatherMotors();
    setAngularUpperLimit((Vector3f) capsule.readSavable("angularUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setAngularLowerLimit((Vector3f) capsule.readSavable("angularLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));
    setLinearUpperLimit((Vector3f) capsule.readSavable("linearUpperLimit", new Vector3f(Vector3f.POSITIVE_INFINITY)));
    setLinearLowerLimit((Vector3f) capsule.readSavable("linearLowerLimit", new Vector3f(Vector3f.NEGATIVE_INFINITY)));
    for (int i = 0; i < 3; i++) {
        RotationalLimitMotor rotationalLimitMotor = getRotationalLimitMotor(i);
        rotationalLimitMotor.setBounce(capsule.readFloat("rotMotor" + i + "_Bounce", 0.0f));
        rotationalLimitMotor.setDamping(capsule.readFloat("rotMotor" + i + "_Damping", 1.0f));
        rotationalLimitMotor.setERP(capsule.readFloat("rotMotor" + i + "_ERP", 0.5f));
        rotationalLimitMotor.setHiLimit(capsule.readFloat("rotMotor" + i + "_HiLimit", Float.POSITIVE_INFINITY));
        rotationalLimitMotor.setLimitSoftness(capsule.readFloat("rotMotor" + i + "_LimitSoftness", 0.5f));
        rotationalLimitMotor.setLoLimit(capsule.readFloat("rotMotor" + i + "_LoLimit", Float.NEGATIVE_INFINITY));
        rotationalLimitMotor.setMaxLimitForce(capsule.readFloat("rotMotor" + i + "_MaxLimitForce", 300.0f));
        rotationalLimitMotor.setMaxMotorForce(capsule.readFloat("rotMotor" + i + "_MaxMotorForce", 0.1f));
        rotationalLimitMotor.setTargetVelocity(capsule.readFloat("rotMotor" + i + "_TargetVelocity", 0));
        rotationalLimitMotor.setEnableMotor(capsule.readBoolean("rotMotor" + i + "_EnableMotor", false));
    }
    getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO));
    getTranslationalLimitMotor().setDamping(capsule.readFloat("transMotor_Damping", 1.0f));
    getTranslationalLimitMotor().setLimitSoftness(capsule.readFloat("transMotor_LimitSoftness", 0.7f));
    getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
    getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
    getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
}
Also used : Matrix3f(com.jme3.math.Matrix3f) InputCapsule(com.jme3.export.InputCapsule) Vector3f(com.jme3.math.Vector3f) Generic6DofConstraint(com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint) RotationalLimitMotor(com.jme3.bullet.joints.motors.RotationalLimitMotor) Transform(com.bulletphysics.linearmath.Transform) Generic6DofConstraint(com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)

Aggregations

Generic6DofConstraint (com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)3 RotationalLimitMotor (com.jme3.bullet.joints.motors.RotationalLimitMotor)3 Vector3f (com.jme3.math.Vector3f)2 Transform (com.bulletphysics.linearmath.Transform)1 TranslationalLimitMotor (com.jme3.bullet.joints.motors.TranslationalLimitMotor)1 InputCapsule (com.jme3.export.InputCapsule)1 OutputCapsule (com.jme3.export.OutputCapsule)1 Matrix3f (com.jme3.math.Matrix3f)1