Rotate Camera about a Node

Hello All,

I had been working a bit on rotating the camera (node) about a specific node given both roll and tilt (pitch) angles and vectors. Hope this is of help to those who need such a feature


  CameraNode oCamNode;

  //rollAxis is usually cam.up
  //tiltAxis is usually cam.up cross cam.dir

  public void rotateDelta(float angleRoll, float anglePitch, Vector3f rollAxis, Vector3f tiltAxis) {   
      Matrix4f axisL2W = new Matrix4f();

      Vector3f oldPos = axisL2W.toTranslationVector().negate();

      Quaternion qRoll = new Quaternion();
      Quaternion qTilt = new Quaternion();
      qRoll.fromAngleAxis(angleRoll, rollAxis);
      qTilt.fromAngleAxis(anglePitch, tiltAxis);
      Quaternion q = qRoll.mult(qTilt);

      oCamNode.setLocalTranslation(new Vector3f());
      Quaternion rot = oCamNode.getLocalRotation();

1 Like

I'm sure it will be helpful! A lot of people need to do that with MMORPG's, RTS's and such.