Improving first person camera and implementing third person camera
Posted
by
brainydexter
on Game Development
See other posts from Game Development
or by brainydexter
Published on 2011-02-04T18:32:08Z
Indexed on
2011/02/04
23:35 UTC
Read the original article
Hit count: 711
I want to improve upon my first person camera implementation and extend it to, so the user can toggle between third person/first person view.
My current setup: draw()::
glPushMatrix();
m_pCamera->ApplyCameraTransform();
// Render gameObjects
glPopMatrix();
Camera is strongly coupled to the player, so much so, that it is a friend of player. This is what the Camera::ApplyCameraTransform looks like:
glm::mat4 l_TransformationMatrix;
m_pPlayer->m_pTransformation->GetTransformation(l_TransformationMatrix, false);
l_TransformationMatrix = glm::core::function::matrix::inverse(l_TransformationMatrix);
glMultMatrixf(glm::value_ptr(l_TransformationMatrix));
So, I take the player's transformation matrix and invert it to yield First person camera view.
Since, Third person camera view is just a 'translated' first person view behind the player; what would be a good way to improve upon this (keeping in mind that I will be extending it to Third person camera as well.
Thanks
© Game Development or respective owner