Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10662 in orxonox.OLD for branches/vs-enhencements/src


Ignore:
Timestamp:
May 24, 2007, 3:54:26 PM (18 years ago)
Author:
rennerc
Message:

Vertical playmode for SpaceShip

Location:
branches/vs-enhencements/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/vs-enhencements/src/util/track/track.h

    r10642 r10662  
    5050   int                   nodeCount;            //!< The count of points this Track has.
    5151   Curve*                curve;                //!< The Curve of this Track
     52   
     53   ActionBox*            getActionBox(){ return this->actionBox; }
    5254
    5355 private:
  • branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc

    r10657 r10662  
    4040  this->pitch = 0.0f;
    4141  this->dPitch = 0.0;
     42 
     43  this->maxSpeed = 10;
     44  this->acceleration = 3;
     45  this->speed = 0;
    4246 
    4347  if ( root )
     
    96100void ActionboxEnemy::moveTowardsBox( ActionBox * box, float dt )
    97101{
    98   Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor();
     102  //Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor();
     103  static float time = 0;
     104  time += dt;
     105  Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor() + State::getPlayer()->getPlayable()->getAbsDir().apply(Vector(1, 0, 0))*50*(1.5 + sin(time/5));
    99106  Vector targetDir = targetPos - myCoor;
    100107 
     
    127134    cur = tmp2;
    128135 
    129   myDir = cur;
     136  myDir = cur;
     137 
     138  Vector fw = cur.apply( Vector(1, 0, 0) );
     139 
     140  this->speed += this->acceleration*dt;
     141  if ( this->speed > this->maxSpeed )
     142    this->speed = this->maxSpeed;
     143  this->myCoor += fw*speed*dt;
    130144}
    131145
  • branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h

    r10656 r10662  
    2626    Quaternion qPitch;
    2727   
     28    float acceleration;
     29    float maxSpeed;
     30    float speed;
     31   
    2832    Quaternion myDir;
    2933    Vector     myCoor;
  • branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc

    r10661 r10662  
    6969
    7070#include "track/track.h"
     71#include "track/action_box.h"
    7172
    7273
     
    345346  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
    346347
    347   State::getCamera()->setViewMode(Camera::ViewTop);
     348  State::getCamera()->setViewMode(Camera::ViewNormal);
     349  State::getCameraTargetNode()->setParent(this);
     350  State::getCamera()->setParent(this);
    348351
    349352  LoadParam(root, "reactor", this, SpaceShip, setReactor);
     
    828831      break;
    829832
     833   
     834    case Playable::Vertical:
     835    {
     836        this->travelNode->setAbsCoor(this->getAbsCoor());
     837        this->travelNode->updateNode(0.01f);
     838
     839        this->isTravelDistanceInit = false;
     840
     841        if(this->entityTrack)
     842           this->travelNode->setParent(this->entityTrack->getTrackNode());
     843
     844        this->setParent(this->travelNode);
     845        this->setRelCoor(0,0,0);
     846
     847        State::getCameraNode()->setParentSoft(this->travelNode);
     848        //State::getCameraNode()->setParentSoft(this);
     849        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
     850        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     851        //State::getCameraTargetNode()->setParentSoft(this);
     852        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     853        this->setCameraMode(Camera::ViewNormal);
     854        State::getCamera()->setEventHandling(false);
     855        registerEvent(KeyMapper::PEV_VIEW0);
     856        registerEvent(KeyMapper::PEV_VIEW1);
     857        registerEvent(KeyMapper::PEV_VIEW2);
     858        registerEvent(KeyMapper::PEV_VIEW3);
     859        registerEvent(KeyMapper::PEV_VIEW4);
     860        registerEvent(KeyMapper::PEV_VIEW5);
     861
     862        State::getCamera()->setParentMode(PNODE_ALL);
     863     
     864      break;
     865    }
     866     
    830867    default:
    831868      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
     
    9901027    }
    9911028    case Playable::Vertical:
     1029    {
     1030      if ( !entityTrack || !entityTrack->getActionBox() )
     1031      {
     1032        break;
     1033      }
     1034      ActionBox * box = entityTrack->getActionBox();
     1035     
     1036      this->travelVelocity = Vector(0, 0, 0);
     1037      float ssss = 50;
     1038      if ( this->bForward )
     1039      {
     1040        this->travelVelocity += Vector( 0, ssss, 0 );
     1041      }
     1042      if ( this->bBackward )
     1043      {
     1044        this->travelVelocity += Vector( 0, -ssss, 0 );
     1045      }
     1046      if ( this->bLeft )
     1047      {
     1048        this->travelVelocity += Vector( 0, 0, -ssss );
     1049      }
     1050      if ( this->bRight )
     1051      {
     1052        this->travelVelocity += Vector( 0, 0, ssss );
     1053      }
     1054     
     1055      Vector ds = this->travelVelocity*dt;
     1056      Vector newPos = this->getRelCoor() + ds;
     1057      if ( newPos.y < -(box->getHeight_2()) || newPos.y > box->getHeight_2() )
     1058      {
     1059        this->travelVelocity.y = 0;
     1060      }
     1061      if ( newPos.z > box->getWidth_2() || newPos.z < -(box->getWidth_2()) )
     1062      {
     1063        this->travelVelocity.z = 0;
     1064      }
     1065    }
    9921066      break;
    9931067    default:
Note: See TracChangeset for help on using the changeset viewer.