Moving the camera around
Having a programmable camera is nice, but it still does not allow us to freely roam the scene. Let 's actually give our camera class the ability to be manipulated in real time, so that we can have the illusion of floating around the world:
enum class GL_Direction{ Up, Down, Left, Right, Forward, Back }; class GL_Camera { public: ... void MoveBy(GL_Direction l_dir, float l_amount); void OffsetLookBy(float l_speed, float l_x, float l_y); ... };
As you can see, we are going to use two methods for that: one for moving the camera, and another for rotating it. We are also defining a helpful enumeration of all six possible directions.
Moving a position vector is fairly simple. Assume we have a scalar value that represents the speed of the camera. If we multiply it by a direction vector, we get a proportional position change based on which direction the vector was pointed at, like so:
With that in mind, let us implement the MoveBy()
method:
void GL_Camera:...