# Dice Algorithm Problem

Lets say I have a few dice models, I get them loaded up, apply ODE and bounce them around in a small box.

Not terribly difficult, a few days and I figured it out for the most part and they are happy little campers.

But now I’m wondering, how do I determine which side is up on each die when they come to rest?

Any ideas?

Match the H/P or R rotations of the dice node, using node.getHpr(), with the side of the face.

For instance, (You’ll have to determine which way is correct), if your dice has a 4 on top when it’s node.getP() value is 0, then you know:

``````if dice.getP() == 0:
diceSide = 4
elif dice.getP() == 180:
diceSide = 0 # whatever the other side is
``````

Soo, you get the idea. You’ll have to match the correct rotation’s with the side of your dice (it depends on how it’s modeled)

~powerpup118

P.S. This probably belongs in Scripting Issues

Yes, that looks promising. Seeing patterns if I print the hpr of each die in the simTask. Thanks.

SMARTASS WARNING

The parallel sides on a regular six-sided cube always give a sum of 7 (although a zero would be quite funny, too)

Something you need to remember if you don’t like to be cheated at games

Alternative to that is to make empties on center of each side and properly tag them. After that, just iterate trough them and see which one has highest apsolute Z coordinate.