Quaternion Camera

Posted by Alex_Hyzer_Kenoyer on Game Development See other posts from Game Development or by Alex_Hyzer_Kenoyer
Published on 2012-12-16T13:56:58Z Indexed on 2012/12/17 5:14 UTC
Read the original article Hit count: 392

Filed under:
|
|
|
|

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);
    ...
}

© Game Development or respective owner

Related posts about java

Related posts about android