Rotatin cube

I was very surprised when I find out that there is no "rotating cube" sample implemented in JME.

I read few introductory chapters about OpenGL, JOGL etc. and there always were some kind of a automatic "rotating cube" sample. It helped me a lot to gain good understanding on how to do basic superposition of rotations within API. Then I continued to improve myself the sample, adding possibility of manual rotations etc.



Could someone post this kind of an example written in JME?

I'm sure it would be very helpful for newbies.


you can look at TestTube.java (in jme-test) to see an example on object rotation.
basicaly:


[.....]
    private Quaternion rotQuat = new Quaternion();
    private float angle = 0;
    private Vector3f axis = new Vector3f(1, 1, 0).normalizeLocal();
    private Tube t;
[.....]
    protected void simpleUpdate() {
        if (timer.getTimePerFrame() < 1) {
            angle = angle + (timer.getTimePerFrame() * 1);
            if (angle > 360) {
                angle = 0;
            }
        }
        rotQuat.fromAngleNormalAxis(angle, axis);
        t.setLocalRotation(rotQuat);
    }
[.....]


I too would like  to see more simple tests like this one.
like:
cube rotation, on which axis for how much time, rotate until 60deg rotation is performed, etc.
thoses small test are easy to understand and reuse.
Quaternion are a bit difficult to understand, few more simple example as this TestTube.java could help.

There's a bunch of spinning shape examples under jmetest.renderer

Here's a cube one based on them. I think you meant something a bit more complex though?



import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;

public class TestCube extends SimpleGame {

       private Box cube;
       private Quaternion rotQuat = new Quaternion();
       private float angle = 0;

       public static void main(String[] args) {
           TestCube app = new TestCube();
           app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
           app.start();
       }

       protected void simpleUpdate() {
           if (tpf < 1) {
               angle = angle + (tpf * 20);
               if (angle > 360) {
                   angle = 0;
               }
           }
           rotQuat.fromAngleAxis(angle * FastMath.DEG_TO_RAD, Vector3f.UNIT_Y);
           cube.setLocalRotation(rotQuat);
       }

       protected void simpleInitGame() {
           display.setTitle("TestCube");

           cube = new Box("cube", new Vector3f(-10f, -10f, -10f), new Vector3f(10f, 10f, 10f));
           cube.setLocalTranslation(new Vector3f(0, 0, -40));
           cube.setModelBound(new BoundingBox());
           cube.updateModelBound();

           rootNode.attachChild(cube);
       }
}

@Alric, where did you find examples with source?

Pls, post a link here.

dhdd - quite so… missed that!

rasa - they're all in the default jme install - jme.src.jmetest

Are there zipped samples, or do I have to browse through CVS?