Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a simple 3D game. In the game, sometimes the players have to roll die (a D8 to be exact). I wish to represent the rolling die with a 3D model, and I'd like to animate it in 3D space as if it was really rolled.

Can anyone help me describe the way the die spins around in real life?

PS: I'm working on this in WPF, using Storyboards and Rotation3DAnimationUsingKeyFrames

share|improve this question
1  
As a meta comment i'm intrigued you're putting this in. I think if people see the dice rolling and there's a bit of a delay, they feel better about the randomness. A player will hold their breath waiting to see what that visual dice roll is, but they won't hold their breath over a straight up random number generator (even if they are the same thing). That visual of the tumbling dice is powerful, whether activated by the player or the game. –  Tim Holt Jun 9 '11 at 0:45
add comment

3 Answers

I think since it's almost a very simple mesh (D8 means 8 triangles), you can directly give the mesh to your physics engine. if you want to draw some more complicated mesh you can still give some simple mesh to physics engine to do physics of dice.

share|improve this answer
    
The 3D is very very simple in this project (like watching a board from above and rotating and moving around). I don't have a 3D engine that could manage physics by itself. I need to describe the spinning dice by rotating the meshes around and axis or by quaternions. –  Tenshiko Jun 8 '11 at 17:59
    
then i suggest you add some physics engine for this problem. it's almost a very complicated problem and solving this is like creating a new physics engine yourself. –  Ali.S Jun 8 '11 at 19:16
    
If he had a physics engine, he could just use a box primitive... –  Olhovsky Jun 8 '11 at 22:46
1  
@olhovsky D8 is not a box. it's d6 that is similar to a box! –  Ali.S Jun 8 '11 at 22:57
1  
Whoops, my mistake :) He could just use the physics engine's octahedron primitive... er... yeah. –  Olhovsky Jun 9 '11 at 0:42
show 2 more comments

Blender 3D is open source, and free.

It is a modeling and rendering application, but it comes with easy to use soft-body, fluid, and ridged-body physics solvers.

You could set up a number of slightly different simulations, that match the dimensions of the area in your game, and export the animation data from blender to use in your engine.

In the game, just use a regular pseudo random number generator, and select an animation that matches that number, use a few variations on each number to reduce monotony.

share|improve this answer
    
+1 Looks like the solution asked for in the comments to my answer :) –  James Jun 8 '11 at 22:21
    
When there were no answers I actually started typing this answer out, but gave up half way, as I myself would rather just have a dice roll sound and a number pop up instead of watching a canned physics simulation, when I returned later, and saw that I decided my answer was on the right track, finished and posted it. –  AttackingHobo Jun 8 '11 at 22:41
add comment

You could 'cheat' the system.. An 8 sided die only has 8 possible values. If you randomly pick a number you could then play 1 of 8 animations that end on the number that was randomly generated. You would not get it to look like a random roll every time, but it would roll to a randomly generated number.

A second step to the canned animations would be randomizing the texture... If you can move which side of the die are the 'number' all you would need to do is have a random set of animations where the final side is known, and then a set of textures that you could choose from to make the final side be the known number. (I can expand on this if need be)

share|improve this answer
    
That is kind of what I was thinking of. Only thing is, I can't make the die roll animation look "real". That's why I asked :) –  Tenshiko Jun 8 '11 at 21:49
    
Ahh, In that case I would hire a professional, hehe. I am not an animator and short of writing a physics simulation to then video capture, getting a person who is good at animation of objects like this would be my next step :) –  James Jun 8 '11 at 21:55
    
I think some 3d modeling packages have built in physics sims. I"m betting somewhere there's a plugin for something that can basically create an animation out of a physics sim. –  Tim Holt Jun 8 '11 at 23:20
2  
@Tim Take a look at Hobo's answer, its a very good solution to the problem :) –  James Jun 8 '11 at 23:27
    
I'll vote you both up :) –  Tim Holt Jun 9 '11 at 0:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.