D:/simple_rts/src/RTSCamera.cpp

Go to the documentation of this file.
00001 #include "RTSCamera.h"
00002 
00003 #include "OgreSceneManager.h"
00004 #include "OgreCamera.h"
00005 #include "OgreSceneNode.h"
00006 #include "OgreMath.h"
00007 
00008 #include <assert.h>
00009 
00010 // HACK
00011 using namespace Ogre;
00012 
00013 
00014 // ----------------------------------------------------------------------------
00015 namespace ASR
00016 {
00017         // ----------------------------------------------------------------------------
00018         RTSCamera::RTSCamera( SceneManager* sceneMgr )
00019                 : mSceneMgr ( sceneMgr )
00020         {
00021                 assert ( sceneMgr != NULL );
00022 
00023                 // Create the structure for the camera nodes
00024                 mCamera = sceneMgr->createCamera ( "playerCam" );
00025                 mCamera->setNearClipDistance ( 5.0f );
00026 
00027                 mCamNode = sceneMgr->getRootSceneNode()->createChildSceneNode( "cameraNode" );
00028                 mPitchNode = mCamNode->createChildSceneNode( "cameraPitchNode" );
00029                 mPitchNode->attachObject ( mCamera );
00030 
00031                 // HACK
00032                 mCamNode->setPosition ( 100, 500, 350 );
00033                 //mCamNode->setPosition ( 250, 1500, 1000 );
00034                 //mCamera->setDirection ( 0, 0, -1 );
00035                 mPitchNode->pitch ( Ogre::Degree(-60) );
00036         }
00037 
00038 
00039         // ----------------------------------------------------------------------------
00040         RTSCamera::~RTSCamera(void)
00041         {
00042                 // Remove the camera
00043                 mPitchNode->detachObject ( mCamera );
00044                 mSceneMgr->destroyCamera ( mCamera );
00045 
00046                 // Destroy the node structure
00047                 mCamNode->getParentSceneNode()->removeAndDestroyChild( mCamNode->getName() );
00048         }
00049 
00050 
00051         // ----------------------------------------------------------------------------
00052         void RTSCamera::translate( const Vector3& vec )
00053         {
00054                 mCamNode->translate ( vec );
00055         }
00056 
00057 
00058         // ----------------------------------------------------------------------------
00059         void RTSCamera::pitch ( const Radian& angle )
00060         {
00061                 mPitchNode->pitch ( angle );
00062         }
00063 
00064 
00065         // ----------------------------------------------------------------------------
00066         void RTSCamera::setAspectRatio( Real ratio )
00067         {
00068                 mCamera->setAspectRatio( ratio );
00069         }
00070 }

Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7