Search in sources :

Example 6 with Matrix3f

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

the class PhysicsGhostObject method getPhysicsRotationMatrix.

/**
     * @return the physicsLocation
     */
public Matrix3f getPhysicsRotationMatrix(Matrix3f rot) {
    if (rot == null) {
        rot = new Matrix3f();
    }
    gObject.getWorldTransform(tempTrans);
    Converter.convert(tempTrans.getRotation(tempRot), physicsLocation.getRotation());
    return rot.set(physicsLocation.getRotation());
}
Also used : Matrix3f(com.jme3.math.Matrix3f)

Example 7 with Matrix3f

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

the class NewtonianParticleInfluencer method influenceParticle.

@Override
public void influenceParticle(Particle particle, EmitterShape emitterShape) {
    emitterShape.getRandomPointAndNormal(particle.position, particle.velocity);
    // influencing the particle's velocity
    if (surfaceTangentFactor == 0.0f) {
        particle.velocity.multLocal(normalVelocity);
    } else {
        // calculating surface tangent (velocity contains the 'normal' value)
        temp.set(particle.velocity.z * surfaceTangentFactor, particle.velocity.y * surfaceTangentFactor, -particle.velocity.x * surfaceTangentFactor);
        if (surfaceTangentRotation != 0.0f) {
            // rotating the tangent
            Matrix3f m = new Matrix3f();
            m.fromAngleNormalAxis(FastMath.PI * surfaceTangentRotation, particle.velocity);
            temp = m.multLocal(temp);
        }
        // applying normal factor (this must be done first)
        particle.velocity.multLocal(normalVelocity);
        // adding tangent vector
        particle.velocity.addLocal(temp);
    }
    if (velocityVariation != 0.0f) {
        this.applyVelocityVariation(particle);
    }
}
Also used : Matrix3f(com.jme3.math.Matrix3f)

Example 8 with Matrix3f

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

the class FlyByCamera method rotateCamera.

protected void rotateCamera(float value, Vector3f axis) {
    if (dragToRotate) {
        if (canRotate) {
        //                value = -value;
        } else {
            return;
        }
    }
    Matrix3f mat = new Matrix3f();
    mat.fromAngleNormalAxis(rotationSpeed * value, axis);
    Vector3f up = cam.getUp();
    Vector3f left = cam.getLeft();
    Vector3f dir = cam.getDirection();
    mat.mult(up, up);
    mat.mult(left, left);
    mat.mult(dir, dir);
    Quaternion q = new Quaternion();
    q.fromAxes(left, up, dir);
    q.normalizeLocal();
    cam.setAxes(q);
}
Also used : Matrix3f(com.jme3.math.Matrix3f) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f)

Example 9 with Matrix3f

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

the class CompoundCollisionShape method addChildShape.

/**
     * adds a child shape at the given local translation
     * @param shape the child shape to add
     * @param location the local location of the child shape
     */
public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
    if (shape instanceof CompoundCollisionShape) {
        throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
    }
    Transform transA = new Transform(Converter.convert(rotation));
    Converter.convert(location, transA.origin);
    Converter.convert(rotation, transA.basis);
    children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
Also used : ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) CompoundShape(com.bulletphysics.collision.shapes.CompoundShape) Transform(com.bulletphysics.linearmath.Transform)

Example 10 with Matrix3f

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

the class PhysicsGhostObject method read.

@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    buildObject();
    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
    setPhysicsRotation(((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f())));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
}
Also used : Matrix3f(com.jme3.math.Matrix3f) InputCapsule(com.jme3.export.InputCapsule) Vector3f(com.jme3.math.Vector3f)

Aggregations

Matrix3f (com.jme3.math.Matrix3f)21 Vector3f (com.jme3.math.Vector3f)10 TempVars (com.jme3.util.TempVars)8 ChildCollisionShape (com.jme3.bullet.collision.shapes.infos.ChildCollisionShape)5 InputCapsule (com.jme3.export.InputCapsule)5 Transform (com.bulletphysics.linearmath.Transform)3 OutputCapsule (com.jme3.export.OutputCapsule)3 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)2 BoxCollisionShape (com.jme3.bullet.collision.shapes.BoxCollisionShape)2 CollisionShape (com.jme3.bullet.collision.shapes.CollisionShape)2 CompoundCollisionShape (com.jme3.bullet.collision.shapes.CompoundCollisionShape)2 Geometry (com.jme3.scene.Geometry)2 Node (com.jme3.scene.Node)2 Spatial (com.jme3.scene.Spatial)2 VertexBuffer (com.jme3.scene.VertexBuffer)2 ByteBuffer (java.nio.ByteBuffer)2 FloatBuffer (java.nio.FloatBuffer)2 Generic6DofConstraint (com.bulletphysics.dynamics.constraintsolver.Generic6DofConstraint)1 RotationalLimitMotor (com.jme3.bullet.joints.motors.RotationalLimitMotor)1 BitmapFont (com.jme3.font.BitmapFont)1