For this lab, you extending project 4 By adding a perspective projection and a camera class for easier navigation.
git checkout project4 git checkout -b project5 git push -u private project5The above commands assume that your personal remote is named private. Furthermore, your working directory must be clean (no uncommitted changes to files under version control), before checking out a new branch. If this is not the case, add and commit you changes locally before switching to a project3 branch.
Once you and your partner have pushed the project5 branches, you can each checkout a shared5 branch to follow your partner's changes
git fetch partner git checkout -b shared5 partner/project5Note you should not merge into either the master, shared, or shared5 branches as you will later be unable to push your changes. Make sure you are on either the working or project5 branch before merging.
git fetch origin git checkout project5 git merge origin/masterThere should only be one file camera.h. It shouldn't cause conflicts, but let me know if you get merge conflicts.
Use your camera class to specify the camera location for the vertex shader. Add a new uniform mat4 camera variable to your vertex shader. You may want to change the name view to projection as view is a bit more ambiguous in this lab. Your new shader can be as simple as follows
#version 130 uniform vec4 vColor; uniform mat4 model; uniform mat4 camera; uniform mat4 projection; in vec4 vPosition; in vec2 vTexture; out vec4 color; out vec2 texCoord; void main() { gl_Position = projection*camera*model*vPosition; color = vColor; texCoord = vTexture; }The old rotation stuff will be handled by your camera class.
Instead of m_view being a ortho projection, modify this to be a perspective projection. Feel free to change the name m_view to m_projection or something similar
Connect the m_view/m_projection matrix and your Camera's matrix to the appropriate uniform matrices in your vertex shader.
Add keyboard, mouse, or button controls to support the following:
Work incrementally. Start by separating m_view into m_projection and m_camera. You can use QMatrix4x4::perspective to handle m_projection. You can temporarily use QMatrix4x4::lookAt to setup a basic scene and test your shader, but ultimately you want to replace this with your Camera class and it's lookAt method which you implement.
Make small changes to your camera and projection matrices. They affect everything, so it is very easy to get completely lost. That's when reset comes in handy. You may want to implement that early.
You can use any of the 'basic' QMatrix4x4 methods. Methods like translate, rotate and scale, modify an existing matrix, by multiplying it on the right. You can use perspective. You cannot use lookAt. You must implement this yourself.