Changeset 6002 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Dec 9, 2005, 5:30:44 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/helicopter.cc
r5999 r6002 10 10 11 11 ### File Specific: 12 main-programmer: Benjamin Knecht12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 14 … … 17 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 18 18 19 #include "executor/executor.h" 20 #include "space_ship.h" 19 #include "helicopter.h" 21 20 22 21 #include "objModel.h" … … 36 35 using namespace std; 37 36 38 CREATE_FACTORY( SpaceShip, CL_SPACE_SHIP);37 CREATE_FACTORY(Helicopter, CL_HELICOPTER); 39 38 40 39 /** 41 40 * creates the controlable Spaceship 42 41 */ 43 SpaceShip::SpaceShip()42 Helicopter::Helicopter() 44 43 { 45 44 this->init(); … … 49 48 * destructs the spaceship, deletes alocated memory 50 49 */ 51 SpaceShip::~SpaceShip()50 Helicopter::~Helicopter () 52 51 { 53 52 } … … 57 56 * @param fileName the name of the File to load the spaceship from (absolute path) 58 57 */ 59 SpaceShip::SpaceShip(const char* fileName)58 Helicopter::Helicopter(const char* fileName) 60 59 { 61 60 this->init(); … … 64 63 if(!doc.LoadFile()) 65 64 { 66 PRINTF(2)("Loading file %s failed for spaceship.\n", fileName);65 PRINTF(2)("Loading file %s failed for Helicopter.\n", fileName); 67 66 return; 68 67 } … … 77 76 @todo add more parameters to load 78 77 */ 79 SpaceShip::SpaceShip(const TiXmlElement* root)78 Helicopter::Helicopter(const TiXmlElement* root) 80 79 { 81 80 this->init(); … … 105 104 * initializes a Spaceship 106 105 */ 107 void SpaceShip::init()106 void Helicopter::init() 108 107 { 109 108 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 110 this->setClassID(CL_ SPACE_SHIP, "SpaceShip");109 this->setClassID(CL_HELICOPTER, "Helicopter"); 111 110 112 111 PRINTF(4)("SPACESHIP INIT\n"); 112 113 this->loadModel("models/ships/helicopter_high.obj", 1.0, 0); 114 this->loadModel("models/ships/helicopter_medium.obj", 1.0, 1); 115 this->loadModel("models/ships/helicopter_low.obj", 1.0, 2); 113 116 114 117 EventHandler::getInstance()->grabEvents(true); … … 177 180 178 181 /** 179 * loads the Settings of a SpaceShipfrom an XML-element.182 * loads the Settings of a Helicopter from an XML-element. 180 183 * @param root the XML-element to load the Spaceship's properties from 181 184 */ 182 void SpaceShip::loadParams(const TiXmlElement* root)185 void Helicopter::loadParams(const TiXmlElement* root) 183 186 { 184 187 static_cast<WorldEntity*>(this)->loadParams(root); … … 190 193 * @param weapon to add 191 194 */ 192 void SpaceShip::addWeapon(Weapon* weapon)195 void Helicopter::addWeapon(Weapon* weapon) 193 196 { 194 197 this->getWeaponManager()->addWeapon(weapon); … … 200 203 * @param weapon to remove 201 204 */ 202 void SpaceShip::removeWeapon(Weapon* weapon)205 void Helicopter::removeWeapon(Weapon* weapon) 203 206 { 204 207 this->getWeaponManager()->removeWeapon(weapon); … … 206 209 207 210 /** 208 * effect that occurs after the SpaceShipis spawned209 */ 210 void SpaceShip::postSpawn ()211 * effect that occurs after the Helicopter is spawned 212 */ 213 void Helicopter::postSpawn () 211 214 { 212 215 //setCollision(new CollisionCluster(1.0, Vector(0,0,0))); … … 216 219 * the action occuring if the spaceship left the game 217 220 */ 218 void SpaceShip::leftWorld ()221 void Helicopter::leftWorld () 219 222 {} 220 223 221 WorldEntity* ref = NULL;222 224 /** 223 225 * this function is called, when two entities collide … … 226 228 * Implement behaviour like damage application or other miscellaneous collision stuff in this function 227 229 */ 228 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)229 { 230 if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)230 void Helicopter::collidesWith(WorldEntity* entity, const Vector& location) 231 { 232 if (entity->isA(CL_TURRET_POWER_UP)) 231 233 { 232 234 this->ADDWEAPON(); 233 ref = entity;234 235 } 235 236 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 236 237 } 237 238 238 /** 239 * draws the spaceship after transforming it. 240 */ 241 void SpaceShip::draw () const 242 { 243 glMatrixMode(GL_MODELVIEW); 244 glPushMatrix(); 245 /* translate */ 246 glTranslatef (this->getAbsCoor ().x, 247 this->getAbsCoor ().y, 248 this->getAbsCoor ().z); 249 /* rotate */ 250 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 251 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 252 this->getModel()->draw(); 253 glPopMatrix(); 254 255 this->getWeaponManager()->draw(); 256 257 //this->debug(0); 258 } 239 259 240 260 241 /** … … 262 243 * @param time The timespan passed since last update 263 244 */ 264 void SpaceShip::tick (float time)245 void Helicopter::tick (float time) 265 246 { 266 247 cycle += time; … … 290 271 * @param time the timeslice since the last frame 291 272 */ 292 void SpaceShip::calculateVelocity (float time)273 void Helicopter::calculateVelocity (float time) 293 274 { 294 275 Vector accel(0.0, 0.0, 0.0); … … 372 353 * weapon manipulation by the player 373 354 */ 374 void SpaceShip::weaponAction()355 void Helicopter::weaponAction() 375 356 { 376 357 if( this->bFire) … … 383 364 * @todo switch statement ?? 384 365 */ 385 void SpaceShip::process(const Event &event)366 void Helicopter::process(const Event &event) 386 367 { 387 368 … … 412 393 #include "weapons/aiming_turret.h" 413 394 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG 414 void SpaceShip::ADDWEAPON()395 void Helicopter::ADDWEAPON() 415 396 { 416 397 Weapon* turret = NULL; -
trunk/src/world_entities/space_ships/helicopter.h
r5999 r6002 1 1 2 2 /*! 3 * @file space_ship.h4 * Implements the Control of a Spaceship3 * @file helicopter.h 4 * Implements the Control of a Helicopter 5 5 */ 6 6 7 #ifndef _ SPACE_SHIP_H8 #define _ SPACE_SHIP_H7 #ifndef _HELICOPTER_H 8 #define _HELICOPTER_H 9 9 10 10 #include "playable.h" 11 11 12 template<class T> class tList;13 class Vector;14 class Event;15 12 16 class SpaceShip: public Playable13 class Helicopter : public Playable 17 14 { 18 15 19 16 public: 20 17 21 SpaceShip();22 SpaceShip(const char* fileName);23 SpaceShip(const TiXmlElement* root);24 virtual ~ SpaceShip();18 Helicopter(); 19 Helicopter(const char* fileName); 20 Helicopter(const TiXmlElement* root); 21 virtual ~Helicopter(); 25 22 26 23 void init(); … … 35 32 virtual void collidesWith(WorldEntity* entity, const Vector& location); 36 33 virtual void tick(float time); 37 virtual void draw() const;38 34 39 35 virtual void process(const Event &event); … … 71 67 }; 72 68 73 #endif /* _ SPACE_SHIPS_H */69 #endif /* _HELICOPTERS_H */ -
trunk/src/world_entities/space_ships/space_ship.cc
r5994 r6002 20 20 #include "space_ship.h" 21 21 22 #include "objModel.h"23 22 #include "resource_manager.h" 24 23 -
trunk/src/world_entities/world_entity.cc
r5996 r6002 27 27 #include "obb_tree.h" 28 28 29 #include "state.h" 30 29 31 using namespace std; 30 32 … … 95 97 PRINTF(4)("fetching %s\n", fileName); 96 98 if (scaling == 1.0) 97 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN) );99 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber); 98 100 else 99 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling) );100 101 this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber); 102 if (modelNumber == 0) 101 103 this->buildObbTree(4); 102 104 } … … 227 229 void WorldEntity::draw() const 228 230 { 229 glMatrixMode(GL_MODELVIEW); 230 glPushMatrix(); 231 float matrix[4][4]; 232 233 /* translate */ 234 glTranslatef (this->getAbsCoor ().x, 235 this->getAbsCoor ().y, 236 this->getAbsCoor ().z); 237 /* rotate */ // FIXME: devise a new Way to rotate this 238 this->getAbsDir ().matrix (matrix); 239 glMultMatrixf((float*)matrix); 240 241 if (this->models[0]) 242 this->models[0]->draw(); 243 glPopMatrix(); 231 if (!this->models.empty()) 232 { 233 glMatrixMode(GL_MODELVIEW); 234 glPushMatrix(); 235 float matrix[4][4]; 236 237 /* translate */ 238 glTranslatef (this->getAbsCoor ().x, 239 this->getAbsCoor ().y, 240 this->getAbsCoor ().z); 241 /* rotate */ // FIXME: devise a new Way to rotate this 242 this->getAbsDir ().matrix (matrix); 243 glMultMatrixf((float*)matrix); 244 245 float cameraDistance = (State::getCamera()->getAbsCoor() - this->getAbsCoor()).len(); 246 if (this->isA(CL_HELICOPTER)) 247 printf("Test %f %d\n", cameraDistance, this->models.size()); 248 if (cameraDistance > 100 && this->models.size() >= 3 && this->models[2] != NULL) 249 { 250 if (this->isA(CL_HELICOPTER))printf("====== 2 ===\n"); 251 this->models[2]->draw(); 252 } 253 else if (cameraDistance > 50 && this->models.size() >= 2 && this->models[1] != NULL) 254 { 255 if (this->isA(CL_HELICOPTER))printf("====== 1 ===\n"); 256 this->models[1]->draw(); 257 } 258 else if (this->models.size() >= 1 && this->models[0] != NULL) 259 { 260 if (this->isA(CL_HELICOPTER))printf("====== 0 ===\n"); 261 this->models[0]->draw(); 262 } 263 glPopMatrix(); 264 } 244 265 } 245 266
Note: See TracChangeset
for help on using the changeset viewer.