Professional Documents
Culture Documents
Camera Class
FPS Controls
Using different points of view can make a
single scene appear to be different worlds.
Every vertex in the world has a 4d coordinate:
<x, y, z, 1>.
This is the vertexs world location
gl_Position = worldCameraMat * worldLoc;
//(worldCameraMat = projectionMat * lookatMat)
//a 4x4 matrix transforms from world to screen
Translates the world
mat3 rotMat =
(mat3)yawPitchRoll(camRot.y, camRot.x, camRot.z);
mat4 perspectiveMat =
glm::perspective(fovy, aspect, zNear, zFar);
Member Data
Updating & Uploading
FPS Controls
4x4 Matrix
Well update this and upload it every frame
if (inputIsDown[GLFW_KEY_LEFT])
camVel += R * vec3(-1, 0, 0);
if (inputIsDown[GLFW_KEY_RIGHT])
camVel += R * vec3(1, 0, 0);
if (inputIsDown[GLFW_KEY_UP])
camVel += R * vec3(0, 0, -1);
if (inputIsDown[GLFW_KEY_DOWN])
camVel += R * vec3(0, 0, 1);