title: Rotate object in Java 3d
body: <p>I try to make a rotation to a cube according to the movement of the mouse in Java3D. No matter the rotation of the cube, I want that when I drag my cursor up, the cube rotates in the same direction. And this for all possible movements.</p>
  
  <p>How can I proceed? I guess it must be placed in the camera coordinates...</p>
  
  <p>Here is my function : </p>
  
  <pre><code>public void objectRotate(TransformGroup objectInInteraction, double dh,
          double dp, double dr) {
  
      Transform3D oldT3D = new Transform3D();
      objectInInteraction.getTransform(oldT3D);       
  
      Transform3D tx = new Transform3D();
      Transform3D ty = new Transform3D();
      Transform3D tz = new Transform3D();
  
      Transform3D tc = new Transform3D();
      //camera.getTransform(tc);
  
      double x = 0, y = 0, z = 0;
      x = Math.PI * dh / 180;
      y = Math.PI * dp / 180;
      z = Math.PI * dr / 180;
  
      tx.rotX(x);
      tc.mul(tx);
  
      ty.rotY(y);
      tc.mul(ty);
  
      tz.rotZ(z);     
      tc.mul(tz);
  
      oldT3D.mul(tc);
  
  
      objectInInteraction.setTransform(oldT3D);
  }
  </code></pre>
  
  <p>dh is a left right movement, dp, up and down</p>
  
  <p>Thanks !</p>