Changeset 3028 in orxonox.OLD for orxonox/branches/bezierTrack/src/track.cc
- Timestamp:
- Nov 30, 2004, 2:50:59 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/bezierTrack/src/track.cc
r3018 r3028 17 17 18 18 #include "track.h" 19 float t = .0;20 19 21 20 using namespace std; … … 28 27 this->next = NULL; 29 28 this->previous = NULL; 29 mainTime = .0; 30 30 31 31 32 curve = BezierCurve(); … … 62 63 } 63 64 65 Vector Track::getPos (void) 66 { 67 return curve.calcPos (mainTime); 68 } 64 69 65 70 Vector Track::getPos (float t) … … 67 72 return curve.calcPos (t); 68 73 } 74 75 Vector Track::getDir (void) 76 { 77 return curve.calcDir (mainTime); 78 } 79 69 80 Vector Track::getDir (float t) 70 81 { 71 82 return curve.calcDir (t); 83 } 84 85 Quaternion Track::getQuat (void) 86 { 87 return curve.calcQuat (mainTime); 88 } 89 Quaternion Track::getQuat (float t) 90 { 91 return curve.calcQuat (t); 72 92 } 73 93 … … 88 108 // float r = (lookat->dist)*PI / l; 89 109 // 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 92 114 Vector w(0.0,0.0,0.0); 93 115 // 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)); 95 117 //Vector up(0.0,sin(r),cos(r)); // corrupt... 96 118 Vector up(0.0, 0.0, 1.0); … … 118 140 bool Track::map_coords (Location* loc, Placement* plc) 119 141 { 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 136 146 /* this quaternion represents the rotation from start-vector (0,0,1) to the direction of 137 147 * the track */ 138 Quaternion dir(curve.calcDir( t), Vector(0,0,1));148 Quaternion dir(curve.calcDir(mainTime), Vector(0,0,1)); 139 149 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; 142 152 143 153 return false; … … 174 184 void Track::tick (float deltaT) 175 185 { 186 mainTime += deltaT/10; 176 187 } 177 188
Note: See TracChangeset
for help on using the changeset viewer.