JBullet RigidBodies

时间:2013-04-09 23:21:37

标签: java collision jbullet

我在与我的游戏实施碰撞时遇到了麻烦,更具体地说是主要玩家(一旦它与我设置的盒子发生碰撞,它就会反弹回来)。这是设置查看器的代码:

    CollisionShape myCol = new CylinderShape(new javax.vecmath.Vector3f(0.4f, 0.9f, 0.4f));
    DefaultMotionState motion = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new javax.vecmath.Vector3f(0, 33, 0), 1f)));
    javax.vecmath.Vector3f fallInertia = new javax.vecmath.Vector3f(0, 0, 0);
    //myCol.calculateLocalInertia(0, fallInertia);
    RigidBodyConstructionInfo cInfo = new RigidBodyConstructionInfo(1, motion, myCol, fallInertia);
    self_Col = new RigidBody(cInfo);
    self_Col.setFriction(1f);
    self_Col.setRestitution(1f);
    self_Col.setDamping(0.04f, 0.1f);

这是物理世界的设置:

  AxisSweep3 pairCache = new AxisSweep3(new javax.vecmath.Vector3f(-10000, -10000, -10000), new javax.vecmath.Vector3f(10000, 10000, 10000));
    DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
    CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
    SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
    detectionWorld = new DiscreteDynamicsWorld(dispatcher, pairCache, solver, collisionConfiguration);
    detectionWorld.setGravity(new javax.vecmath.Vector3f(0, -2f, 0));

我正在尝试移动播放器,然后将新位置应用到碰撞盒,然后执行物理步骤并将位置设置为新的碰撞盒位置。所以基本上我有两个向量的位置。

编辑:任何人?我还有这个问题

1 个答案:

答案 0 :(得分:0)

JBullet通常有0-1的许多单位。恢复原状是造成这个问题的原因,恢复原状是你的碰撞形状有多么有弹性。你的恢复原状很高,试着减少它,看看是否有帮助。

self_Col.setRestitution(0.1f);