小编Čes*_*pan的帖子

相对重力

我最近开始使用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,但它只是设置方向.所以对象就这样消失了.

我真的很期待找到答案.

java jmonkeyengine bulletphysics

8
推荐指数
1
解决办法
1283
查看次数

如何处理从0到2 ^ 95的循环?

我的问题如下:

我必须遍历95个元素的所有可能性(0或1).

例如,如果有2个元素,则可能性为:00,01,10,11

总可能性的数量是2 ^ n,因此它增长得非常快.2 ^ 95 = 39614081257132168796771975168

我如何有效地从0迭代到2 ^ 95?

PS选择编程语言并不重要,但我猜C或C++应该是最快的选择.

PPS我认为BigInt实现似乎比原始类型慢得多,将数字拆分为X个基元可能是个好主意.到目前为止我没有运气.

PPS我有一个功能,它可以通过提供0到2 ^ 95的数字来产生可能性

loops

0
推荐指数
1
解决办法
102
查看次数

标签 统计

bulletphysics ×1

java ×1

jmonkeyengine ×1

loops ×1