Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 27, 2004, 1:05:47 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/bezierTrack: moveing possible (strange Camera-behaviour)

File:
1 edited

Legend:

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

    r3005 r3010  
    1717
    1818#include "track.h"
     19  float t = .0;
    1920
    2021using namespace std;
     
    2526Track::Track ()
    2627{
    27         ID = 0;
    28         offset = NULL;
    29         end = NULL;
    30         nextID = 0;
    31 }
     28  this->next = NULL;
     29  this->previous = NULL;
    3230
    33 /**
    34         \brief creates a functional base Track part
    35         \param number: the ID if this Track part
    36         \param next: the ID of the next Track part
    37         \param start: pointer to an anchor point (Vector) representing the offset of this part
    38         \param finish: pointer to an anchor point (Vector) representing the end of this part
    39 */
    40 Track::Track (Uint32 number, Uint32 next, Vector* start, Vector* finish)
    41 {
    42         ID = number;
    43         offset = start;
    44         end = finish;
    45         nextID = next;
     31  curve = BezierCurve();
    4632}
    4733
     
    5137Track::~Track ()
    5238{
     39  if (next != NULL)
     40    delete next;
     41  if (previous != NULL)
     42    delete previous;
    5343}
    5444
     
    5646{
    5747 
     48}
     49
     50void Track::addPoint (Vector& point)
     51{
     52  curve.addNode(point);
     53
     54  return;
     55}
     56
     57
     58void Track::addHotPoint (Vector& hotPoint)
     59{
     60
     61  return;
    5862}
    5963
     
    7074void Track::map_camera (Location* lookat, Placement* camplc)
    7175{
    72   Line trace(*offset, *end - *offset);
    73   float l = trace.len ();
     76  t+=.001;
     77  if (t> 1) t =0;
     78  //  Line trace(*offset, *end - *offset);
     79  //  float l = trace.len ();
    7480 
    75   //    camplc->r = *offset + Vector(0,0,0.5);
    76   //    camplc->w = Quaternion (trace.a, Vector(0,0,1));
    77   float r = (lookat->dist)*PI / l;
    78   camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
    79  
     81  //  float r = (lookat->dist)*PI / l;
     82  // camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
     83  camplc->r = curve.calcPos(t) + (curve.calcDir(t)* ((lookat->dist-10)/t)) + Vector(0,0,5.0);
     84                                 
    8085  Vector w(0.0,0.0,0.0);
    81   w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
     86  //  w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
     87  w = Vector(0,0,0) - (((curve.calcPos(t)) + ((curve.calcDir(t)) * ((lookat->dist) / t)) - camplc->r));
     88
    8289  //Vector up(0.0,sin(r),cos(r)); // corrupt...
    8390  Vector up(0.0, 0.0, 1.0);
     
    105112bool Track::map_coords (Location* loc, Placement* plc)
    106113{
    107         Line trace(*offset, *end - *offset);
    108         float l = trace.len ();
     114  //Line trace(*offset, *end - *offset);
     115  //    float l = trace.len ();
    109116       
    110117        /* change to the next track? */
    111         if( loc->dist > l)
    112         {
    113                 loc->dist -= l;
    114                 loc->part = nextID;
     118        //      if( loc->dist > l)
     119        //{
     120        //      loc->dist -= l;
     121        //      loc->part = nextID;
    115122                //FIXME: loc->track = this;
    116                 return true;
    117         }
     123                //return true;
     124                //}
    118125       
    119126        /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of
    120127         * the track */
    121         Quaternion dir(trace.a, Vector(0,0,1));
     128        Quaternion dir(curve.calcDir(t), Vector(0,0,1));
    122129
    123         plc->r = trace.r + (trace.a * ((loc->dist) / l)) + /*dir.apply*/(loc->pos);
     130        plc->r = curve.calcPos(t) + (curve.calcDir(t) * ((loc->dist) / t)) + /*dir.apply*/(loc->pos);
    124131        plc->w = dir * loc->rot;
    125132       
Note: See TracChangeset for help on using the changeset viewer.