Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6800 in orxonox.OLD


Ignore:
Timestamp:
Jan 27, 2006, 4:40:37 PM (18 years ago)
Author:
bensch
Message:

trunk: hover functionality

Location:
trunk/src/world_entities/space_ships
Files:
2 edited

Legend:

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

    r6799 r6800  
    9797  this->getWeaponManager()->changeWeaponConfig(1);
    9898  dynamic_cast<Element2D*>(this->getWeaponManager()->getFixedTarget())->setVisibility( false);
     99
     100  this->loadModel("models/ships/hoverglider_mainbody.obj");
    99101}
    100102
     
    126128
    127129  // cameraissue
     130  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    128131  this->cameraNode.setParent(this);
    129132  this->cameraNode.setParentMode(PNODE_ALL);
     
    131134
    132135  // rotors
    133   this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    134   this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    135 
    136   this->topRotor.setParent(this);
    137   this->tailRotor.setParent(this);
    138 
    139   this->topRotor.setRelCoor(Vector(-0.877,0.627,0));
    140   this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068));
    141   this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0)));
    142 
    143   this->loadModel("models/ships/rotor.obj",1.0,3);
    144   this->loadModel("models/ships/rotor.obj",0.2,4);
     136  this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     137  this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     138
     139  this->rotorNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     140  this->rotorNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
     141
     142  this->wingNodeLeft.setParent(this);
     143  this->wingNodeRight.setParent(this);
     144
     145  this->wingNodeLeft.setRelCoor(-1, .5, -.5);
     146  this->wingNodeRight.setRelCoor(-1, .5, .5);
     147
     148  this->rotorNodeLeft.setParent(&this->wingNodeLeft);
     149  this->rotorNodeRight.setParent(&this->wingNodeRight);
     150
     151  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
     152  this->loadModel("models/ships/hoverglider_rotor.obj", 1.0f, 4);
    145153
    146154
     
    259267void Hover::collidesWith(WorldEntity* entity, const Vector& location)
    260268{
    261   if (entity->isA(CL_TURRET_POWER_UP))
    262   {
    263     this->ADDWEAPON();
    264     }
    265 //  PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z);
     269
    266270}
    267271
     
    283287
    284288  // rotorrotation
    285   this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
    286   this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
     289//   this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
     290//   this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0)));
    287291
    288292  // spaceship controlled movement
     
    451455
    452456    /* translate */
    453     glTranslatef (this->topRotor.getAbsCoor ().x,
    454                   this->topRotor.getAbsCoor ().y,
    455                   this->topRotor.getAbsCoor ().z);
    456     Vector tmpRot = this->topRotor.getAbsDir().getSpacialAxis();
    457     glRotatef (this->topRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
     457    glTranslatef (this->wingNodeLeft.getAbsCoor ().x,
     458                  this->wingNodeLeft.getAbsCoor ().y,
     459                  this->wingNodeLeft.getAbsCoor ().z);
     460    Vector tmpRot = this->wingNodeLeft.getAbsDir().getSpacialAxis();
     461    glRotatef (this->wingNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    458462    this->getModel(3)->draw();
    459 
    460     glPopMatrix ();
    461     glPushMatrix();
    462 
    463     /* translate */
    464     glTranslatef (this->tailRotor.getAbsCoor ().x,
    465                   this->tailRotor.getAbsCoor ().y,
    466                   this->tailRotor.getAbsCoor ().z);
    467     tmpRot = this->tailRotor.getAbsDir().getSpacialAxis();
    468     glRotatef (this->tailRotor.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    469     this->getModel(4)->draw();
    470463
    471464    glPopMatrix ();
     
    535528    }
    536529}
    537 
    538 #include "weapons/aiming_turret.h"
    539 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG
    540 void Hover::ADDWEAPON()
    541 {
    542   Weapon* turret = NULL;
    543 
    544   if ((float)rand()/RAND_MAX < .1)
    545   {
    546     //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET))
    547     {
    548       turret = new Turret();
    549       this->addWeapon(turret, 2);
    550       this->getWeaponManager()->changeWeaponConfig(2);
    551     }
    552   }
    553   else
    554   {
    555     //if (this->getWeaponManager()->hasFreeSlot(3))
    556     {
    557       turret = new AimingTurret();
    558       this->addWeapon(turret, 3);
    559 
    560       this->getWeaponManager()->changeWeaponConfig(3);
    561     }
    562   }
    563 
    564   if(turret != NULL)
    565   {
    566     turret->setName("Turret");
    567     turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);
    568   }
    569 }
  • trunk/src/world_entities/space_ships/hover.h

    r6799 r6800  
    1010#include "playable.h"
    1111
    12 
    1312class Hover : public Playable
    1413{
    15 
    1614  public:
    1715
     
    3735    virtual void process(const Event &event);
    3836
    39 
    40 
    4137  private:
    4238    void calculateVelocity(float time);
    4339    void weaponAction();
    44 
    45     // !! temporary !!
    46     void ADDWEAPON();
    4740
    4841    bool                  bUp;                //!< up button pressed.
     
    6457    //float                 cycle;              //!< hovercycle
    6558
    66     PNode                 topRotor;
    67     PNode                 tailRotor;
     59    PNode                 wingNodeLeft;
     60    PNode                 wingNodeRight;
     61    PNode                 rotorNodeLeft;
     62    PNode                 rotorNodeRight;
    6863
    6964    PNode                 cameraNode;
Note: See TracChangeset for help on using the changeset viewer.