Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3028 in orxonox.OLD for orxonox/branches/bezierTrack/src/track.cc


Ignore:
Timestamp:
Nov 30, 2004, 2:50:59 PM (21 years ago)
Author:
bensch
Message:

orxonox/branches/bezierTrack: now Camera follows Path. heavy cleanUp of not used stuff like elyptical Camera and so on…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/bezierTrack/src/track.cc

    r3018 r3028  
    1717
    1818#include "track.h"
    19   float t = .0;
    2019
    2120using namespace std;
     
    2827  this->next = NULL;
    2928  this->previous = NULL;
     29  mainTime = .0;
     30
    3031
    3132  curve = BezierCurve();
     
    6263}
    6364
     65Vector Track::getPos (void)
     66{
     67  return curve.calcPos (mainTime);
     68}
    6469
    6570Vector Track::getPos (float t)
     
    6772  return curve.calcPos (t);
    6873}
     74
     75Vector Track::getDir (void)
     76{
     77  return curve.calcDir (mainTime);
     78}
     79
    6980Vector Track::getDir (float t)
    7081{
    7182  return curve.calcDir (t);
     83}
     84
     85Quaternion Track::getQuat (void)
     86{
     87  return curve.calcQuat (mainTime);
     88}
     89Quaternion Track::getQuat (float t)
     90{
     91  return curve.calcQuat (t);
    7292}
    7393
     
    88108  //  float r = (lookat->dist)*PI / l;
    89109  // camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
    90   camplc->pos = curve.calcPos(t) + (curve.calcDir(t)* ((lookat->dist-10.0)/t)) + Vector(-5,0,5);
    91                                  
     110 
     111  //  camplc->pos = curve.calcPos(t) + (curve.calcDir(t)* ((lookat->dist-10.0)/t)) + Vector(-5,0,5);
     112  camplc->pos = curve.calcPos(mainTime) + (curve.calcDir(mainTime) * 5) + Vector (0,0,5);
     113 
    92114  Vector w(0.0,0.0,0.0);
    93115  //  w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
    94   w = Vector(0,0,0) - (((curve.calcPos(t)) + ((curve.calcDir(t)) * ((lookat->dist) / t)) - camplc->pos));
     116  w = Vector(0,0,0) - (((curve.calcPos(mainTime)) + ((curve.calcDir(mainTime)) * ((lookat->dist) / mainTime)) - camplc->pos));
    95117  //Vector up(0.0,sin(r),cos(r)); // corrupt...
    96118  Vector up(0.0, 0.0, 1.0);
     
    118140bool Track::map_coords (Location* loc, Placement* plc)
    119141{
    120   t+=.0001;
    121   //  printf ("%f\n", t);
    122   //  if (t > 1) t =0;
    123   //  printf ("Pos: %f, %f, %f\n", curve.calcPos(t).x, curve.calcPos(t).y, curve.calcPos(t).z);
    124   //Line trace(*offset, *end - *offset);
    125   //    float l = trace.len ();
    126        
    127         /* change to the next track? */
    128         //      if( loc->dist > l)
    129         //{
    130         //      loc->dist -= l;
    131         //      loc->part = nextID;
    132                 //FIXME: loc->track = this;
    133                 //return true;
    134                 //}
    135        
     142  this->setPosition (curve.calcPos (mainTime), WORLD);
     143  this->setRotation (curve.calcQuat (mainTime), WORLD);
     144  //  printf ("x: %f; y:%f; z:%f\n", getRotation(WORLD).v.x, getRotation(WORLD).v.y, getRotation(WORLD).v.z);
     145
    136146        /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of
    137147         * the track */
    138         Quaternion dir(curve.calcDir(t), Vector(0,0,1));
     148        Quaternion dir(curve.calcDir(mainTime), Vector(0,0,1));
    139149
    140         plc->pos = curve.calcPos(t) + (curve.calcDir(t) * ((loc->dist) / t)) + /*dir.apply*/(loc->pos);
    141         plc->rot = dir * loc->rot;
     150        plc->pos = this->getPosition(WORLD);// curve.calcPos(t) + (curve.calcDir(t) * ((loc->dist) / t)) + /*dir.apply*/(loc->pos);
     151        plc->rot = this->getRotation(WORLD);dir * loc->rot;
    142152       
    143153        return false;
     
    174184void Track::tick (float deltaT)
    175185{
     186  mainTime += deltaT/10;
    176187}
    177188
Note: See TracChangeset for help on using the changeset viewer.