Quaternion Camera
- by Alex_Hyzer_Kenoyer
Can someone help me figure out how to use a Quaternion with the PerspectiveCamera in libGDX or in general? I am trying to rotate my camera around a sphere that is being drawn at (0,0,0). I am not sure how to go about setting up the quaternion correctly, manipulating it, and then applying it to the camera.
Edit:
Here is what I have tried to do so far.
// This is how I set it up
Quaternion orientation = new Quaternion();
orientation.setFromAxis(Vector3.Y, 45);
// This is how I am trying to update the rotations
public void rotateX(float amount)
{
Quaternion temp = new Quaternion();
temp.set(Vector3.X, amount);
orientation.mul(temp);
}
public void rotateY(float amount)
{
Quaternion temp = new Quaternion();
temp.set(Vector3.Y, amount);
orientation.mul(temp);
}
public void updateCamera()
{
// This is where I am unsure how to apply the rotations to the camera
// I think I should update the view and projection matrices?
camera.view.mul(orientation);
...
}