Search in sources :

Example 6 with ConvexShape

use of com.bulletphysics.collision.shapes.ConvexShape 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 7 with ConvexShape

use of com.bulletphysics.collision.shapes.ConvexShape 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)

Example 8 with ConvexShape

use of com.bulletphysics.collision.shapes.ConvexShape in project bdx by GoranM.

the class ConvexConvexAlgorithm method processCollision.

/**
	 * Convex-Convex collision algorithm.
	 */
@Override
public void processCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
    if (manifoldPtr == null) {
        // swapped?
        manifoldPtr = dispatcher.getNewManifold(body0, body1);
        ownManifold = true;
    }
    resultOut.setPersistentManifold(manifoldPtr);
    //	#ifdef USE_BT_GJKEPA
    //		btConvexShape*				shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
    //		btConvexShape*				shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
    //		const btScalar				radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
    //		btGjkEpaSolver::sResults	results;
    //		if(btGjkEpaSolver::Collide(	shape0,body0->getWorldTransform(),
    //									shape1,body1->getWorldTransform(),
    //									radialmargin,results))
    //			{
    //			dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
    //			resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
    //			}
    //	#else
    ConvexShape min0 = (ConvexShape) body0.getCollisionShape();
    ConvexShape min1 = (ConvexShape) body1.getCollisionShape();
    ClosestPointInput input = pointInputsPool.get();
    input.init();
    // JAVA NOTE: original: TODO: if (dispatchInfo.m_useContinuous)
    gjkPairDetector.setMinkowskiA(min0);
    gjkPairDetector.setMinkowskiB(min1);
    input.maximumDistanceSquared = min0.getMargin() + min1.getMargin() + manifoldPtr.getContactBreakingThreshold();
    input.maximumDistanceSquared *= input.maximumDistanceSquared;
    //input.m_stackAlloc = dispatchInfo.m_stackAllocator;
    //	input.m_maximumDistanceSquared = btScalar(1e30);
    body0.getWorldTransform(input.transformA);
    body1.getWorldTransform(input.transformB);
    gjkPairDetector.getClosestPoints(input, resultOut, dispatchInfo.debugDraw);
    pointInputsPool.release(input);
    if (ownManifold) {
        resultOut.refreshContactPoints();
    }
}
Also used : ClosestPointInput(com.bulletphysics.collision.narrowphase.DiscreteCollisionDetectorInterface.ClosestPointInput) ConvexShape(com.bulletphysics.collision.shapes.ConvexShape)

Aggregations

ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)8 Transform (com.bulletphysics.linearmath.Transform)4 Stack (com.bulletphysics.util.Stack)4 Vector3f (javax.vecmath.Vector3f)4 VoronoiSimplexSolver (com.bulletphysics.collision.narrowphase.VoronoiSimplexSolver)3 ConvexCast (com.bulletphysics.collision.narrowphase.ConvexCast)2 CastResult (com.bulletphysics.collision.narrowphase.ConvexCast.CastResult)2 GjkConvexCast (com.bulletphysics.collision.narrowphase.GjkConvexCast)2 SubsimplexConvexCast (com.bulletphysics.collision.narrowphase.SubsimplexConvexCast)2 BvhTriangleMeshShape (com.bulletphysics.collision.shapes.BvhTriangleMeshShape)2 CollisionShape (com.bulletphysics.collision.shapes.CollisionShape)2 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)2 ConcaveShape (com.bulletphysics.collision.shapes.ConcaveShape)2 SphereShape (com.bulletphysics.collision.shapes.SphereShape)2 KinematicCharacterController (com.bulletphysics.dynamics.character.KinematicCharacterController)2 PairCachingGhostObject (com.bulletphysics.collision.dispatch.PairCachingGhostObject)1 ClosestPointInput (com.bulletphysics.collision.narrowphase.DiscreteCollisionDetectorInterface.ClosestPointInput)1 GjkEpaPenetrationDepthSolver (com.bulletphysics.collision.narrowphase.GjkEpaPenetrationDepthSolver)1 StaticPlaneShape (com.bulletphysics.collision.shapes.StaticPlaneShape)1 InputCapsule (com.jme3.export.InputCapsule)1