I am learning some inner workings of game engine development and have come across this confusion. To explain what I am trying to do, I want to start with an example:
Let's say that I have an object (e.g a cube) that moves forward. I want to add a camera that follows the object (e.g 3rd person camera). For this, my SceneGraph looks like this (XML type markup to show hierarchy):
<GameObjectNode mesh="cube.mesh" position="(0.0, 0.0, z)"> <CameraNode position="(0.0, 10.0, 15.0)" /> </GameObjectNode>
This allows my camera to "follow" the cube because the camera's world transformation is:
camera.worldTransform = parent->worldTransform * camera.transform;
This all makes sense in terms of transformations in the world. However, when it comes to view transforms, this is where I am confused about. All the hardware APIs use have something like
setViewTransform(float *matView, float *matProjection) and the view matrix is typically calculated using something like
lookAt(vec3 eye, vec3 center, vec3 up).
My camera transform is calculated using the formula above. However, the lookAt matrix function requires position as vector (eye). Is there a way to create lookAt matrix function that does not use vectors to get position? Or is there a way to extract position from transform matrix?
EDIT: I was able to use the worldTransform matrix last "vector" to get the position vector as that's where the translation parameters were. However, I still have a problem with center one because the the center vector must also be calculated using matrix transform. How can I get the coordinates of center in relationship to Eye.