Rolling dice

sorry anyone has an example of rolling dice in android appreciate them

Do you mean:

  1. Just emulating numeric result
  2. Animation of rolling dice with results coming from 1
  3. Full blown physics simulation of dice boucing from environment and each other and using results
    ?

Regarding 3, I have done it in desktop version of jme3, it might be portable to Android if you simplify shaders a bit.

Good Morning, I mean the 2 and 3

is an example that can serve me? thank you very much for your help

There are no standalone classes for that unfortunately. In any case, there are some pointers with which you can probably bootstrap your development a lot faster:

Dice objects are here:
https://www.assembla.com/code/vmat/subversion/nodes/118/trunk/assets/dist/dice
Naming is (example for d20)
d20-hull.obj - to be used for collission shape
d20-s2.obj - best detail object for rendering
d20-s1,d20-s0 - less details (more pronounced edges)

You should use d20.png texture for all dice except d4, for which special d4.png texture is to be used.

Here you can find shaders I was using
https://www.assembla.com/code/vmat/subversion/nodes/118/trunk/src/main/resources/net/virtualmat/dice

Data model is here
https://www.assembla.com/code/vmat/subversion/nodes/118/trunk/src/main/resources/net/virtualmat/dice/diceshapes.json
important part is ‘control points’ - it is the table of normals for which dice shows given value. You can see code for checking the normals here
https://www.assembla.com/code/vmat/subversion/nodes/118/trunk/src/main/java/net/virtualmat/dice/DiceRecorder.java
(look for controlPoints).
You might want to look into other classes in
https://www.assembla.com/code/vmat/subversion/nodes/118/trunk/src/main/java/net/virtualmat/dice
to get ideas about how to create objects and physics representations. Please pay attention to DiceManager.randomQuaternion - it is critical that you use it for randomizing dice orientation. Any trivial solution like rotating by 3 random floats is going to skew the results.

Code is considerably more complicated than it should because it has logic for network replication and reply of dice paths (my goal was to have exactly same behaviour on every connected client).

In any case, even just taking dice shapes and textures should already make things a lot easier - add them to physics space, give some initial random rotatio and direction of movement, drop on the table and enjoy them bouncing around.

You can see example of it in action at

thank you very much for your help, you are the best