HUD: Fix Axis-Direction independet of the Camera-Direction or Orientation

Hi all together,



I want to build an HUD containing AxisRods that are always direct into the x-direction of the world independent of the camera direction or orientations (like a compass). So a rotation method for Object in a HUD. This also can used as an map for strategy games.



here is my code, after a lot of readings and tries I think I don't know what i do :smiley:



public class HUDInterface {
   public static final String HUDName = "HeadsUpDisplay";

   private final Node MyHUDRoot;
   private final D3Implementor MyImplementor;
   private final Spatial MyAxis;
   private final Vector3f axis = new Vector3f(1, 1, 10);
   private Quaternion rotQuat = new Quaternion();

   public HUDInterface(final D3Implementor Implementor) {
      MyImplementor = Implementor;
      MyHUDRoot = new Node(HUDName);
      MyAxis = new AxisRods("CoordinateAxis", true, 50f);
      MyAxis.setRenderQueueMode(Renderer.QUEUE_ORTHO);
      MyAxis.setLocalTranslation(new Vector3f(MyImplementor.DisplaySystem().getWidth() / 2, MyImplementor.DisplaySystem().getHeight() / 2, 0));
      MyHUDRoot.attachChild(MyAxis);
      MyImplementor.getRootNode().attachChild(MyHUDRoot);
   }

   public Node HUDRoot() {
      return MyHUDRoot;
   }

   public void Update() {
      // if (MyImplementor.getTimePerFrame() < 1) {
      // angle = angle + MyImplementor.getTimePerFrame();
      // }
      rotQuat = MyImplementor.getRootNode().getWorldRotation();
      // angle=MyImplementor.getRootNode().getWorldRotation()
      // rotQuat.fromAngleAxis(0, MyImplementor.getCamera().getDirection());
      MyAxis.setLocalRotation(rotQuat);
      MyAxis.updateRenderState();
   }

}



I think the problem is the rotation in the Update() method.

(Btw. variables and methods has to begin with an upper case letter in our project, I don't like it but may you now it: Historical Grown :D  . no further comments.)

Take a look in the wiki at :-



=compass]http://www.jmonkeyengine.com/wiki/doku.php?id=navigator&s[]=compass