Changeset 232
- Timestamp:
- Nov 21, 2007, 12:44:02 AM (17 years ago)
- Location:
- code/branches/main_reto_vs05
- Files:
-
- 24 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto_vs05/scripts/weapon_framework.vcproj
r198 r232 42 42 Optimization="0" 43 43 AdditionalIncludeDirectories="..\src;"$(OGRE_HOME)\OgreMain\include";"$(OGRE_HOME)\Dependencies\include"" 44 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"44 PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS" 45 45 MinimalRebuild="true" 46 46 BasicRuntimeChecks="3" … … 223 223 </File> 224 224 <File 225 RelativePath="..\src\weapon\barrel_gun.cc" 226 > 227 </File> 228 <File 225 229 RelativePath="..\src\weapon\base_weapon.cpp" 226 230 > … … 236 240 <File 237 241 RelativePath="..\src\weapon\weapon_station.cc" 242 > 243 </File> 244 </Filter> 245 <Filter 246 Name="class_hierarchy" 247 > 248 <File 249 RelativePath="..\src\class_hierarchy\BaseObject.cc" 250 > 251 </File> 252 <File 253 RelativePath="..\src\class_hierarchy\ClassHierarchy.cc" 254 > 255 </File> 256 <File 257 RelativePath="..\src\class_hierarchy\Identifier.cc" 258 > 259 </File> 260 <File 261 RelativePath="..\src\class_hierarchy\IdentifierList.cc" 262 > 263 </File> 264 <File 265 RelativePath="..\src\class_hierarchy\ObjectList.cc" 266 > 267 </File> 268 <File 269 RelativePath="..\src\class_hierarchy\OrxonoxClass.cc" 270 > 271 </File> 272 <File 273 RelativePath="..\src\class_hierarchy\test1.cc" 274 > 275 </File> 276 <File 277 RelativePath="..\src\class_hierarchy\test2.cc" 278 > 279 </File> 280 <File 281 RelativePath="..\src\class_hierarchy\test3.cc" 238 282 > 239 283 </File> … … 285 329 </File> 286 330 <File 331 RelativePath="..\src\weapon\barrel_gun.h" 332 > 333 </File> 334 <File 287 335 RelativePath="..\src\weapon\base_weapon.h" 288 336 > … … 302 350 <File 303 351 RelativePath="..\src\weapon\weapon_station.h" 352 > 353 </File> 354 </Filter> 355 <Filter 356 Name="class_hierarchy" 357 > 358 <File 359 RelativePath="..\src\class_hierarchy\BaseObject.h" 360 > 361 </File> 362 <File 363 RelativePath="..\src\class_hierarchy\ClassHierarchy.h" 364 > 365 </File> 366 <File 367 RelativePath="..\src\class_hierarchy\Identifier.h" 368 > 369 </File> 370 <File 371 RelativePath="..\src\class_hierarchy\IdentifierIncludes.h" 372 > 373 </File> 374 <File 375 RelativePath="..\src\class_hierarchy\IdentifierList.h" 376 > 377 </File> 378 <File 379 RelativePath="..\src\class_hierarchy\ObjectList.h" 380 > 381 </File> 382 <File 383 RelativePath="..\src\class_hierarchy\OrxonoxClass.h" 384 > 385 </File> 386 <File 387 RelativePath="..\src\class_hierarchy\Test.h" 388 > 389 </File> 390 <File 391 RelativePath="..\src\class_hierarchy\test1.h" 392 > 393 </File> 394 <File 395 RelativePath="..\src\class_hierarchy\test2.h" 396 > 397 </File> 398 <File 399 RelativePath="..\src\class_hierarchy\test3.h" 304 400 > 305 401 </File> -
code/branches/main_reto_vs05/src/main.cc
r178 r232 31 31 #include "orxonox.h" 32 32 33 #include "class_hierarchy/BaseObject.h" 34 #include "class_hierarchy/Test.h" 35 #include "class_hierarchy/test1.h" 36 #include "class_hierarchy/test2.h" 37 #include "class_hierarchy/test3.h" 38 39 33 40 #ifdef __cplusplus 34 41 extern "C" { … … 43 50 #endif 44 51 { 52 #if 1 45 53 try { 46 54 // create an orxonox application and run it … … 60 68 } 61 69 70 #else 71 #define testandcout(code) \ 72 std::cout << #code << " " << code << "\n" 73 74 using namespace orxonox; 75 76 std::cout << "Test 8\n"; 77 78 std::cout << "1\n"; 79 Test1* test8_01 = new Test1; 80 Test1* asdf = new Test1; 81 Test3* test8_03 = new Test3; 82 test8_03->usefullClassesIsATest(test8_01); 83 84 std::cout << "2\n"; 85 Test2* test8_02 = new Test2; 86 test8_03->usefullClassesIsATest(test8_02); 87 88 std::cout << "3\n"; 89 test8_01->setUsefullClass1(Class(Test1)); 90 test8_01->setUsefullClass1(test8_02->getIdentifier()); 91 test8_01->setUsefullClass2(Class(Test2)); 92 test8_01->setUsefullClassOfTypeTest3(Class(Test3)); 93 test8_01->setUsefullClassOfTypeTest3(test8_03->getIdentifier()); 94 95 96 testandcout(test8_01->isA(Class(Test1))); 97 testandcout(test8_01->isA(Class(Test2))); 98 testandcout(test8_01->isA(Class(Test3))); 99 100 Test2* test8_04 = new Test2; 101 testandcout(test8_02->isA(Class(Test1))); 102 testandcout(test8_02->isA(Class(Test2))); 103 testandcout(test8_02->isA(Class(Test3))); 104 105 Test3* test8_05 = new Test3; 106 testandcout(test8_03->isA(Class(Test1))); 107 testandcout(test8_03->isA(Class(Test2))); 108 testandcout(test8_03->isA(Class(Test3))); 109 110 delete test8_01; 111 delete test8_02; 112 delete test8_03; 113 114 #endif 62 115 return 0; 63 116 } -
code/branches/main_reto_vs05/src/orxonox_prerequisites.h
r198 r232 47 47 class BulletManager; 48 48 class BaseWeapon; 49 class BarrelGun; 49 50 class WeaponStation; 50 51 -
code/branches/main_reto_vs05/src/orxonox_ship.cc
r198 r232 34 34 35 35 #include "inertial_node.h" 36 #include "run_manager.h" 36 37 #include "weapon/bullet.h" 37 38 #include "weapon/bullet_manager.h" 38 39 #include "weapon/weapon_station.h" 39 40 #include "weapon/base_weapon.h" 41 #include "weapon/barrel_gun.h" 40 42 #include "weapon/ammunition_dump.h" 41 43 … … 68 70 * @param mNode The scene node which the ship will be attached to later. 69 71 */ 70 OrxonoxShip::OrxonoxShip(SceneManager *sceneMgr, SceneNode *node, 71 BulletManager *bulletManager) 72 : sceneMgr_(sceneMgr), 73 baseThrust_(1000), currentThrust_(Vector3::ZERO), 74 objectCounter_(0), bulletManager_(bulletManager) 72 OrxonoxShip::OrxonoxShip(SceneNode *node) 73 : sceneMgr_(RunManager::getSingletonPtr()->getSceneManagerPtr()), 74 bulletManager_(RunManager::getSingletonPtr()->getBulletManagerPtr()), 75 baseThrust_(1000), currentThrust_(Vector3::ZERO), objectCounter_(0) 75 76 { 76 77 rootNode_ = new InertialNode(node, Vector3::ZERO); … … 115 116 116 117 // initialise weapon(s) 117 ammoDump_ = new AmmunitionDump(420); 118 ammoDump_->store(420); 118 ammoDump_ = new AmmunitionDump(); 119 ammoDump_->setDumpSize("Barrel", 1000); 120 ammoDump_->store("Barrel", 420); 119 121 120 122 InertialNode *mainWeaponNode = rootNode_->createChildNode(); 121 mainWeapon_ = new BaseWeapon(sceneMgr_, mainWeaponNode, 122 bulletManager_, ammoDump_); 123 mainWeapon_ = new BarrelGun(mainWeaponNode, ammoDump_); 123 124 124 125 railGunStation_ = new WeaponStation(4); … … 216 217 int OrxonoxShip::getAmmoStock() 217 218 { 218 return ammoDump_->getStockSize( );219 return ammoDump_->getStockSize("Barrel"); 219 220 } 220 221 -
code/branches/main_reto_vs05/src/orxonox_ship.h
r198 r232 40 40 { 41 41 public: 42 OrxonoxShip(Ogre::Scene Manager*, Ogre::SceneNode*, weapon::BulletManager*);42 OrxonoxShip(Ogre::SceneNode*); 43 43 virtual ~OrxonoxShip(); 44 44 -
code/branches/main_reto_vs05/src/run_manager.cc
r198 r232 60 60 #include "run_manager.h" 61 61 62 namespace Ogre { 63 using namespace orxonox; 64 template<> RunManager* Singleton<RunManager>::ms_Singleton = 0; 65 } 66 62 67 namespace orxonox { 63 68 using namespace Ogre; … … 77 82 */ 78 83 84 RunManager* RunManager::getSingletonPtr(void) 85 { 86 return ms_Singleton; 87 } 88 RunManager& RunManager::getSingleton(void) 89 { 90 assert( ms_Singleton ); return ( *ms_Singleton ); 91 } 92 79 93 80 94 /** … … 94 108 debugOverlay_(0), inputManager_(0), mouse_(0), keyboard_(0), joystick_(0) 95 109 { 96 97 110 // SETTING UP THE SCENE 98 111 99 112 // create one new SceneManger 100 sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, " backgroundScene_");113 sceneMgr_ = ogre_->getRoot()->createSceneManager(ST_GENERIC, "Orxonox Scene"); 101 114 102 115 // background scene (world objects, skybox, lights, etc.) … … 125 138 126 139 // Construct a new spaceship and give it the node 127 playerShip_ = new OrxonoxShip(sceneMgr_ , sceneMgr_->getRootSceneNode()128 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20)) , bulletManager_);140 playerShip_ = new OrxonoxShip(sceneMgr_->getRootSceneNode() 141 ->createChildSceneNode("ShipNode", Vector3(20, 20, 20))); 129 142 130 143 … … 274 287 // keep rendering 275 288 return true; 289 } 290 291 292 SceneManager& RunManager::getSceneManager() 293 { 294 return *sceneMgr_; 295 } 296 297 SceneManager* RunManager::getSceneManagerPtr() 298 { 299 return sceneMgr_; 300 } 301 302 BulletManager* RunManager::getBulletManagerPtr() 303 { 304 return bulletManager_; 305 } 306 307 int RunManager::getAmmunitionID(const Ogre::String &ammoName) 308 { 309 Ogre::String ammoTypes[] = { "Energy Cell", "Barrel", "Lead Shot" }; 310 int ammoTypesLength = 3; 311 312 for (int i = 0; i < ammoTypesLength; i++) 313 { 314 if (ammoTypes[i] == ammoName) 315 return i; 316 } 317 return -1; 318 } 319 320 int RunManager::getNumberOfAmmos() 321 { 322 return 3; 276 323 } 277 324 -
code/branches/main_reto_vs05/src/run_manager.h
r194 r232 33 33 #include "OgreWindowEventUtilities.h" 34 34 #include "OgreTextureManager.h" 35 #include "OgreSingleton.h" 35 36 36 37 #include <OIS/OISPrereqs.h> … … 43 44 // let the class inherit from WindowEventListener in order for the RunMgr 44 45 // to act as the central point of all the calcuations in Orxonox 45 class RunManager : Ogre::WindowEventListener 46 class RunManager : public Ogre::WindowEventListener, 47 public Ogre::Singleton<RunManager> 46 48 { 47 49 public: 48 50 RunManager(OgreControl*); 49 51 50 virtual ~RunManager(); 52 virtual ~RunManager(); 53 //void initialise(OgreControl*); 51 54 52 virtual bool tick(unsigned long, Ogre::Real); 55 bool tick(unsigned long, Ogre::Real); 56 57 Ogre::SceneManager& getSceneManager(); 58 59 Ogre::SceneManager* getSceneManagerPtr(); 60 61 weapon::BulletManager* getBulletManagerPtr(); 62 63 int getAmmunitionID(const Ogre::String&); 64 65 int getNumberOfAmmos(); 66 67 static RunManager& getSingleton(void); 68 69 static RunManager* getSingletonPtr(void); 70 53 71 54 72 protected: 55 v irtual void createCamera(void);73 void createCamera(void); 56 74 57 v irtual void createViewports(void);75 void createViewports(void); 58 76 59 77 … … 61 79 62 80 //Adjust mouse clipping area 63 v irtual void windowResized(Ogre::RenderWindow*);81 void windowResized(Ogre::RenderWindow*); 64 82 65 83 //Unattach OIS before window shutdown (very important under Linux) 66 v irtual void windowClosed(Ogre::RenderWindow*);84 void windowClosed(Ogre::RenderWindow*); 67 85 68 86 69 87 /** INPUT PROCESSING **/ 70 virtualbool processUnbufferedKeyInput();88 bool processUnbufferedKeyInput(); 71 89 72 virtualbool processUnbufferedMouseInput();90 bool processUnbufferedMouseInput(); 73 91 74 92 75 93 /** OUTPUT **/ 76 94 77 v irtual void updateStats(void);95 void updateStats(void); 78 96 79 v irtual void showDebugOverlay(bool);97 void showDebugOverlay(bool); 80 98 81 99 protected: -
code/branches/main_reto_vs05/src/weapon/ammunition_dump.cc
r198 r232 26 26 */ 27 27 28 #include "run_manager.h" 29 28 30 #include "ammunition_dump.h" 29 31 … … 32 34 namespace weapon { 33 35 34 AmmunitionDump::AmmunitionDump(int capacity) 35 : stock_(0), capacity_(capacity) 36 AmmunitionDump::AmmunitionDump() 37 : numberOfAmmos_(RunManager::getSingletonPtr()->getNumberOfAmmos()), 38 stock_(new int[numberOfAmmos_]), 39 capacity_(new int[numberOfAmmos_]) 36 40 { 41 for (int i = 0; i < numberOfAmmos_; i++) 42 { 43 stock_[i] = 0; 44 capacity_[i] = 0; 45 } 37 46 } 38 47 … … 40 49 AmmunitionDump::~AmmunitionDump() 41 50 { 51 if (stock_) 52 delete stock_; 53 if (capacity_) 54 delete capacity_; 55 } 56 57 void AmmunitionDump::setDumpSize(const Ogre::String &name, int size) 58 { 59 if (size < 0) 60 return; 61 int id = RunManager::getSingletonPtr()->getAmmunitionID(name); 62 if (id == -1) 63 return; 64 capacity_[id] = size; 42 65 } 43 66 44 67 45 void AmmunitionDump::store(int quantity)68 int AmmunitionDump::store(const Ogre::String &name, int quantity) 46 69 { 47 stock_ += quantity; 48 if (stock_ > capacity_) 49 stock_ = capacity_; 70 int id = RunManager::getSingletonPtr()->getAmmunitionID(name); 71 if (id == -1) 72 return quantity; 73 stock_[id] += quantity; 74 if (stock_[id] > capacity_[id]) 75 { 76 quantity = capacity_[id] - stock_[id]; 77 stock_[id] = capacity_[id]; 78 return quantity; 79 } 80 else 81 return 0; 50 82 } 51 83 52 84 53 int AmmunitionDump::getAmmunition( int quantity)85 int AmmunitionDump::getAmmunition(const Ogre::String &name, int quantity) 54 86 { 55 i f (stock_ >= quantity)56 {57 stock_ -= quantity;58 return quantity;59 }87 int id = RunManager::getSingletonPtr()->getAmmunitionID(name); 88 if (id == -1) 89 return 0; 90 if (stock_[id] >= quantity) 91 stock_[id] -= quantity; 60 92 else 61 93 { 62 quantity = stock_; 63 stock_ = 0; 64 return quantity; 94 quantity = stock_[id]; 95 stock_[id] = 0; 65 96 } 97 return quantity; 66 98 } 67 99 68 100 69 int AmmunitionDump::getStockSize( )101 int AmmunitionDump::getStockSize(const Ogre::String &name) 70 102 { 71 return stock_; 103 int id = RunManager::getSingletonPtr()->getAmmunitionID(name); 104 if (id = -1) 105 return -1; 106 return stock_[id]; 72 107 } 73 108 } -
code/branches/main_reto_vs05/src/weapon/ammunition_dump.h
r198 r232 41 41 { 42 42 public: 43 AmmunitionDump(int capacity);43 AmmunitionDump(); 44 44 ~AmmunitionDump(); 45 45 46 void s tore(int quantiy);46 void setDumpSize(const Ogre::String &name, int size); 47 47 48 int getAmmunition(int quantity);48 int store(const Ogre::String &name, int quantiy); 49 49 50 int getStockSize(); 50 int getAmmunition(const Ogre::String &name, int quantity); 51 52 int getStockSize(const Ogre::String &name); 51 53 52 54 protected: 53 int stock_; 54 int capacity_; 55 int numberOfAmmos_; 56 int *stock_; 57 int *capacity_; 55 58 56 59 protected: -
code/branches/main_reto_vs05/src/weapon/base_weapon.cpp
r198 r232 37 37 #include "inertial_node.h" 38 38 #include "ammunition_dump.h" 39 #include "run_manager.h" 39 40 40 41 #include "base_weapon.h" … … 45 46 using namespace Ogre; 46 47 47 BaseWeapon::BaseWeapon(SceneManager *sceneMgr, InertialNode *node, 48 BulletManager *bulletManager, AmmunitionDump *ammoDump) 49 : sceneMgr_(sceneMgr), node_(node), 50 bulletCounter_(0), primaryFireRequest_(false), currentState_(IDLE), 51 secondaryFireRequest_(false), 52 bulletManager_(bulletManager), secondaryFired_(false), 53 timeSinceNextActionAdded_(0), actionAdded_(false), nextAction_(NOTHING), 54 name_("Base Weapon"), primaryFirePower_(100), secondaryFirePower_(500), 55 primaryFiringRate_(10), secondaryFiringRate_(2), primaryBulletSpeed_(1000), 56 secondaryBulletSpeed_(500), magazineSize_(25), ammoDump_(ammoDump) 48 BaseWeapon::BaseWeapon(InertialNode *node, AmmunitionDump *ammoDump) 49 : sceneMgr_(RunManager::getSingletonPtr()->getSceneManagerPtr()), node_(node), 50 bulletCounter_(0), primaryFireRequest_(false), currentState_(IDLE), 51 secondaryFireRequest_(false), 52 bulletManager_(RunManager::getSingletonPtr()->getBulletManagerPtr()), 53 secondaryFired_(false), 54 timeSinceNextActionAdded_(0), actionAdded_(false), nextAction_(NOTHING), 55 ammoDump_(ammoDump) 57 56 { 58 leftAmmo_ = ammoDump_->getAmmunition(magazineSize_);57 leftAmmo_ = 0; 59 58 } 60 59 … … 84 83 85 84 86 void BaseWeapon::primaryFire()87 {88 if (leftAmmo_ < 1)89 {90 currentState_ = IDLE;91 return;92 }93 94 SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(95 node_->getSceneNode()->getWorldPosition(),96 node_->getSceneNode()->getWorldOrientation());97 98 Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"99 + StringConverter::toString(bulletCounter_++), "Barrel.mesh");100 101 Vector3 speed = (temp->getOrientation() * Vector3(0, 0, -1))102 .normalisedCopy() * primaryBulletSpeed_;103 speed += node_->getWorldSpeed();104 105 temp->setScale(Vector3(1, 1, 1) * 4);106 temp->yaw(Degree(-90));107 108 bulletManager_->addBullet(new Bullet(temp, bulletEntity, speed));109 110 --leftAmmo_;111 }112 113 114 void BaseWeapon::primaryFiring(unsigned int time)115 {116 if (time > 100)117 {118 currentState_ = IDLE;119 }120 }121 122 123 85 void BaseWeapon::secondaryFireRequest() 124 86 { 125 87 secondaryFireRequest_ = true; 126 }127 128 129 void BaseWeapon::secondaryFire()130 {131 if (leftAmmo_ < 5)132 {133 currentState_ = IDLE;134 return;135 }136 137 SceneNode *temp = sceneMgr_->getRootSceneNode()->createChildSceneNode(138 node_->getSceneNode()->getWorldPosition(),139 node_->getSceneNode()->getWorldOrientation());140 141 Entity* bulletEntity = sceneMgr_->createEntity("BulletEntity"142 + StringConverter::toString(bulletCounter_++), "Barrel.mesh");143 144 Vector3 speed = (temp->getOrientation() * Vector3(0, 0, -1))145 .normalisedCopy() * secondaryBulletSpeed_*0.5;146 speed += node_->getWorldSpeed();147 148 temp->setScale(Vector3(1, 1, 1) * 10);149 temp->yaw(Degree(-90));150 151 bulletManager_->addBullet(new Bullet(temp, bulletEntity, speed));152 153 leftAmmo_ -= 5;154 }155 156 157 void BaseWeapon::secondaryFiring(unsigned int time)158 {159 if (time > 250)160 currentState_ = IDLE;161 88 } 162 89 … … 181 108 { 182 109 case RELOAD: 183 leftAmmo_ += ammoDump_->getAmmunition( magazineSize_ - leftAmmo_);110 leftAmmo_ += ammoDump_->getAmmunition("Barrel", magazineSize_ - leftAmmo_); 184 111 break; 185 112 -
code/branches/main_reto_vs05/src/weapon/base_weapon.h
r198 r232 58 58 59 59 public: 60 BaseWeapon(Ogre::SceneManager*, InertialNode*, BulletManager*, 61 AmmunitionDump*); 60 BaseWeapon(InertialNode*, AmmunitionDump*); 62 61 virtual ~BaseWeapon(); 63 62 … … 73 72 74 73 protected: 75 v oid primaryFire();74 virtual void primaryFire() = 0; 76 75 77 v oid primaryFiring(unsigned int);76 virtual void primaryFiring(unsigned int) = 0; 78 77 79 v oid secondaryFire();78 virtual void secondaryFire() = 0; 80 79 81 v oid secondaryFiring(unsigned int);80 virtual void secondaryFiring(unsigned int) = 0; 82 81 83 82 public:
Note: See TracChangeset
for help on using the changeset viewer.