use of com.jme3.bullet.collision.shapes.infos.ChildCollisionShape 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.bullet.collision.shapes.infos.ChildCollisionShape 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;
}
use of com.jme3.bullet.collision.shapes.infos.ChildCollisionShape in project jmonkeyengine by jMonkeyEngine.
the class CompoundCollisionShape method write.
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule capsule = ex.getCapsule(this);
capsule.writeSavableArrayList(children, "children", new ArrayList<ChildCollisionShape>());
}
Aggregations