Now that our GDW team has been making progress on tool development for our capstone project, I will explain what we've done and how it works.
The first and probably most important tool we have been working on is the comprehensive model viewer. The purpose of this tool is to give team members a preview of any game assets with textures, lighting/shading, and other post-processing effects. This ensures the assets are up to the required quality level as well as form a cohesive theme with all other assets within the game.
After starting with a base project using the Project Generator, the first step was to set up a camera system. Since this tool is a model viewer, it was sufficient to set up a TwoLoc MayaCam. The code is very simple:
mCam = mMgr->createCamera("MainCamera");
mCam->setAspectRatio(Ogre::Real(OGRE_CORE->mViewport->getActualWidth()) /
Ogre::Real(OGRE_CORE->mViewport->getActualHeight()));
mCam->setNearClipDistance(1.0f);
mCam->setFarClipDistance(10000.0f);
OGRE_CORE->mViewport->setCamera(mCam);
OGRE_CORE->mViewport->setBackgroundColour(Ogre::ColourValue(0.1f, 0.1f, 0.1f));
mCam->setPosition(0.0f, 20.0f, 0.5f);
mCam->lookAt(0, 0, 0);
OGRE_CORE->AttachMayaCam(mCam);
Going through this, the code creates a MayaCam, then sets its various viewing parameters. It then tells Ogre to use this camera and sets a default background colour to display the object on. Now that the camera exists and is activated, you then set up the "physical" properties of the camera, such as where it is and which direction it is looking. Finally, Ogre attaches the camera to the scene and it is ready to use. The maya cam uses the default control scheme as Maya so users are familiar with it.
Additionally we implemented code to switch between solid and wireframe model views.
void FBXViewer::cameraMode()
{
if(mCam->getPolygonMode()==PM_SOLID)
mCam->setPolygonMode(PM_WIREFRAME);
else
mCam->setPolygonMode(PM_SOLID);
}
Using the provided FBX Loader and myGUI, we can browse through files and load any model that we want. To properly view the model, we added in a default light which enables the viewer to clearly see whichever object is loaded.
Ogre::Light * FBXViewer::createLight()
{
//////////////////////////////////////////////////////////////////////////
//Adding in the light pointLight
Ogre::Light *pointLight = mMgr->createLight("pointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(Ogre::Vector3(0.0f,5.0f,0.0f));
pointLight->setDiffuseColour(1.0, 0.0, 0.0);
pointLight->setSpecularColour(1.0, 0.0, 0.0);
return pointLight;
}
The code is simple; it creates a light and initializes the standard light settings. Now with an fbx loader, lighting, camera, and viewing modes, we have all the basic feature we need for a model viewer. In the coming week our team will be adding more complex features such as shaders, multi-object loading, multiple viewports, and other small tweaks.