0
votes

How can I transform the camera left around the interface? Need to rotate the "eye" vector around the "up" vector!?.

void Transform::left(float degrees, vec3& eye, vec3& up) {
    float c = cosf(degrees * (pi / 180));
    float s = sinf(degrees * (pi / 180));
}

mat4 Transform::lookAt(vec3 eye, vec3 up) {

    glm::mat4 view = glm::lookAt(
        glm::vec3(eye.x, eye.y, eye.z),
        glm::vec3(0.0f, 0.0f, 0.0f),
        glm::vec3(up.x, up.y, up.z)
        );
    return view;
}
1

1 Answers

1
votes

Calculate a rotated eye vector by multiplying the rotation vector by the original, unrotated, eye vector and pass that into the lookAt function.

float rotX = cosf(angle * (pi / 180));
float rotY = sinf(angle * (pi / 180));

glm::vec3 rotatedEye = glm::vec3(eye.x * rotX , eye.y * rotY, eye.z)

glam::mat4 view = lookAt(rotatedEye, up);

Note that each time your camera vectors change you will need to calculate a new view matrix.