Search in sources :

Example 16 with Matrix3f

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

the class CollisionShapeFactory method shiftCompoundShapeContents.

/**
     * This method moves each child shape of a compound shape by the given vector
     * @param vector
     */
public static void shiftCompoundShapeContents(CompoundCollisionShape compoundShape, Vector3f vector) {
    for (Iterator<ChildCollisionShape> it = new LinkedList(compoundShape.getChildren()).iterator(); it.hasNext(); ) {
        ChildCollisionShape childCollisionShape = it.next();
        CollisionShape child = childCollisionShape.shape;
        Vector3f location = childCollisionShape.location;
        Matrix3f rotation = childCollisionShape.rotation;
        compoundShape.removeChildShape(child);
        compoundShape.addChildShape(child, location.add(vector), rotation);
    }
}
Also used : ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) Matrix3f(com.jme3.math.Matrix3f) Vector3f(com.jme3.math.Vector3f) ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) LinkedList(java.util.LinkedList)

Example 17 with Matrix3f

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

the class PhysicsGhostObject method getPhysicsRotationMatrix.

public Matrix3f getPhysicsRotationMatrix() {
    Matrix3f mtx = new Matrix3f();
    getPhysicsRotationMatrix(objectId, mtx);
    return mtx;
}
Also used : Matrix3f(com.jme3.math.Matrix3f)

Example 18 with Matrix3f

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

the class PhysicsRigidBody method getPhysicsRotationMatrix.

public Matrix3f getPhysicsRotationMatrix() {
    Matrix3f mtx = new Matrix3f();
    getPhysicsRotationMatrix(objectId, mtx);
    return mtx;
}
Also used : Matrix3f(com.jme3.math.Matrix3f)

Example 19 with Matrix3f

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

the class BoundingBox method transform.

public BoundingVolume transform(Matrix4f trans, BoundingVolume store) {
    BoundingBox box;
    if (store == null || store.getType() != Type.AABB) {
        box = new BoundingBox();
    } else {
        box = (BoundingBox) store;
    }
    TempVars vars = TempVars.get();
    float w = trans.multProj(center, box.center);
    box.center.divideLocal(w);
    Matrix3f transMatrix = vars.tempMat3;
    trans.toRotationMatrix(transMatrix);
    // Make the rotation matrix all positive to get the maximum x/y/z extent
    transMatrix.absoluteLocal();
    vars.vect1.set(xExtent, yExtent, zExtent);
    transMatrix.mult(vars.vect1, vars.vect1);
    // Assign the biggest rotations after scales.
    box.xExtent = FastMath.abs(vars.vect1.getX());
    box.yExtent = FastMath.abs(vars.vect1.getY());
    box.zExtent = FastMath.abs(vars.vect1.getZ());
    vars.release();
    return box;
}
Also used : TempVars(com.jme3.util.TempVars)

Example 20 with Matrix3f

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

the class DebugShapeFactory method getDebugShape.

/** The maximum corner for the aabb used for triangles to include in ConcaveShape processing.*/
//    private static final Vector3f aabbMax = new Vector3f(1e30f, 1e30f, 1e30f);
/** The minimum corner for the aabb used for triangles to include in ConcaveShape processing.*/
//    private static final Vector3f aabbMin = new Vector3f(-1e30f, -1e30f, -1e30f);
/**
     * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
     * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
     * @param collisionShape
     * @return
     */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext(); ) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);
            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);
            // apply rotation
            TempVars vars = TempVars.get();
            Matrix3f tempRot = vars.tempMat3;
            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);
            vars.release();
            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
Also used : Geometry(com.jme3.scene.Geometry) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) CollisionShape(com.jme3.bullet.collision.shapes.CollisionShape) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) Spatial(com.jme3.scene.Spatial) Matrix3f(com.jme3.math.Matrix3f) Node(com.jme3.scene.Node) ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) TempVars(com.jme3.util.TempVars)

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