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
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
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
00032 mCamNode->setPosition ( 100, 500, 350 );
00033
00034
00035 mPitchNode->pitch ( Ogre::Degree(-60) );
00036 }
00037
00038
00039
00040 RTSCamera::~RTSCamera(void)
00041 {
00042
00043 mPitchNode->detachObject ( mCamera );
00044 mSceneMgr->destroyCamera ( mCamera );
00045
00046
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 }