Changeset 3010 in orxonox.OLD for orxonox/branches/bezierTrack/src/track.cc
- Timestamp:
- Nov 27, 2004, 1:05:47 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/bezierTrack/src/track.cc
r3005 r3010 17 17 18 18 #include "track.h" 19 float t = .0; 19 20 20 21 using namespace std; … … 25 26 Track::Track () 26 27 { 27 ID = 0; 28 offset = NULL; 29 end = NULL; 30 nextID = 0; 31 } 28 this->next = NULL; 29 this->previous = NULL; 32 30 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(); 46 32 } 47 33 … … 51 37 Track::~Track () 52 38 { 39 if (next != NULL) 40 delete next; 41 if (previous != NULL) 42 delete previous; 53 43 } 54 44 … … 56 46 { 57 47 48 } 49 50 void Track::addPoint (Vector& point) 51 { 52 curve.addNode(point); 53 54 return; 55 } 56 57 58 void Track::addHotPoint (Vector& hotPoint) 59 { 60 61 return; 58 62 } 59 63 … … 70 74 void Track::map_camera (Location* lookat, Placement* camplc) 71 75 { 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 (); 74 80 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 80 85 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 82 89 //Vector up(0.0,sin(r),cos(r)); // corrupt... 83 90 Vector up(0.0, 0.0, 1.0); … … 105 112 bool Track::map_coords (Location* loc, Placement* plc) 106 113 { 107 108 float l = trace.len ();114 //Line trace(*offset, *end - *offset); 115 // float l = trace.len (); 109 116 110 117 /* 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; 115 122 //FIXME: loc->track = this; 116 return true;117 }123 //return true; 124 //} 118 125 119 126 /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of 120 127 * the track */ 121 Quaternion dir( trace.a, Vector(0,0,1));128 Quaternion dir(curve.calcDir(t), Vector(0,0,1)); 122 129 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); 124 131 plc->w = dir * loc->rot; 125 132
Note: See TracChangeset
for help on using the changeset viewer.