开发者

Ideas for physics for rolling dice [closed]

开发者 https://www.devze.com 2023-03-05 18:18 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学运维
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学运维

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 6 years ago.

Improve this question

I want to make rolling cube like dice that reacts on accelerometer. So accelerometer gives parameters for cube moving. I think that small physic should be used here. My question is what formulas, techniques should I use to accomplish this without any physics engine.


You will need probably to use OpenGL for that. There a good physics tutorial for OGL here

Specifically for dice, take a look at this nokia demo. It's written in cpp (source here)

On the physics side, you can take a look at this site.

Anyhow, I do not think you need real physics for the app, but just an approximation:

  • I would start getting a velocity that depends on the accelerometer (plus or minus, let's say, 20%) and random angular speeds for the dice.
  • Then, find the trajectory for each and when touching a border.
  • Bounce them to one direction or another depending on the rotation at that particular moment.
  • Change the sign of the angular speed if the dice bounce back.
  • Reduce the speed about 50% each bounce, until a threshold.
  • Below that threshold, leave them in the floor and stop movement.
0

精彩评论

暂无评论...
验证码 换一张
取 消