Search in sources :

Example 1 with KinematicCharacterController

use of com.bulletphysics.dynamics.character.KinematicCharacterController in project jmonkeyengine by jMonkeyEngine.

the class PhysicsCharacter method buildObject.

protected void buildObject() {
    if (gObject == null) {
        gObject = new PairCachingGhostObject();
    }
    gObject.setCollisionFlags(CollisionFlags.CHARACTER_OBJECT);
    gObject.setCollisionFlags(gObject.getCollisionFlags() & ~CollisionFlags.NO_CONTACT_RESPONSE);
    gObject.setCollisionShape(collisionShape.getCShape());
    gObject.setUserPointer(this);
    character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
}
Also used : ConvexShape(com.bulletphysics.collision.shapes.ConvexShape) PairCachingGhostObject(com.bulletphysics.collision.dispatch.PairCachingGhostObject) KinematicCharacterController(com.bulletphysics.dynamics.character.KinematicCharacterController)

Example 2 with KinematicCharacterController

use of com.bulletphysics.dynamics.character.KinematicCharacterController in project jmonkeyengine by jMonkeyEngine.

the class PhysicsCharacter method read.

@Override
public void read(JmeImporter e) throws IOException {
    super.read(e);
    InputCapsule capsule = e.getCapsule(this);
    stepHeight = capsule.readFloat("stepHeight", 1.0f);
    buildObject();
    character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight);
    setGravity(capsule.readFloat("gravity", 9.8f * 3));
    setMaxSlope(capsule.readFloat("maxSlope", 1.0f));
    setFallSpeed(capsule.readFloat("fallSpeed", 55.0f));
    setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f));
    setUpAxis(capsule.readInt("upAxis", 1));
    setCcdMotionThreshold(capsule.readFloat("ccdMotionThreshold", 0));
    setCcdSweptSphereRadius(capsule.readFloat("ccdSweptSphereRadius", 0));
    setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f()));
}
Also used : InputCapsule(com.jme3.export.InputCapsule) Vector3f(com.jme3.math.Vector3f) ConvexShape(com.bulletphysics.collision.shapes.ConvexShape) KinematicCharacterController(com.bulletphysics.dynamics.character.KinematicCharacterController)

Aggregations

ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)2 KinematicCharacterController (com.bulletphysics.dynamics.character.KinematicCharacterController)2 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)1 InputCapsule (com.jme3.export.InputCapsule)1 Vector3f (com.jme3.math.Vector3f)1