title: JavaFX: Rotate an object without turning the axis
body: <p>In order to work on a project Rybi's cube game, I have to turn the cubes  around particular axes, so the problem is that if I turn an object around an axis, eg Y-axis with a 90  degree, so if I turn it again around x axis,the rotation will be on the direction of the Z axis because the X axis takes dircetion of Z.</p>
  
  <p>Below, there is a piece of code illustrates the same situation that I just introduce you.</p>
  
  <p>Is there a way to do things the way I desire</p>
  
  <pre><code>public class RybiCube extends Application {
  
      final Group root = new Group();
      final PerspectiveCamera camera = new PerspectiveCamera(true);
      final XformCamera cameraXform = new XformCamera();
      public static final double CAMERA_INITIAL_DISTANCE = -1000;
      public static final double CAMERA_NEAR_CLIP = 0.1;
      public static final double CAMERA_FAR_CLIP = 10000.0;
  
      public void init(Stage primaryStage) {
  
          Box box = new Box();
          box.setHeight(70);
          box.setWidth(200);
          box.setDepth(70);
          //box.setRotationAxis(Rotate.Y_AXIS);
          //box.setRotate(80);
          box.getTransforms().add(new Rotate(90,Rotate.Y_AXIS));
          box.getTransforms().add(new Rotate(45,Rotate.X_AXIS));
  
  
          PhongMaterial material = new PhongMaterial();
          material.setDiffuseColor(Color.ORANGE);
          material.setSpecularColor(Color.BLACK);
          box.setMaterial(material);
  
          root.getChildren().add(box);
          buildCamera();
          Scene scene = new Scene(root, 600, 600, true);
          primaryStage.setScene(scene);
          scene.setCamera(camera);
          ///
          primaryStage.setResizable(false);
          scene.setFill(Color.rgb(0, 0,0,0.5));
          primaryStage.setScene(scene);        
      }
  
      private void buildCamera() {
          root.getChildren().add(cameraXform);
          cameraXform.getChildren().add(camera);
          camera.setNearClip(CAMERA_NEAR_CLIP);
          camera.setFarClip(CAMERA_FAR_CLIP);
          camera.setTranslateZ(CAMERA_INITIAL_DISTANCE);
      }
  
      public void start(Stage primaryStage)
      {
          init(primaryStage);
          primaryStage.show();
      }
      public static void main(String[] args) {
          launch(args);
      }
  
  }
  class XformCamera extends Group {
  
      final Translate tr = new Translate(0.0, 0.0, 0.0);
      final Rotate rx = new Rotate(00, Rotate.X_AXIS);
      final Rotate ry = new Rotate(10, Rotate.Y_AXIS);
      final Rotate rz = new Rotate(0, Rotate.Z_AXIS);
  
      public XformCamera() {
          super();
          this.getTransforms().addAll(tr, rx, ry, rz);
      }
  
  }
  </code></pre>