Search in sources :

Example 71 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformVerts.

private static void doTransformVerts(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f pos = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        pos.x = inBuf.get(i * 3 + 0);
        pos.y = inBuf.get(i * 3 + 1);
        pos.z = inBuf.get(i * 3 + 2);
        transform.mult(pos, pos);
        outBuf.put(offset + i * 3 + 0, pos.x);
        outBuf.put(offset + i * 3 + 1, pos.y);
        outBuf.put(offset + i * 3 + 2, pos.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 72 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformTangents.

private static void doTransformTangents(FloatBuffer inBuf, int offset, int components, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f tan = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= components;
    for (int i = 0; i < inBuf.limit() / components; i++) {
        tan.x = inBuf.get(i * components + 0);
        tan.y = inBuf.get(i * components + 1);
        tan.z = inBuf.get(i * components + 2);
        transform.multNormal(tan, tan);
        outBuf.put(offset + i * components + 0, tan.x);
        outBuf.put(offset + i * components + 1, tan.y);
        outBuf.put(offset + i * components + 2, tan.z);
        if (components == 4) {
            outBuf.put(offset + i * components + 3, inBuf.get(i * components + 3));
        }
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 73 with Transform

use of com.jme3.math.Transform in project jmonkeyengine by jMonkeyEngine.

the class GeometryBatchFactory method doTransformNorms.

private static void doTransformNorms(FloatBuffer inBuf, int offset, FloatBuffer outBuf, Matrix4f transform) {
    Vector3f norm = new Vector3f();
    // offset is given in element units
    // convert to be in component units
    offset *= 3;
    for (int i = 0; i < inBuf.limit() / 3; i++) {
        norm.x = inBuf.get(i * 3 + 0);
        norm.y = inBuf.get(i * 3 + 1);
        norm.z = inBuf.get(i * 3 + 2);
        transform.multNormal(norm, norm);
        outBuf.put(offset + i * 3 + 0, norm.x);
        outBuf.put(offset + i * 3 + 1, norm.y);
        outBuf.put(offset + i * 3 + 2, norm.z);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 74 with Transform

use of com.jme3.math.Transform 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)

Example 75 with Transform

use of com.jme3.math.Transform in project chordatlas by twak.

the class RotHandle method updateScale.

private void updateScale() {
    float scale = handleScale();
    Vector3f offset = new Vector3f(dir);
    BoundingBox bv = (BoundingBox) target.getWorldBound();
    g1.setLocalTransform(new Transform(bv.getCenter().add(offset.mult(bv.getExtent(null))).add(offset.mult(2))));
    g1.setLocalScale(scale * 1);
    Quaternion rot = new Quaternion(new float[] { FastMath.PI / 2, 0, 0 });
    g1.setLocalRotation(rot);
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) BoundingBox(com.jme3.bounding.BoundingBox) Transform(com.jme3.math.Transform)

Aggregations

Vector3f (com.jme3.math.Vector3f)34 Transform (com.jme3.math.Transform)33 TempVars (com.jme3.util.TempVars)24 Quaternion (com.jme3.math.Quaternion)13 Matrix4f (com.jme3.math.Matrix4f)11 Bone (com.jme3.animation.Bone)9 BoundingBox (com.jme3.bounding.BoundingBox)9 Spatial (com.jme3.scene.Spatial)9 Geometry (com.jme3.scene.Geometry)8 ColorRGBA (com.jme3.math.ColorRGBA)7 Material (com.jme3.material.Material)6 Node (com.jme3.scene.Node)5 PointLight (com.jme3.light.PointLight)4 Mode (com.jme3.scene.Mesh.Mode)4 BoneContext (com.jme3.scene.plugins.blender.animations.BoneContext)4 FloatBuffer (java.nio.FloatBuffer)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Matrix4d (javax.vecmath.Matrix4d)4 Transform (com.bulletphysics.linearmath.Transform)3