Game Development Reference
In-Depth Information
In a normal game, the human view is responsible for the sound manager, drawing
the world, and grabbing user input. The editor view is simpler in one way, not need-
ing a sound system, but more complicated since it receives input from the C# side of
things. The following code is in Source\Editor\EditorGameView.cpp:
EditorHumanView::EditorHumanView(shared_ptr<IRenderer> renderer)
: HumanView(renderer)
{}
void EditorHumanView::VOnUpdate( unsigned long deltaMilliseconds )
{
// Much like TeapotWarsView::VOnUpdate, except
// we only have one controller in the editor
HumanView::VOnUpdate( deltaMilliseconds );
if (m_pFreeCameraController)
{
m_pFreeCameraController->OnUpdate(deltaMilliseconds);
}
}
This is similar to, but simpler than, the parallel functions in the TeapotWarsHuman-
View class. Both call into the HumanView class, which creates the 3D scene, attaches
a camera, and registers delegates for events. The only real difference between the two
is TeapotWarsHumanView attaches a main menu for choosing the level and setting
up other game parameters. VOnUpdate() is also very simple, only calling Human-
View::OnUpdate() and ticking the camera controller.
Here
'
s what the view does when a new level is loaded:
bool EditorHumanView::VLoadGameDelegate(TiXmlElement* pLevelData)
{
if (!HumanView::VLoadGameDelegate(pLevelData))
return false;
// The MovementController is hooked up to the keyboard and mouse
// handlers, since this is our primary method for moving the camera around.
m_pFreeCameraController.reset(
GCC_NEW MovementController(m_pCamera, 90, 0, true));
m_pCamera->ClearTarget();
m_KeyboardHandler = m_pFreeCameraController;
m_PointerHandler = m_pFreeCameraController;
Search WWH ::




Custom Search