Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2005, 5:30:44 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: implemented the helicopter

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/helicopter.cc

    r5999 r6002  
    1010
    1111### File Specific:
    12    main-programmer: Benjamin Knecht
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414
     
    1717#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
    1818
    19 #include "executor/executor.h"
    20 #include "space_ship.h"
     19#include "helicopter.h"
    2120
    2221#include "objModel.h"
     
    3635using namespace std;
    3736
    38 CREATE_FACTORY(SpaceShip, CL_SPACE_SHIP);
     37CREATE_FACTORY(Helicopter, CL_HELICOPTER);
    3938
    4039/**
    4140 *  creates the controlable Spaceship
    4241 */
    43 SpaceShip::SpaceShip()
     42Helicopter::Helicopter()
    4443{
    4544  this->init();
     
    4948 *  destructs the spaceship, deletes alocated memory
    5049 */
    51 SpaceShip::~SpaceShip ()
     50Helicopter::~Helicopter ()
    5251{
    5352}
     
    5756 * @param fileName the name of the File to load the spaceship from (absolute path)
    5857 */
    59 SpaceShip::SpaceShip(const char* fileName)
     58Helicopter::Helicopter(const char* fileName)
    6059{
    6160  this->init();
     
    6463  if(!doc.LoadFile())
    6564  {
    66     PRINTF(2)("Loading file %s failed for spaceship.\n", fileName);
     65    PRINTF(2)("Loading file %s failed for Helicopter.\n", fileName);
    6766    return;
    6867  }
     
    7776   @todo add more parameters to load
    7877*/
    79 SpaceShip::SpaceShip(const TiXmlElement* root)
     78Helicopter::Helicopter(const TiXmlElement* root)
    8079{
    8180  this->init();
     
    105104 * initializes a Spaceship
    106105 */
    107 void SpaceShip::init()
     106void Helicopter::init()
    108107{
    109108//  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    110   this->setClassID(CL_SPACE_SHIP, "SpaceShip");
     109  this->setClassID(CL_HELICOPTER, "Helicopter");
    111110
    112111  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);
    113116
    114117  EventHandler::getInstance()->grabEvents(true);
     
    177180
    178181/**
    179  * loads the Settings of a SpaceShip from an XML-element.
     182 * loads the Settings of a Helicopter from an XML-element.
    180183 * @param root the XML-element to load the Spaceship's properties from
    181184 */
    182 void SpaceShip::loadParams(const TiXmlElement* root)
     185void Helicopter::loadParams(const TiXmlElement* root)
    183186{
    184187  static_cast<WorldEntity*>(this)->loadParams(root);
     
    190193 * @param weapon to add
    191194*/
    192 void SpaceShip::addWeapon(Weapon* weapon)
     195void Helicopter::addWeapon(Weapon* weapon)
    193196{
    194197  this->getWeaponManager()->addWeapon(weapon);
     
    200203 * @param weapon to remove
    201204*/
    202 void SpaceShip::removeWeapon(Weapon* weapon)
     205void Helicopter::removeWeapon(Weapon* weapon)
    203206{
    204207  this->getWeaponManager()->removeWeapon(weapon);
     
    206209
    207210/**
    208  *  effect that occurs after the SpaceShip is spawned
    209 */
    210 void SpaceShip::postSpawn ()
     211 *  effect that occurs after the Helicopter is spawned
     212*/
     213void Helicopter::postSpawn ()
    211214{
    212215  //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
     
    216219 *  the action occuring if the spaceship left the game
    217220*/
    218 void SpaceShip::leftWorld ()
     221void Helicopter::leftWorld ()
    219222{}
    220223
    221 WorldEntity* ref = NULL;
    222224/**
    223225 *  this function is called, when two entities collide
     
    226228 * Implement behaviour like damage application or other miscellaneous collision stuff in this function
    227229 */
    228 void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
    229 {
    230   if (entity->isA(CL_TURRET_POWER_UP) && entity != ref)
     230void Helicopter::collidesWith(WorldEntity* entity, const Vector& location)
     231{
     232  if (entity->isA(CL_TURRET_POWER_UP))
    231233  {
    232234    this->ADDWEAPON();
    233     ref = entity;
    234235    }
    235236//  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
    236237}
    237238
    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
    259240
    260241/**
     
    262243 * @param time The timespan passed since last update
    263244*/
    264 void SpaceShip::tick (float time)
     245void Helicopter::tick (float time)
    265246{
    266247     cycle += time;
     
    290271 * @param time the timeslice since the last frame
    291272*/
    292 void SpaceShip::calculateVelocity (float time)
     273void Helicopter::calculateVelocity (float time)
    293274{
    294275  Vector accel(0.0, 0.0, 0.0);
     
    372353 * weapon manipulation by the player
    373354*/
    374 void SpaceShip::weaponAction()
     355void Helicopter::weaponAction()
    375356{
    376357  if( this->bFire)
     
    383364 * @todo switch statement ??
    384365 */
    385 void SpaceShip::process(const Event &event)
     366void Helicopter::process(const Event &event)
    386367{
    387368
     
    412393#include "weapons/aiming_turret.h"
    413394// FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
    414 void SpaceShip::ADDWEAPON()
     395void Helicopter::ADDWEAPON()
    415396{
    416397  Weapon* turret = NULL;
Note: See TracChangeset for help on using the changeset viewer.