use of com.jme3.bullet.collision.shapes.CollisionShape in project jmonkeyengine by jMonkeyEngine.
the class PhysicsRigidBody method rebuildRigidBody.
/**
* Builds/rebuilds the phyiscs body when parameters have changed
*/
protected void rebuildRigidBody() {
boolean removed = false;
if (collisionShape instanceof MeshCollisionShape && mass != 0) {
throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!");
}
if (rBody != null) {
if (rBody.isInWorld()) {
PhysicsSpace.getPhysicsSpace().remove(this);
removed = true;
}
rBody.destroy();
}
preRebuild();
rBody = new RigidBody(constructionInfo);
postRebuild();
if (removed) {
PhysicsSpace.getPhysicsSpace().add(this);
}
}
use of com.jme3.bullet.collision.shapes.CollisionShape in project jmonkeyengine by jMonkeyEngine.
the class BufferedTriangleCallback method createDebugShape.
private static Geometry createDebugShape(CollisionShape shape) {
Geometry geom = new Geometry();
geom.setMesh(DebugShapeFactory.getDebugMesh(shape));
// geom.setLocalScale(shape.getScale());
geom.updateModelBound();
return geom;
}
use of com.jme3.bullet.collision.shapes.CollisionShape in project jmonkeyengine by jMonkeyEngine.
the class BufferedTriangleCallback method getDebugMesh.
public static Mesh getDebugMesh(CollisionShape shape) {
Mesh mesh = null;
if (shape.getCShape() instanceof ConvexShape) {
mesh = new Mesh();
mesh.setBuffer(Type.Position, 3, getVertices((ConvexShape) shape.getCShape()));
mesh.getFloatBuffer(Type.Position).clear();
} else if (shape.getCShape() instanceof ConcaveShape) {
mesh = new Mesh();
mesh.setBuffer(Type.Position, 3, getVertices((ConcaveShape) shape.getCShape()));
mesh.getFloatBuffer(Type.Position).clear();
}
return mesh;
}
use of com.jme3.bullet.collision.shapes.CollisionShape in project jmonkeyengine by jMonkeyEngine.
the class PhysicsCollisionObject method read.
@Override
public void read(JmeImporter e) throws IOException {
InputCapsule capsule = e.getCapsule(this);
collisionGroup = capsule.readInt("collisionGroup", 0x00000001);
collisionGroupsMask = capsule.readInt("collisionGroupsMask", 0x00000001);
CollisionShape shape = (CollisionShape) capsule.readSavable("collisionShape", null);
collisionShape = shape;
}
Aggregations