Game Development Reference
In-Depth Information
The VRender() method calls the Frustum::Render() method to draw the cam-
era ' s viewable area, but only if the debug camera is enabled:
HRESULT CameraNode::VRender(Scene *pScene)
{
if (m_DebugCamera)
{
m_Frustum.Render();
}
return S_OK;
}
Create a Special Camera for Debugging
When I was working on Thief: Deadly Shadows, it was really useful to have a special
debug
camera
that moved about the scene without affecting the code that was being checked against the
camera. The process worked like this: I would key in a special debug command, and the debug camera
would be enabled. I could free-fly it around the scene, and the
real
camera was visible because the
view frustum of the normal camera would draw, and I could visually debug problems like third-person
movement issues, scene culling issues, and so on. It was kind of like having a backstage pass to the
internals of the game!
normal
The VOnRestore() chain can be called when the player resizes the game screen to a
different resolution. If this happens, the camera view frustum shape will probably
change, and so will the projection matrix, which is really a Mat4x4 structure that
describes the shape of the view frustum in a transform matrix. Notice the D3DXMa-
trixPerspectiveFovLH call
the LH stands for
left-handed.
virtual HRESULT CameraNode::VOnRestore(Scene *pScene)
{
m_Frustum.SetAspect(DXUTGetWindowWidth() / (FLOAT) DXUTGetWindowHeight());
D3DXMatrixPerspectiveFovLH( &m_Projection, m_Frustum.m_Fov,
m_Frustum.m_Aspect, m_Frustum.m_Near, m_Frustum.m_Far );
return S_OK;
}
The camera
'
s SetView() method is called just before rendering the scene. It reads
the
from world
transform stored in the scene node and sends that into the render-
ing device:
HRESULT CameraNode::SetView(Scene *pScene)
{
//If there is a target, make sure the camera is
//rigidly attached right behind the target
 
Search WWH ::




Custom Search