Special camera matrix construction


I am designing a game engine as hobby project in my free time. The game will be a third-person adventure game, in the style of Diablo and Fallout, where the camera will be orbiting above the player avatar. The player is allowed to zoom in and out the camera, and rotate it around Y-axis and X-axis.

Can you help me to develop an algorithm which calculates the camera matrix? See the following diagram:

Hi Henri,

This is exactly what the gluLookAt function is for.

gluLookAt( camX, camY, camZ, orgX, orgY, orgZ, 0.0, 1.0, 0.0 )

R = distancecos(beta)
camX = R
camY = distancesin(beta)+orgY
camZ = R

This page describes how the matrix is being constructed.



Thanks for this Nico. I got similar solution by myself also.