【问题标题】:JBullet - Convex Shapes not working properly when staticJBullet - 静态时凸形状无法正常工作
【发布时间】:2015-07-06 14:53:07
【问题描述】:

我在 JBullet 中使用动态箱形物体进行碰撞。它们正确地相互碰撞。但是我正在摆弄构建世界并遇到了一些奇怪的问题。

当我试图使凸刚体(BoxShape 或 TriangleShape)静态(通过将质量设置为 0)时,碰撞仅在 (0,0,0) 处的某种点而不是给定形状处起作用。如果它是动态的,那么它运行良好。

其他问题,也许有一些链接:如果我使用 BvhTriangleMeshShape 或 GImpactMeshShape,它只有在动态且在静态时不会发生碰撞时才能正常工作(尽管 BvhTriangleMeshShape 将用于静态物体)。

我是这样初始化世界的:

BroadphaseInterface broadphase = new DbvtBroadphase();
CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
ConstraintSolver solver = new SequentialImpulseConstraintSolver();
dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
dynamicsWorld.setGravity(new Vector3f(0, 0, 0));
GImpactCollisionAlgorithm.registerAlgorithm(dispatcher);

有问题的对象:

Vector3f inertia = new Vector3f(0, 0, 0);
MotionState motion = new DefaultMotionState(new Transform());

//BvhTriangleMeshShape shape = ShapeUtil.getShapeFromModel(testSphere);
//CompoundShape shape = ShapeUtil.getCompoundShapeFromModel(testSphere);
//GImpactMeshShape shape = ShapeUtil.getGImpactShapeFromModel(testSphere);
BoxShape shape = new BoxShape (new Vector3f(2,2,2));
//TriangleShape shape = new TriangleShape(new Vector3f(-20,0,-10), new Vector3f(20,20,-10), new Vector3f(20,-20,-10));

RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(0, motion, shape, inertia);
RigidBody body = new RigidBody(constructionInfo);
//body.setCollisionFlags(CollisionFlags.STATIC_OBJECT);

dynamicsWorld.addRigidBody(body);
this.bodies[64] = body;

谁能帮帮我?我正在使用 2010 年 10 月 10 日的 JBullet 版本。 提前致谢。

【问题讨论】:

    标签: java physics jbullet


    【解决方案1】:

    看来我发现了问题。我通过替换线解决了它

    MotionState motion = new DefaultMotionState(new Transform());
    

    通过

    Transform transform = new Transform();
    transform.setIdentity();
    MotionState motion = new DefaultMotionState(transform);
    

    看起来 Transform 的默认构造函数不会像我预期的那样创建身份转换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-21
      • 2015-12-07
      • 2016-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多