Search code examples
javaopengllwjgl

How to calculate a camera up vector in world space


I am trying to calculate the camera up vector with these variables:

private Vector3f targetPosition = new Vector3f(0, 0, 0);
private Vector3f camPosition = new Vector3f(0, 0, 0);
private float pitch = 20; // y rotation \\
private float yaw = 0; // x rotation \\

How could I achieve this?


Solution

  • Up Vector in world space is just up or whatever you want to define as "up". Normally up is just a positive y:

    private const Vector3f UP = new Vector3f(0.0f, 1.0f, 0.0f);