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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations