Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 18, 2007, 12:08:19 AM (18 years ago)
Author:
muellmic
Message:

traveldistance calculated dynamically now, but calculations aren't correct yet.

Location:
branches/playability/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10289 r10291  
    6565
    6666#include "track/track.h"
     67#include "math.h"
    6768
    6869
     
    349350
    350351  //this->airFriction = 0.5f;
    351   this->travelDistancePlus = Vector2D(38.0, 43.0);
    352   this->travelDistanceMinus = Vector2D(-38.0, -43.0);
     352  //this->travelDistancePlus = Vector2D(38.0, 43.0);
     353  //this->travelDistanceMinus = Vector2D(-38.0, -43.0);
     354  this->travelDistancePlus = Vector2D(0,0);
     355  this->travelDistancePlus = Vector2D(0,0);
     356  this->isTravelDistanceInit = false;
     357  this->actionWidthPercentage = 0.7;
     358
    353359  this->cameraSpeed = 40;
    354360  this->cameraLook = 0.0f;
     
    397403  LoadParam(root, "cameraDistance", this, SpaceShip, setCameraDistance);
    398404  LoadParam(root, "cameraFovy", this, SpaceShip, setCameraFovy);
     405  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
    399406
    400407  State::getCamera()->setViewMode(Camera::ViewTop);
     
    553560  this->trailR->tick(time);
    554561
     562  if (!this->isTravelDistanceInit)
     563  {
     564    this->updateTravelDistance();
     565    this->isTravelDistanceInit = true;
     566  }
     567
    555568  //orient the spaceship in direction of the mouse
    556569  /*
     
    578591    this->bLeft = event.bPressed;
    579592  else if( event.type == KeyMapper::PEV_RIGHT)
     593  {
    580594    this->bRight = event.bPressed;
     595    printf("ShipCoorX: %f \n", this->getRelCoor().x);
     596  }
    581597  else if( event.type == KeyMapper::PEV_FORWARD)
     598  {
    582599    this->bForward = event.bPressed; //this->shiftCoor(0,.1,0);
     600   
     601  }
    583602  else if( event.type == KeyMapper::PEV_BACKWARD)
    584603    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
     
    823842        this->travelNode->setAbsCoor(this->getAbsCoor());
    824843        this->travelNode->updateNode(0.01f);
     844        this->isTravelDistanceInit = false;
    825845
    826846        this->setParent(this->travelNode);
     
    844864        State::getCamera()->setParentMode(PNODE_MOVEMENT);
    845865
     866        //this->updateTravelDistance();
     867
    846868        this->debugNode(1);
    847869        this->travelNode->debugNode(1);
     
    865887  float airCoeff = 2.5;
    866888  float pi = 3.14;
    867  
    868889
    869890  switch(this->getPlaymode())
     
    915936      if( this->bForward )
    916937      {
     938        //printf("ShipCoorX: %f \n", this->getRelCoor().x);
    917939        if(this->getRelCoor().x < this->travelDistancePlus.x)
    918940        {
     
    973995      if( this->bRight)
    974996      {
     997        //printf("ShipCoorZ: %f \n", this->getRelCoor().z);
    975998        if(this->getRelCoor().z < this->travelDistancePlus.y)
    976999        {
     
    10961119  State::getCamera()->setViewTopFovy(fovy);
    10971120}
     1121
     1122void SpaceShip::updateTravelDistance()
     1123{
     1124  float x = fabsf(State::getCamera()->getAbsCoor().y) * tan(State::getCamera()->getFovy()*M_PI /360.0);
     1125  float y = x / State::getCamera()->getAspectRatio();
     1126  //State::getCamera()->setAbsCoor(-5, 1000, 0);
     1127
     1128
     1129  //State::getCamera()->getAbsCoor().print();
     1130  printf("CameraRelCoorY: %f \n", State::getCamera()->getRelCoor().y);
     1131
     1132  printf("x: %f, y: %f \n", x, y);
     1133  this->travelDistancePlus = Vector2D(x, y);
     1134  this->travelDistanceMinus = Vector2D(-x, -y);
     1135
     1136  //this->isTravelDistanceInit = true;
     1137}
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r10274 r10291  
    7878    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
    7979
    80     //included by Michel: ((
     80    //included by Michel:
    8181    virtual void enterPlaymode(Playable::Playmode playmode);
    8282    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
     83    inline void setActionWidthPercentage(float f) {this->actionWidthPercentage = f; updateTravelDistance();};
     84    void updateTravelDistance();
    8385    virtual void movement (float dt);
    8486
    85     //))
     87    //
    8688
    8789    void nextWeaponConfig();
     
    175177    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
    176178    Vector2D              travelDistanceMinus;
     179    bool                  isTravelDistanceInit;
     180
     181    float                 actionWidthPercentage;
    177182
    178183// Camera
Note: See TracChangeset for help on using the changeset viewer.