Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ideas for physics for rolling dice [closed]

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.

like image 691
userbb Avatar asked May 14 '11 19:05

userbb


1 Answers

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.
like image 194
Aleadam Avatar answered Nov 04 '22 08:11

Aleadam