Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10512 in orxonox.OLD


Ignore:
Timestamp:
Jan 30, 2007, 8:01:19 PM (17 years ago)
Author:
bknecht
Message:

some changes so the vertical scroller will work better

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/track/track.cc

    r10500 r10512  
    233233//         }
    234234//     }
    235    if (this->trackNode)
    236      {
     235   if (this->trackNode && !this->pause)
     236   {
    237237       // tmp save
    238238        float oldTime = this->localTime;
     
    240240        if(this->mode == 0)
    241241        {
    242               if(this->localTime < this->duration)
     242              // PRINTF(0)("localTime %f and duration %f", this->localTime, this->duration);
     243              if(this->localTime + dt < this->duration)
    243244                this->localTime += dt;
    244245        }
     
    250251        }
    251252
    252        Vector tmp = this->calcPos();
    253 
    254 
    255        Vector dV = tmp - this->trackNode->getAbsCoor();
    256        float dx = speed * dt;
    257        float ratio = dx / dV.len();
    258 
    259        if( dt > 0.0f)
     253       if(oldTime != this->localTime)
    260254       {
    261           float newDt = dt * ratio;
    262           if(this->pause)
    263             newDt = 0;
    264           this->localTime = oldTime += newDt;
     255           Vector tmp = this->calcPos();
     256   
     257   
     258           Vector dV = tmp - this->trackNode->getAbsCoor();
     259           float dx = speed * dt;
     260           float ratio = dx / dV.len();
     261   
     262           if( dt > 0.0f)
     263           {
     264              float newDt = dt * ratio;
     265              this->localTime = oldTime + newDt;
     266           }
     267           tmp = this->calcPos();
     268   
     269           Vector v(0.0, 1.0, 0.0);
     270           Quaternion quat = Quaternion(this->calcDir(), v);
     271           Quaternion q(-PI/2, v);
     272           quat = quat * q;
     273   
     274           // move trackNode of the track
     275           this->trackNode->shiftCoor(tmp - this->trackNode->getAbsCoor());
     276           // set direction and roll angle of trackNode
     277           this->trackNode->setAbsDir(quat);
    265278       }
    266        tmp = this->calcPos();
    267 
    268        Vector v(0.0, 1.0, 0.0);
    269        Quaternion quat = Quaternion(this->calcDir(), v);
    270        Quaternion q(-PI/2, v);
    271        quat = quat * q;
    272 
    273        // move trackNode of the track
    274        this->trackNode->shiftCoor(tmp - this->trackNode->getAbsCoor());
    275        // set direction and roll angle of trackNode
    276        this->trackNode->setAbsDir(quat);
    277      }
     279    }
    278280}
    279281
  • trunk/src/world_entities/npcs/npc.cc

    r10511 r10512  
    6565                        ->addMethod("fire", Executor0<NPC, lua_State*>(&NPC::fire))
    6666                        ->addMethod("pause", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::pauseTrack))
     67                        ->addMethod("setAI", Executor1<NPC, lua_State*, bool>(&NPC::setAI))
    6768                        ->addMethod("setVisibility", Executor1<WorldEntity, lua_State*, bool>(&WorldEntity::setVisibility))
    6869                       );
     
    234235//   LoadParamXML(root, "Weapons", this, NPC, addWeapons)
    235236//   .describe("creates and adds weapons");
     237}
     238
     239void NPC::setAI(bool activate)
     240{
     241     if(activate) AIEngine::getInstance()->addAI(teamNumber,swarmNumber,(WorldEntity*)this,maxSpeed,attackDistance);
     242     else AIEngine::getInstance()->removeAI(teamNumber,swarmNumber,(WorldEntity*)this);
    236243}
    237244
  • trunk/src/world_entities/npcs/npc.h

    r10499 r10512  
    3333  inline int getTeam()  { return teamNumber; }
    3434  inline void fire(){ this->bFire=true;}
    35 
     35  void setAI(bool activate);
    3636  inline void enableAI(int flag) { this->bAIEnabled = (bool)flag; }
    3737
  • trunk/src/world_entities/space_ships/space_ship.cc

    r10503 r10512  
    6060#include "player.h"
    6161#include "camera.h"
     62#include "cameraman.h"
    6263
    6364
     
    11481149void SpaceShip::updateTravelDistance()
    11491150{
    1150   float x = 1.25 * this->actionWidthPercentage * fabsf(State::getCamera()->getAbsCoor().y) * tan(State::getCamera()->getFovy()*M_PI /360.0);
    1151   float y = x / State::getCamera()->getAspectRatio() / this->actionWidthPercentage;
     1151     CameraMan* cm = State::getCameraman();
     1152     Camera* c = cm->getCurrentCam();
     1153     
     1154     
     1155  float x = 1.25 * this->actionWidthPercentage * fabsf(c->getAbsCoor().y) * tan(c->getFovy()*M_PI /360.0);
     1156  float y = x / c->getAspectRatio() / this->actionWidthPercentage;
    11521157  //State::getCamera()->setAbsCoor(-5, 1000, 0);
    11531158
Note: See TracChangeset for help on using the changeset viewer.