问题描述
我玩制作迷你高尔夫游戏使用three.js和ammo.js子弹物理库的转换,但我有一些麻烦让球实事求是地移动。
I am playing with making a minigolf game using three.js and the ammo.js conversion of the Bullet Physics library but I am having some trouble getting the ball to move realistically.
(我已经把一个演示在 penguinspuzzle.appspot.com/minigolf.html 如果你想看看它是如何工作的做法。)
(I've put a demo at penguinspuzzle.appspot.com/minigolf.html if you want to have a look at how this works in practice.)
什么是好的算法给一个迷你高尔夫球场的球更真实的动作?
What is a good algorithm to give more realistic motion of a minigolf ball?
在ammo.js有摩擦,线性阻尼和旋转阻尼选项。
In ammo.js there are options for friction, linear damping, and rotational damping.
当球滚动,摩擦设置似乎并没有产生太大的影响。
As the ball rolls, the friction setting does not seem to have much effect.
我目前使用
body.setRestitution(0.8);
body.setFriction(1);
body.setDamping(0.2,0.1); // linear damping, rotational damping
问题
使用线性值高阻尼球似乎减速太快了。
Problems
With high values of linear damping the ball seems to decelerate too fast.
的值越小,似乎把年龄,终于停下来。
With lower values it seems to take ages to finally stop.
当球在空中,似乎不合理的被应用线性衰减的。
When the ball is in the air it seems unreasonable to be applying linear damping at all.
我想问题可能是线性的阻尼ammo.js这将导致指数放缓。
I think the problem may be the linear damping in ammo.js which causes an exponential slow down.
我想:
- 记录高尔夫球击球的视频
- 在每帧测量球的位置
- 绘制球的位置和速度与时间
的结果如下所示。它看起来对我来说,速度分布更接近是线性比指数。
The results are shown below. It looks to me like the velocity profile is much closer to being linear than exponential.
有一个算法,得到ammo.js更为现实有什么建议?
Any suggestions for an algorithm to get ammo.js to be more realistic?
推荐答案
我发现你使用常规摩擦上一个球形物体。在物理学中有一个单独的概念,滚动摩擦的圆形物体。我不知道子弹物理无论是在它的API提供这样一个概念。如果是的话,尝试与滚动摩擦对应替换这样的:
I spotted that you're using "regular" friction on a spherical object. In physics there is a separate concept, "rolling friction" for round objects. I don't know whether Bullet Physics supplies such a concept in its API. If it does, try replacing this with the rolling friction counterpart:
body.setFriction(1);
这篇关于我如何能真实模拟高尔夫球击球与Bullet物理? (包括现场演示)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!