JME-Jbullet物理题
我目前正在使用 JME-Jbullet 物理引擎,但我的地形遇到了问题。
我有 2 个扁平的盒子,一个用于地板,另一个用作坡道。问题如下:
使用以下代码:
Box slope = new Box("Slope", new Vector3f(0, -1, 0), 10f, 0f, 15f);
PhysicsNode pSlope = new PhysicsNode(slope, CollisionShape.ShapeTypes.MESH);
pSlope.setMass(0);
pSlope.getLocalRotation().fromAngleNormalAxis( 0.5f, new Vector3f( 0, 0, -1 ) );
在应用旋转之前,盒子表现正常,如果另一个对象掉落在顶部,则它们会正确碰撞。然而,旋转之后,盒子会旋转,但它的“物理”不会改变,因此当一个物体掉落到看似斜坡的顶部时,它的表现就好像旋转从未发生过一样。
是否有某种方法可以更新斜坡,以便当物体掉落到其上时,它会滑落?
谢谢。
I'm currently playing with the JME-Jbullet physics engine, and having issues with my terrain.
I have 2 flat boxes, one for the floor, and one to act as a ramp. The issue is as follows:
With the following code:
Box slope = new Box("Slope", new Vector3f(0, -1, 0), 10f, 0f, 15f);
PhysicsNode pSlope = new PhysicsNode(slope, CollisionShape.ShapeTypes.MESH);
pSlope.setMass(0);
pSlope.getLocalRotation().fromAngleNormalAxis( 0.5f, new Vector3f( 0, 0, -1 ) );
Before the rotation is applied, the box acts as normal, if another object is dropped on top, then they collide correctly. After the rotation however, the box is rotated, but its "Physics" doesn't change, so when an object is dropped ontop of what appears to be the ramp, it is acting as though the rotation never happened.
Is there some way to update the ramp so that when an object is dropped on to it, it slides down?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还记得在
update
方法中更新物理世界吗?其中
pSpace
来自PhysicsSpace pSpace=PhysicsSpace.getPhysicsSpace();
are you remembering to update the physics world in your
update
method?where
pSpace
comes fromPhysicsSpace pSpace=PhysicsSpace.getPhysicsSpace();
问题出在碰撞形状上。网格是计算碰撞的极其昂贵的形状,据我所知,它在 JME 中还不能正常工作。将其替换为盒子碰撞形状即可解决您的问题。
The problem is in the collision shape. A mesh is an extremely expensive shape to calculate collisions for, and as far as I am aware of not working properly (yet) in JME. Replacing it by a box collision shape will solve your problem.
如 javadocs:
我猜你需要调用
pSlope.setLocalRotation(...) 而不是获取旋转并就地修改它。
As indicated in the javadocs:
I would guess from that that you will need to call
pSlope.setLocalRotation(...)
instead of getting the rotation and modifying it in place.