I'm trying to make a basic FPS camera view matrix, using position, pitch/yaw, and worldUp. Currently, my camera's view matrix is just a plain rotation matrix (made with yaw/pitch/roll) and the result is the view appears to be looking down the negative Z-axis, which in my case is my floor. Most tutorials I can find recommend making a view matrix by passing in an "eye" and "target" vector. But this isn't a desirable setup for an FPS camera where I only know the position and angles (pitch/yaw/roll) of the camera -- I don't have a specific point in mind that I want the camera to be focused on!
I'm using OpenGL as a renderer, but I don't want to use GLM as I'd wish/hope to understand how to implement this without helper libs. Also, my meshes and world matrices are made so that Z is my worldUp, X as forward, and Y as right/left. That might seem odd, but old Unreal engine games used this setup and I'm just accustomed to it for mapping/modding.
As mentioned my view matrix is currently looking down at the floor, but I'm not surprised that it's wrong because I've never incorporated or multiplied my worldUp vector into the matrix, and I don't understand how to.
So that's my question: How exactly do I incorporate my worldUp vector into my rotation matrix, to turn it into a proper view matrix -- or better yet, what is the proper method for constructing a view matrix when you have exactly these variables: 1.) Camera Position (XYZ) 2.) World Up vector ("0,0,1" for me) 3.) Camera Pitch/Yaw/Roll (Really only need Pitch/Yaw!)
I've been going through loads of tutorials and I can't find what I'm looking for. This is how I've started, but all it is is a normal rotation matrix, so honestly a full methodology would be really appreciated as I've been pulling my hair out over this for a week now. Thank you for any guidance on this.
MAT4X4F mrol; MAT4X4F mpit; MAT4X4F myaw; float cr, cp, cy; float sr, sp, sy; cr = cos(_cam_roll); cp = cos(_cam_pitch); cy = cos(_cam_yaw); sr = sin(_cam_roll); sp = sin(_cam_pitch); sy = sin(_cam_yaw); // Yaw (about Z-axis) myaw.m = cy; myaw.m = -sy; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = sy; myaw.m = cy; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 1.0f; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 0.0f; myaw.m = 1.0f; // Pitch (about Y-axis) mpit.m = cp; mpit.m = 0.0f; mpit.m = sp; mpit.m = 0.0f; mpit.m = 0.0f; mpit.m = 1.0f; mpit.m = 0.0f; mpit.m = 0.0f; mpit.m = -sp; mpit.m = 0.0f; mpit.m = cp; mpit.m = 0.0f; mpit.m = 0.0f; mpit.m = 0.0f; mpit.m = 0.0f; mpit.m = 1.0f; // Roll (about X-axis) mrol.m = 1.0f; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = cr; mrol.m = -sr; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = sr; mrol.m = cr; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = 0.0f; mrol.m = 1.0f; _cam_matrix = myaw * mpit * mrol;