Dice rolling / rotation?

Hello,

Probably the solution for this is not the jmephysics related so i'll post it here.

I managed to implement very simple dice roll with the jmephysics2. I've added the dice model node to the dynamic node, applyied some forceo on it… and everything is fine, the dice rolls diferently almost every time. Everything but one thing, i have absolutly no idea how to read the result :), i can only look at it and see but thats not enough.

I belive i should use getLocalRotation() method, but sometimes the x,y,z,w values are changing even when the dice isn't moving so im confused. Any ideas, hints?

thanks

Irrisor suggested using the physics engine itself to come up with this answer… This thread would be interesting to you regardless http://www.jmonkeyengine.com/jmeforum/index.php?topic=5770.0


Thanks for the anwser, i've seen this thrad before, however i don't find there any awnser for my problem, or maybe im just blind.

The easiest way that comes to my mind, currently, is to multiply a vector like (1;2;3) with the world rotation and inspect the resulting vector - the y (if you have y-up) component should be either 1, -1, 2, -2, 3 or -3 - depending on what the dice shows… if it is lying correctly on the floor, at least… but mud2005 could tell you more, I guess - he also used different dice than just a cube…

irrisor said:

The easiest way that comes to my mind, currently, is to multiply a vector like (1;2;3) with the world rotation and inspect the resulting vector - the y (if you have y-up) component should be either 1, -1, 2, -2, 3 or -3 - depending on what the dice shows... if it is lying correctly on the floor, at least... but mud2005 could tell you more, I guess - he also used different dice than just a cube...


Something like: dynamicNode.getLocalRotation().mult(gameNode.getLocalRotation()).y ?

no


dynamicNode.getWorldRotation().multLocal( new Vector(1, 2, 3) ).y

irrisor said:

no

dynamicNode.getWorldRotation().multLocal( new Vector(1, 2, 3) ).y




Thanks it works great :)