Public Member Functions | |
TutorialApplication () | |
~TutorialApplication () | |
Protected Member Functions | |
void | chooseSceneManager () |
void | createFrameListener () |
void | createCamera () |
void | createViewports () |
void | createUnitTypes () |
void | createScene (void) |
void | _createTeamA () |
void | _createTeamB () |
void | _createTeamC () |
Private Attributes | |
Client * | mClient |
Game * | mGame |
LevelStatusVisualizer * | mLevelVisual |
Definition at line 62 of file main.cpp.
TutorialApplication::TutorialApplication | ( | ) | [inline] |
Definition at line 80 of file main.cpp.
References mClient, mGame, mLevelVisual, and mSceneRayQuery.
00081 { 00082 mClient = NULL; 00083 mGame = NULL; 00084 00085 // 00086 // HACKS 00087 // 00088 mSceneRayQuery = NULL; 00089 mLevelVisual = NULL; 00090 }
TutorialApplication::~TutorialApplication | ( | ) | [inline] |
Definition at line 92 of file main.cpp.
References mClient, mGame, mLevelVisual, and mSceneRayQuery.
00093 { 00094 // 00095 // HACKS 00096 // 00097 delete mLevelVisual; 00098 if ( mSceneRayQuery ) 00099 mSceneMgr->destroyQuery ( mSceneRayQuery ); 00100 00101 delete UnitTypeManager::getSingletonPtr(); 00102 00103 delete mClient; 00104 delete mGame; 00105 }
void TutorialApplication::_createTeamA | ( | ) | [inline, protected] |
Definition at line 198 of file main.cpp.
References BUILDING_COUNT, ASR::Team::createBuilding(), ASR::Client::createTeam(), ASR::Team::createUnit(), mClient, mSceneRayQuery, TERRAIN_QUERY_HEIGHT, UNIT_COUNT, and UNIT_SCALE.
Referenced by createScene().
00199 { 00200 Team* teamA = mClient->createTeam ( "TeamA", ColourValue ( 1.0, 0.0, 0.0 ) ); 00201 //mTeamA->setSpatialGridSize ( 100, 100 ); 00202 00203 // Create some buildings 00204 for ( int i = 0; i < BUILDING_COUNT; i++ ) 00205 { 00206 float x = 300 + (i % (int)sqrt(double(BUILDING_COUNT) ) ) * 290; 00207 float z = 800 + (i / (int)sqrt(double(BUILDING_COUNT) ) ) * 250; 00208 00209 Ray barracksRay ( Vector3(x, TERRAIN_QUERY_HEIGHT, z), Vector3::NEGATIVE_UNIT_Y ); 00210 mSceneRayQuery->setRay ( barracksRay ); 00211 RaySceneQueryResult& result = mSceneRayQuery->execute(); 00212 RaySceneQueryResult::iterator iter = result.begin(); 00213 if ( iter != result.end() ) 00214 { 00215 if ( iter->worldFragment ) 00216 { 00217 // TODO 00218 // Make the buildings themselves figure out where they should be placed (y-axis) 00219 Real terrainHeight = iter->worldFragment->singleIntersection.y; 00220 Building* building = teamA->createBuilding( "blacksmith.mesh", Vector3(x, terrainHeight, z ) ); 00221 } 00222 iter++; 00223 } 00224 } 00225 00226 // Create some units 00227 for ( int i = 0; i < UNIT_COUNT; i++ ) 00228 { 00229 Unit* unit = teamA->createUnit ( *(UnitTypeManager::getSingleton().getUnitType ( "robot" )) ); 00230 unit->scale ( UNIT_SCALE, UNIT_SCALE, UNIT_SCALE ); 00231 unit->translate( Vector3((i % (int)sqrt(double(UNIT_COUNT))) * 60 + 10, 120, (i / (int)sqrt((double)UNIT_COUNT)) * 60 + 10) ); 00232 } 00233 00234 /* 00235 Unit* unit; 00236 00237 unit = teamA->createUnit ( *(UnitTypeManager::getSingleton().getUnitType ( "robot" )) ); 00238 unit->translate( Vector3( 10, 0, 10 ) ); 00239 00240 unit = teamA->createUnit ( *(UnitTypeManager::getSingleton().getUnitType ( "robot" )) ); 00241 unit->translate( Vector3 (500, 0, 10) ); 00242 */ 00243 }
void TutorialApplication::_createTeamB | ( | ) | [inline, protected] |
Definition at line 247 of file main.cpp.
References ASR::Level::createTeam(), ASR::Team::createUnit(), UNIT_COUNT, and UNIT_SCALE.
Referenced by createScene().
00248 { 00249 Level* curLevel = Game::getSingleton ().getLevel (); 00250 Team* teamB = curLevel->createTeam ( "TeamB", ColourValue ( 0.0, 0.0, 1.0 ) ); 00251 00252 for ( int i = 0; i < UNIT_COUNT * 3; i++ ) 00253 { 00254 Unit* unit = teamB->createUnit ( *(UnitTypeManager::getSingleton ().getUnitType ( "robot" ) ) ); 00255 unit->scale ( UNIT_SCALE, UNIT_SCALE, UNIT_SCALE ); 00256 unit->translate( Vector3( 100, 120, i * 60) ); 00257 } 00258 00259 for ( int i = 0; i < UNIT_COUNT * 2; i++ ) 00260 { 00261 Unit* unit = teamB->createUnit ( *(UnitTypeManager::getSingleton ().getUnitType ( "robot" ) ) ); 00262 unit->scale ( UNIT_SCALE, UNIT_SCALE, UNIT_SCALE ); 00263 unit->translate( Vector3( 200, 120, i * 60) ); 00264 } 00265 00266 /* 00267 Unit* unit; 00268 00269 unit = teamB->createUnit ( *(UnitTypeManager::getSingleton().getUnitType ( "robot" )) ); 00270 unit->translate( Vector3( 120, 0, 10 ) ); 00271 */ 00272 }
void TutorialApplication::_createTeamC | ( | ) | [inline, protected] |
Definition at line 276 of file main.cpp.
References ASR::Level::createTeam(), ASR::Team::createUnit(), and UNIT_SCALE.
Referenced by createScene().
00277 { 00278 Level* curLevel = Game::getSingleton ().getLevel (); 00279 Team* teamC = curLevel->createTeam ( "TeamC", ColourValue ( 0.0, 1.0, 1.0 ) ); 00280 00281 for ( int i = 0; i < 10; i++ ) 00282 { 00283 Unit* unit = teamC->createUnit ( *(UnitTypeManager::getSingleton ().getUnitType ( "robot" ) ) ); 00284 unit->scale ( UNIT_SCALE, UNIT_SCALE, UNIT_SCALE ); 00285 unit->translate( Vector3(300, 120, i * 60) ); 00286 } 00287 }
void TutorialApplication::chooseSceneManager | ( | ) | [inline, protected] |
Definition at line 111 of file main.cpp.
References ASR::Game::createLevel(), mClient, mGame, and mSceneRayQuery.
00112 { 00113 mSceneMgr = mRoot->createSceneManager( "TerrainSceneManager" ); 00114 mSceneMgr->setShadowTechnique( SHADOWTYPE_STENCIL_MODULATIVE ); 00115 00116 //mSceneMgr->setAmbientLight( ColourValue( 1.0f, 0.874, 0.6356 ) ); 00117 mSceneRayQuery = mSceneMgr->createRayQuery( Ray() ); 00118 00119 mGame = new Game ( mSceneMgr, mWindow ); 00120 mGame->createLevel (); 00121 00122 mClient = new Client ( mWindow ); 00123 }
void TutorialApplication::createCamera | ( | ) | [inline, protected] |
Definition at line 142 of file main.cpp.
References ASR::Client::createCamera(), and mClient.
00143 { 00144 mClient->createCamera (); 00145 }
void TutorialApplication::createFrameListener | ( | ) | [inline, protected] |
Definition at line 127 of file main.cpp.
References ASR::Level::getTeam(), and mLevelVisual.
00128 { 00129 Level* lev = Game::getSingleton ().getLevel (); 00130 Team* teamA = lev->getTeam ( 0 ); 00131 SceneNode* baseNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "levelVisualizer" ); 00132 00133 mLevelVisual = new LevelStatusVisualizer ( Game::getSingleton ().getLevel() ); 00134 00135 Game::getSingleton ().addUpdater ( mLevelVisual ); 00136 00137 //mRTSCamera->getCamera()->setPolygonMode ( Ogre::PM_WIREFRAME ); 00138 }
void TutorialApplication::createScene | ( | void | ) | [inline, protected] |
Definition at line 168 of file main.cpp.
References _createTeamA(), _createTeamB(), _createTeamC(), createUnitTypes(), ASR::Level::rebuild(), ASR::Level::setDimensions(), and ASR::Level::setWorldDimensions().
00169 { 00170 mSceneMgr->setWorldGeometry( "ASR_terrain.cfg" ); 00171 00172 createUnitTypes (); 00173 00174 Level* curLevel = Game::getSingleton ().getLevel (); 00175 00176 curLevel->setWorldDimensions ( 2560, 2560 ); 00177 //mLevel->setCellSize ( 10.0f, 10.0f ); 00178 //curLevel->setCellSize ( 10.0f, 10.0f ); 00179 curLevel->setDimensions ( 256, 256 ); 00180 curLevel->rebuild (); 00181 00182 _createTeamA (); 00183 _createTeamB (); 00184 _createTeamC (); 00185 00186 mSceneMgr->setAmbientLight( ColourValue( 0.5, 0.5, 0.5 ) ); 00187 00188 Light* light = mSceneMgr->createLight( "Light1" ); 00189 light->setType( Light::LT_DIRECTIONAL ); 00190 light->setDirection ( Vector3(-0.5, -1, -1 ) ); 00191 //light->setPosition( Vector3(50, 250, 100) ); 00192 light->setDiffuseColour( 1.0, 1.0, 1.0 ); 00193 light->setSpecularColour( 1.0, 1.0, 1.0 ); 00194 }
void TutorialApplication::createUnitTypes | ( | ) | [inline, protected] |
Definition at line 156 of file main.cpp.
References ASR::UnitTypeManager::createUnitType(), and ASR::UnitType::setMesh().
Referenced by createScene().
00157 { 00158 // TODO 00159 // Load these in from a file instead of hard coding them 00160 new UnitTypeManager(); 00161 UnitTypeManager* typeMgr = UnitTypeManager::getSingletonPtr(); 00162 UnitType* robotType = typeMgr->createUnitType( "robot" ); 00163 robotType->setMesh( "lizardman.mesh" ); 00164 }
void TutorialApplication::createViewports | ( | ) | [inline, protected] |
Client* TutorialApplication::mClient [private] |
Definition at line 67 of file main.cpp.
Referenced by _createTeamA(), chooseSceneManager(), createCamera(), TutorialApplication(), and ~TutorialApplication().
Game* TutorialApplication::mGame [private] |
Definition at line 68 of file main.cpp.
Referenced by chooseSceneManager(), TutorialApplication(), and ~TutorialApplication().
Definition at line 73 of file main.cpp.
Referenced by createFrameListener(), TutorialApplication(), and ~TutorialApplication().