Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 3, 2006, 4:05:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/branches/single_player_map: added Spacecraft_2d

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/world_entities/space_ships/spacecraft_2d.cc

    r9045 r9046  
    102102  this->setClassID(CL_SPACECRAFT_2D, "Spacecraft2D");
    103103
    104   this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal | Playable::Vertical);
    105 
    106   this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
    107   this->loadModel("models/ships/hoverglider_turbine.obj", 1.0f, 4);
    108   this->loadModel("models/ships/hoverglider_turbine_rotors.obj", 1.0f, 5);
    109 
    110   bForward = bBackward = bLeft = bRight = bAscend = bDescend = false;
     104  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
     105
     106
     107  bForward = bBackward = bLeft = bRight = false;
    111108  mouseSensitivity = 0.005;
    112109
     
    123120
    124121  // camera - issue
    125   this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    126122  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    127123  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
     
    129125
    130126  // rotors
    131   this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT );
    132   this->wingNodeLeft.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    133   this->wingNodeLeft.setParent(this);
    134   this->wingNodeLeft.setRelCoor(-1.5, -.3, -1.0);
    135   this->rotorNodeLeft.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    136   this->rotorNodeLeft.setParent(&this->wingNodeLeft);
    137   this->rotorNodeLeft.setRelCoor(0, 1.0, -2.3);
    138 
    139   this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    140   this->wingNodeRight.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    141   this->wingNodeRight.setParent(this);
    142   this->wingNodeRight.setRelCoor(-1.5, -0.3, 1.0);
    143   this->rotorNodeRight.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    144   this->rotorNodeRight.setParent(&this->wingNodeRight);
    145   this->rotorNodeRight.setRelCoor(0, 1.0, 2.3);
    146 
    147127  // PARTICLES
    148   this->burstEmitter[0] = new DotEmitter(200, 5.0, .01);
    149   this->burstEmitter[0]->setParent(&this->rotorNodeLeft);
    150   this->burstEmitter[0]->setRelCoor(0, -0.7, 0);
    151   this->burstEmitter[0]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
    152   this->burstEmitter[0]->setName("Spacecraft2D_Burst_emitter_Left");
    153 
    154   this->burstEmitter[1] = new DotEmitter(200, 5.0, .01);
    155   this->burstEmitter[1]->setParent(&this->rotorNodeRight);
    156   this->burstEmitter[1]->setRelCoor(0, -0.7, 0);
    157   this->burstEmitter[1]->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
    158   this->burstEmitter[1]->setName("Spacecraft2D_Burst_emitter_Right");
     128  this->burstEmitter = new DotEmitter(200, 5.0, .01);
     129  this->burstEmitter->setParent(this);
     130  this->burstEmitter->setRelCoor(0, -0.7, 0);
     131  this->burstEmitter->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
     132  this->burstEmitter->setName("Spacecraft2D_Burst_emitter_Left");
    159133
    160134
    161135  this->burstSystem = new SpriteParticles(1000);
    162   this->burstSystem->addEmitter(this->burstEmitter[0]);
    163   this->burstSystem->addEmitter(this->burstEmitter[1]);
     136  this->burstSystem->addEmitter(this->burstEmitter);
    164137  this->burstSystem->setName("SpaceShip_Burst_System");
    165138  ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
     
    192165  this->getWeaponManager().setSlotCount(5);
    193166
    194   this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750), &this->wingNodeLeft);
     167  this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750));
    195168  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    196169
    197   this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750), &this->wingNodeRight);
     170  this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750));
    198171  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    199172
     
    216189  registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
    217190  registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
    218   registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
    219   registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
    220191  //registerVar( new SynchronizeableQuaternion( &direction, &direction, "direction", PERMISSION_OWNER ) );
    221192  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
     
    327298  {
    328299    accel += Vector(0, 0, this->acceleration);
    329   }
    330 
    331   if (this->bAscend )
    332   {
    333     accel += Vector(0, this->acceleration, 0);
    334   }
    335   if (this->bDescend )
    336   {
    337     accel -= Vector(0, this->acceleration, 0);
    338300  }
    339301
     
    364326        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    365327
    366         this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    367         this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
    368 
    369         this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    370         this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
    371328      }
    372329      break;
     
    397354
    398355        this->setRelDirSoft(this->direction, 5);
    399 
    400         this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    401         this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation, Vector(0,0,1)), 5);
    402 
    403         this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    404         this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation, Vector(0,0,1)), 5);
    405356      }
    406357      break;
     
    419370
    420371      this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    421 
    422       this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    423       this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
    424 
    425       this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    426       this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
    427372    }
    428373    break;
     
    435380void Spacecraft2D::draw() const
    436381{
    437   Vector tmpRot;
    438382  WorldEntity::draw();
    439 
    440   glPushMatrix();
    441   /// LEFT SIDE
    442   glTranslatef (this->wingNodeLeft.getAbsCoor ().x,
    443                 this->wingNodeLeft.getAbsCoor ().y,
    444                 this->wingNodeLeft.getAbsCoor ().z);
    445   tmpRot = this->wingNodeLeft.getAbsDir().getSpacialAxis();
    446   glRotatef (this->wingNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    447   this->getModel(3)->draw();
    448   glPopMatrix ();
    449 
    450   glPushMatrix();
    451   glTranslatef (this->rotorNodeLeft.getAbsCoor ().x,
    452                 this->rotorNodeLeft.getAbsCoor ().y,
    453                 this->rotorNodeLeft.getAbsCoor ().z);
    454   tmpRot = this->rotorNodeLeft.getAbsDir().getSpacialAxis();
    455   glRotatef (this->rotorNodeLeft.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    456   this->getModel(4)->draw();
    457   glRotatef(this->rotorCycle, 0,1,0);
    458   this->getModel(5)->draw();
    459   glPopMatrix ();
    460 
    461   /// RIGHT SIDE
    462   glPushMatrix();
    463   glTranslatef (this->wingNodeRight.getAbsCoor ().x,
    464                 this->wingNodeRight.getAbsCoor ().y,
    465                 this->wingNodeRight.getAbsCoor ().z);
    466   tmpRot = this->wingNodeRight.getAbsDir().getSpacialAxis();
    467   glRotatef (this->wingNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    468   glScalef(1,1,-1);
    469   this->getModel(3)->draw();
    470   glPopMatrix ();
    471 
    472   glPushMatrix();
    473   glTranslatef (this->rotorNodeRight.getAbsCoor ().x,
    474                 this->rotorNodeRight.getAbsCoor ().y,
    475                 this->rotorNodeRight.getAbsCoor ().z);
    476   tmpRot = this->rotorNodeRight.getAbsDir().getSpacialAxis();
    477   glRotatef (this->rotorNodeRight.getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
    478   glScalef(1,1,-1);
    479   this->getModel(4)->draw();
    480   glRotatef(this->rotorCycle, 0,1,0);
    481   this->getModel(5)->draw();
    482   glPopMatrix ();
    483383}
    484384
     
    494394  else if( event.type == KeyMapper::PEV_RIGHT)
    495395    this->bRight = event.bPressed;
    496   else if( event.type == KeyMapper::PEV_UP)
    497     this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
    498   else if( event.type == KeyMapper::PEV_DOWN)
    499     this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
    500396  else if( event.type == KeyMapper::PEV_FORWARD)
    501397    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
Note: See TracChangeset for help on using the changeset viewer.