Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9052 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 3, 2006, 5:32:34 PM (18 years ago)
Author:
bensch
Message:

some crappy spacecraft work… maybe i will start again :/

Location:
branches/single_player_map/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/single_player_map/src/lib/event/event_handler.cc

    r9044 r9052  
    357357  else
    358358  {
    359 //      SDL_WM_GrabInput(SDL_GRAB_ON);
    360 //      SDL_ShowCursor(SDL_DISABLE);
     359     SDL_WM_GrabInput(SDL_GRAB_ON);
     360     SDL_ShowCursor(SDL_DISABLE);
    361361  }
    362362}
  • branches/single_player_map/src/world_entities/playable.cc

    r9047 r9052  
    9595
    9696  LoadParam(root, "abs-dir", this, Playable, setPlayDirection);
     97  LoadParam(root, "enter-radius", this, Playable, setEnterRadius)
     98      .describe("The Distance one can enter the ship from.");
    9799}
    98100
  • branches/single_player_map/src/world_entities/space_ships/spacecraft_2d.cc

    r9047 r9052  
    3636CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
    3737
    38 /**
    39  *  destructs the spacecraft_2d, deletes alocated memory
    40  */
    41 Spacecraft2D::~Spacecraft2D ()
    42 {
    43   this->setPlayer(NULL);
    44 }
    4538
    4639/**
     
    9386
    9487/**
     88 *  destructs the spacecraft_2d, deletes alocated memory
     89 */
     90Spacecraft2D::~Spacecraft2D ()
     91{
     92  this->setPlayer(NULL);
     93}
     94
     95/**
    9596 * @brief initializes a Spacecraft2D
    9697 */
     
    106107  mouseSensitivity = 0.005;
    107108
    108   this->rotorSpeed = 1000.0f;
    109   this->rotorCycle = 0.0f;
    110109  this->cameraLook = 0.0f;
    111110  this->rotation = 0.0f;
    112111  this->acceleration = 10.0f;
    113   this->airFriction = 2.0f;
     112  this->altitude = 0.0f;
    114113
    115114  this->setHealthMax(100);
     
    118117
    119118  // camera - issue
    120   this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
     119  this->travelNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    121120  //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
    122121  //this->cameraNode.setParent(this);
     
    179178  this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
    180179
    181   this->cameraNode.setRelCoor(1,5,0);
    182   this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    183   this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     180  this->travelNode.setRelCoor(0,0,0);
     181  //this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     182  //this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
    184183
    185184  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    206205}
    207206
     207void Spacecraft2D::setTravelDirecton(const Quaternion& rot, float speed)
     208{
     209  this->setPlayDirection(rot, speed);
     210}
     211
     212void Spacecraft2D::setTravelSpeed(float travelSpeed)
     213{
     214  this->travelSpeed = travelSpeed;
     215}
     216
     217
     218
    208219void Spacecraft2D::enter()
    209220{
     
    212223  if (State::getCameraNode != NULL)
    213224  {
    214     State::getCameraNode()->setParentSoft(&this->cameraNode);
    215     State::getCameraNode()->setRelCoorSoft(-10, 0,0);
    216     State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
     225    State::getCameraNode()->setParentSoft(&this->travelNode);
     226    State::getCameraNode()->setRelCoorSoft(-10, 50,0);
     227    State::getCameraTargetNode()->setParentSoft(&this->travelNode);
    217228  }
    218229}
     
    264275  // spaceship controlled movement
    265276  this->movement(dt);
    266   this->rotorCycle += this->rotorSpeed * dt;
    267277
    268278  // TRYING TO FIX PNode.
    269   this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
    270   this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
     279  //this->travelNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
     280  //this->travelNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    271281}
    272282
     
    297307    accel += Vector(0, 0, this->acceleration);
    298308  }
     309
    299310
    300311  switch(this->getPlaymode())
     
    305316
    306317        // this is the air friction (necessary for a smooth control)
    307         Vector damping = (this->velocity * this->airFriction);
    308 
    309 
    310         this->velocity += (accelerationDir - damping)* dt;
     318
     319        this->velocity += (accelerationDir)* dt;
    311320        this->shiftCoor (this->velocity * dt);
    312321
     
    334343
    335344        // this is the air friction (necessary for a smooth control)
    336         Vector damping = (this->velocity * this->airFriction);
    337 
    338 
    339         this->velocity += (accelerationDir - damping)* dt;
     345
     346
     347        this->velocity += (accelerationDir )* dt;
    340348        this->shiftCoor (this->velocity * dt);
    341349
     
    344352        {
    345353          float maxRot = 10.0 * dt;
    346           if (unlikely(this->rotation > maxRot)) this->rotation = maxRot;
    347           if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot;
     354          if (unlikely(this->rotation > 0.01 || this->rotation < 0.01)) this->rotation /=1.5;
    348355          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
    349356
     
    355362      break;
    356363
    357     case Playable::Vertical:
    358     {
    359       accel.z = 0;
    360       Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
    361       accelerationDir.z=0;
    362 
    363         // this is the air friction (necessary for a smooth control)
    364       Vector damping = (this->velocity * this->airFriction);
    365 
    366       this->velocity += (accelerationDir - damping)* dt;
    367       this->shiftCoor (this->velocity * dt);
    368 
    369       this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
    370     }
    371     break;
    372364    default:
    373365      PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
     
    403395
    404396    // rotate the Player around the y-axis
    405     this->rotation += xMouse;
     397    if (this->getPlaymode() == Playable::Full3D)
     398      this->rotation += xMouse;
    406399
    407400    this->cameraLook += yMouse;
  • branches/single_player_map/src/world_entities/space_ships/spacecraft_2d.h

    r9046 r9052  
    2323    virtual void loadParams(const TiXmlElement* root);
    2424    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
     25    void setTravelDirecton(const Quaternion& rot, float speed = 0.0);
     26    void setTravelSpeed(float travelSpeed);
     27
    2528    virtual void enter();
    2629    virtual void leave();
     30
     31
    2732
    2833    virtual void postSpawn();
     
    4853    float                 mouseSensitivity;   //!< the mouse sensitivity
    4954
    50     PNode                 cameraNode;
     55
     56
     57    PNode                 travelNode;
     58    float                 travelSpeed;
     59
    5160    float                 cameraLook;
    5261    float                 rotation;
     
    5463   // Vector                velocity;           //!< the velocity of the Spacecraft2D.
    5564    Quaternion            direction;          //!< the direction of the Spacecraft2D.
    56     float                 travelSpeed;        //!< the current speed of the Hove (to make soft movement)
    5765    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
    58     float                 airFriction;        //!< AirFriction.
     66    float                 maxSpeed;           //!< The Maximal speed of the Spacecraft2D.
    5967
    60     float                 rotorSpeed;         //!< the speed of the rotor.
    61     float                 rotorCycle;         //!< The Cycle the rotor is in.
    62 
    63     float                 airViscosity;
     68    float                 altitude;           //!< The height in the Entity.
    6469
    6570    ParticleEmitter*      burstEmitter;
Note: See TracChangeset for help on using the changeset viewer.