Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3010 in orxonox.OLD


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

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

Location:
orxonox/branches/bezierTrack/src
Files:
5 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       
  • orxonox/branches/bezierTrack/src/track.h

    r2636 r3010  
    2020  Vector* offset;
    2121  Vector* end;
     22  BezierCurve curve;
    2223  // Vector* direction; // unity direction vector: it is costy to always recalculate it
    2324  //Vector* up; // direction where up is ment to be - diffuse in space, eh?
     
    2526  Uint32 nextID;
    2627 
     28  Track* next;
     29  Track* previous;
    2730       
    2831 public:
    2932  Track ();
    30   Track (Uint32 number, Uint32 next, Vector* start, Vector* finish);
     33 
    3134  ~Track ();
    3235  virtual void init();
     36
     37  void addPoint (Vector& point);
     38  void addHotPoint (Vector& hotPoint);
    3339 
    3440  virtual void post_enter (WorldEntity* entity);        // handle coordinate transition in here !!! (when dist < 0 or dist > lasttracklenght)
  • orxonox/branches/bezierTrack/src/vector.cc

    r3004 r3010  
    919919  munk = pow(1-t,(double)nodeCount);
    920920 
    921   for (k=0; k<=nodeCount; k++) {
     921  for (k=0; k<=nodeCount-1; k++) {
    922922    nn = nodeCount;
    923923    kn = k;
     
    947947}
    948948
    949 Vector BezierCurve::calcDirection (float t)
     949Vector BezierCurve::calcDir (float t)
    950950{
    951951  double diff = .00000000001;
  • orxonox/branches/bezierTrack/src/vector.h

    r3004 r3010  
    178178  void addNode (const Vector& newNode);
    179179  Vector calcPos (float t);
    180   Vector calcDirection (float t);
     180  Vector calcDir (float t);
    181181 
    182182  Vector getPos () const;
  • orxonox/branches/bezierTrack/src/world.cc

    r3005 r3010  
    101101            this->pathnodes = new Vector[6];
    102102            this->pathnodes[0] = Vector(0, 0, 0);
    103             this->pathnodes[1] = Vector(1000, 0, 0);
    104             //      this->pathnodes[2] = Vector(-100, 140, 0);
    105             //      this->pathnodes[3] = Vector(0, 180, 0);
    106             //      this->pathnodes[4] = Vector(100, 140, 0);
    107             //      this->pathnodes[5] = Vector(100, 40, 0);
     103            this->pathnodes[1] = Vector(10, 5, 0);
     104            this->pathnodes[2] = Vector(20, 0, 0);
     105            this->pathnodes[3] = Vector(10, 3, 0);
     106            this->pathnodes[4] = Vector(50, 0, 0);
     107            this->pathnodes[5] = Vector(100, 0, 0);
    108108           
    109109            // create the tracks
    110             this->tracklen = 2;
    111             this->track = new Track[2];
     110            this->tracklen = 5;
     111            this->track = new Track();
    112112            for( int i = 0; i < this->tracklen; i++)
    113113              {
    114                 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
     114                //              this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
     115                track->addPoint(this->pathnodes[i]);
    115116              }
    116117           
     
    152153            for( int i = 0; i < this->tracklen; i++)
    153154              {
    154                 this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
     155                //              this->track[i] = Track( i, (i+1)%this->tracklen, &this->pathnodes[i], &this->pathnodes[(i+1)%this->tracklen]);
    155156              }
    156157           
     
    428429    }
    429430
    430   for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
     431  //  for( int i = 0; i < tracklen; i++) track[i].tick (seconds);
    431432}
    432433
Note: See TracChangeset for help on using the changeset viewer.