Search in sources :

Example 21 with CollisionShape

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);
    }
}
Also used : MeshCollisionShape(com.jme3.bullet.collision.shapes.MeshCollisionShape) RigidBody(com.bulletphysics.dynamics.RigidBody)

Example 22 with CollisionShape

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;
}
Also used : Geometry(com.jme3.scene.Geometry)

Example 23 with CollisionShape

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;
}
Also used : ConvexShape(com.bulletphysics.collision.shapes.ConvexShape) ConcaveShape(com.bulletphysics.collision.shapes.ConcaveShape) Mesh(com.jme3.scene.Mesh)

Example 24 with CollisionShape

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;
}
Also used : CollisionShape(com.jme3.bullet.collision.shapes.CollisionShape)

Aggregations

CollisionShape (com.jme3.bullet.collision.shapes.CollisionShape)8 Vector3f (com.jme3.math.Vector3f)7 ChildCollisionShape (com.jme3.bullet.collision.shapes.infos.ChildCollisionShape)6 Geometry (com.jme3.scene.Geometry)6 Node (com.jme3.scene.Node)6 Matrix3f (com.jme3.math.Matrix3f)5 BoxCollisionShape (com.jme3.bullet.collision.shapes.BoxCollisionShape)4 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)4 Spatial (com.jme3.scene.Spatial)4 CompoundCollisionShape (com.jme3.bullet.collision.shapes.CompoundCollisionShape)3 Mesh (com.jme3.scene.Mesh)3 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)2 Transform (com.bulletphysics.linearmath.Transform)2 BulletAppState (com.jme3.bullet.BulletAppState)2 CapsuleCollisionShape (com.jme3.bullet.collision.shapes.CapsuleCollisionShape)2 VehicleWheel (com.jme3.bullet.objects.VehicleWheel)2 Transform (com.jme3.math.Transform)2 Box (com.jme3.scene.shape.Box)2 TempVars (com.jme3.util.TempVars)2 ConcaveShape (com.bulletphysics.collision.shapes.ConcaveShape)1