Čes*_*pan 8 java jmonkeyengine bulletphysics
我最近开始使用jMonkey引擎,非常好.但是我试图实现相对引力.
我想制造围绕彼此旋转的行星(不一定是完美的圆形轨道,取决于速度).所以每个对象都应该影响其他对象.
我现在拥有的:
关闭全球引力
bulletAppState.getPhysicsSpace().setGravity(Vector3f.ZERO);
Run Code Online (Sandbox Code Playgroud)
初始化球体并添加到物理空间
Sphere sphere = new Sphere(50, 50, 5);
Geometry sun = new Geometry("Sun", sphere);
sun.setMaterial(stone_mat);
rootNode.attachChild(sun);
sun.setLocalTranslation(0, 0, 0);
sunPhysics = new RigidBodyControl((float) (50*Math.pow(10, 5)));
sun.addControl(sunPhysics);
bulletAppState.getPhysicsSpace().add(sunPhysics);
Geometry mercury = new Geometry("Mercury", sphere);
mercury.setMaterial(stone_mat);
rootNode.attachChild(mercury);
mercury.setLocalTranslation(15f, 0, 0);
mercuryPhysics = new RigidBodyControl((float) (5));
mercury.addControl(mercuryPhysics);
bulletAppState.getPhysicsSpace().add(mercuryPhysics);
Run Code Online (Sandbox Code Playgroud)
我注意到RigidBodyControl类中有方法setGravity,但它只是设置方向.所以对象就这样消失了.
我真的很期待找到答案.
子弹物理学中的重力是所有物体的一个方向。
您应该像以前一样将重力设置为 0,并在每个模拟步骤后使用以下公式对所有对象施加力
F = m * a
F - force
m - objects mass
a - acceleration
Run Code Online (Sandbox Code Playgroud)
地球上的规则加速度是g == 9.8
在太空中,加速度可能取决于与一个或多个行星的距离。
如果您喜欢模拟《愤怒的小鸟太空》这样的游戏,那么您应该考虑阅读有关该游戏中重力的文章 http://www.wired.com/wiredscience/2012/03/the-gravitational-force-in-angry-birds-space /
| 归档时间: |
|
| 查看次数: |
1283 次 |
| 最近记录: |