Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7339 in orxonox.OLD for trunk/src/world_entities


Ignore:
Timestamp:
Apr 19, 2006, 2:11:14 AM (19 years ago)
Author:
bensch
Message:

some nice fixes

Location:
trunk/src/world_entities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/playable.cc

    r7338 r7339  
    128128 * @returns true on success, false otherwise
    129129 */
    130 bool Playable::setPlayMode(Playable::Playmode playmode)
     130bool Playable::setPlaymode(Playable::Playmode playmode)
    131131{
    132132  if (!this->playmodeSupported(playmode))
     
    302302
    303303/**
    304  * remove an event to the event list this Playable can capture.
     304 * @brief remove an event to the event list this Playable can capture.
    305305 * @param event the event to unregister.
    306306 */
     
    431431  return flags!=oldFlags;
    432432}
     433
     434
     435Playable::Playmode Playable::stringToPlaymode(const std::string& playmode)
     436{
     437  if (playmode == "Vertical")
     438    return Playable::Vertical;
     439  if (playmode == "Horizontal")
     440    return Playable::Horizontal;
     441  if (playmode == "FromBehind")
     442    return Playable::FromBehind;
     443  if (playmode == "Full3D")
     444    return Playable::Full3D;
     445
     446  return Playable::Full3D;
     447}
     448
     449const char* Playable::playmodeToString(Playable::Playmode playmode)
     450{
     451  switch(playmode)
     452  {
     453    case Playable::Vertical:
     454      return "Vertical";
     455    case Playable::Horizontal:
     456      return "Horizontal";
     457    case Playable::FromBehind:
     458      return "FromBehind";
     459    case Playable::Full3D:
     460      return "Full3D";
     461
     462    default:
     463      return "Full3D";
     464  }
     465
     466}
  • trunk/src/world_entities/playable.h

    r7338 r7339  
    6161  virtual void setCameraMode(unsigned int cameraMode = 0);
    6262  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
    63   bool setPlayMode(Playable::Playmode playmode);
     63  bool setPlaymode(Playable::Playmode playmode);
     64  Playable::Playmode getPlaymode() const { return this->playmode; };
    6465
    6566  virtual void collidesWith(WorldEntity* entity, const Vector& location);
     
    8384  inline int  getScore() { return this->score; }
    8485
     86
     87  // Transformations:
     88  static Playable::Playmode stringToPlaymode(const std::string& playmode);
     89  static const char* playmodeToString(Playable::Playmode playmode);
    8590protected:
    8691  Playable();
  • trunk/src/world_entities/player.h

    r6986 r7339  
    2929
    3030    bool              setPlayable(Playable* controllalble);
     31    bool              eject();
    3132    inline Playable*  getPlayable() const  { return this->playable; };
    32     bool              eject();
    3333
    3434    void              weaponConfigChanged();
     
    3939  private:
    4040    Playable*         playable;                  //!< The one we controll or NULL if none
    41     Hud               hud;                           //!< The HUD to be displayed for this Player.
     41    Hud               hud;                       //!< The HUD to be displayed for this Player.
    4242};
    4343
  • trunk/src/world_entities/space_ships/turbine_hover.cc

    r7337 r7339  
    4646
    4747/**
    48  * loads a TurbineHover information from a specified file.
     48 * @brief loads a TurbineHover information from a specified file.
    4949 * @param fileName the name of the File to load the turbine_hover from (absolute path)
    5050 */
     
    6464
    6565/**
    66  * creates a new Spaceship from Xml Data
     66 * @brief creates a new Spaceship from Xml Data
    6767 * @param root the xml element containing spaceship data
    6868
     
    9696
    9797/**
    98  * initializes a TurbineHover
     98 * @brief initializes a TurbineHover
    9999 */
    100100void TurbineHover::init()
     
    102102  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    103103  this->setClassID(CL_TURBINE_HOVER, "TurbineHover");
     104
     105  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
    104106
    105107  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
     
    275277void TurbineHover::tick (float dt)
    276278{
    277 //  this->debugNode(1);
     279  //  this->debugNode(1);
    278280  Playable::tick(dt);
    279281
     
    324326  }
    325327
    326   Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
    327 
    328   // this is the air friction (necessary for a smooth control)
    329   Vector damping = (this->velocity * this->airFriction);
    330 
    331 
    332   this->velocity += (accelerationDir - damping)* dt;
    333   this->shiftCoor (this->velocity * dt);
    334 
    335   // limit the maximum rotation speed.
    336   if (this->rotation != 0.0f)
    337   {
    338     float maxRot = 10.0 * dt;
    339     if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
    340     if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
    341     this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
    342 
    343     this->rotation = 0.0f;
    344   }
    345 
    346   this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    347 
    348   this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    349   this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
    350 
    351   this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
    352   this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
     328  switch(this->getPlaymode())
     329  {
     330    case Playable::Full3D:
     331      {
     332        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
     333
     334        // this is the air friction (necessary for a smooth control)
     335        Vector damping = (this->velocity * this->airFriction);
     336
     337
     338        this->velocity += (accelerationDir - damping)* dt;
     339        this->shiftCoor (this->velocity * dt);
     340
     341        // limit the maximum rotation speed.
     342        if (this->rotation != 0.0f)
     343        {
     344          float maxRot = 10.0 * dt;
     345          if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
     346          if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
     347          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
     348
     349          this->rotation = 0.0f;
     350        }
     351
     352        this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
     353
     354        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
     355        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5);
     356
     357        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
     358        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5);
     359      }
     360      break;
     361
     362    case Playable::Horizontal:
     363      {
     364        accel.z = 0.0;
     365        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
     366        accelerationDir.z = 0.0;
     367
     368        // this is the air friction (necessary for a smooth control)
     369        Vector damping = (this->velocity * this->airFriction);
     370
     371
     372        this->velocity += (accelerationDir - damping)* dt;
     373        this->shiftCoor (this->velocity * dt);
     374
     375        // limit the maximum rotation speed.
     376        if (this->rotation != 0.0f)
     377        {
     378          float maxRot = 10.0 * dt;
     379          if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
     380          if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
     381          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
     382
     383          this->rotation = 0.0f;
     384        }
     385
     386        this->setRelDirSoft(this->direction, 5);
     387
     388        this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
     389        this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation, Vector(0,0,1)), 5);
     390
     391        this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5);
     392        this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation, Vector(0,0,1)), 5);
     393      }
     394      break;
     395  }
    353396}
    354397
  • trunk/src/world_entities/space_ships/turbine_hover.h

    r7337 r7339  
    1717{
    1818  public:
    19 
    2019    TurbineHover(const std::string& fileName);
    2120    TurbineHover(const TiXmlElement* root = NULL);
Note: See TracChangeset for help on using the changeset viewer.