class Camera
{
public:
Camera() = default;
glm::vec3 cameraPos = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 cameraRot = glm::vec3(0.0f, 0.0f, 0.0f);
float FOV = 100.0f;
float zFAR = 100.0f;
float zNEAR = 0.01f;
float aspect = 1.0f;
glm::mat4 projection;
glm::mat4 view;
void update()
{
glm::vec3 cameraFront;
cameraFront.x = cos(glm::radians(cameraRot.x)) * cos(glm::radians(cameraRot.y));
cameraFront.y = sin(glm::radians(cameraRot.x));
cameraFront.z = cos(glm::radians(cameraRot.x)) * sin(glm::radians(cameraRot.y));
cameraFront = glm::normalize(cameraFront);
glm::vec3 worldUp = glm::vec3(0.0f, 1.0f, 0.0f);
glm::mat4 rollMatrix = glm::rotate(glm::mat4(1.0f), cameraRot.z, cameraFront);
glm::vec3 cameraUp = glm::normalize(glm::vec3(rollMatrix * glm::vec4(worldUp, 0.0f)));
projection = glm::perspective(glm::radians(FOV), aspect, zNEAR, zFAR);
view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp);
}
void update(int width, int height)
{
aspect = (float)width / (float)height;
update();
}
void cameraMatrix(Shader& shader)
{
glm::mat4 camMatrix;
camMatrix = projection * view;
shader.bind();
shader.setMat4("camMat", camMatrix);
shader.unbind();
}
};
any problem with this?
why my mesh disapeared when i multilple the gl_position with the camMat
