Changeset 3010 in orxonox.OLD for orxonox/branches
- Timestamp:
- Nov 27, 2004, 1:05:47 AM (20 years ago)
- Location:
- orxonox/branches/bezierTrack/src
- Files:
-
- 5 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 -
orxonox/branches/bezierTrack/src/track.h
r2636 r3010 20 20 Vector* offset; 21 21 Vector* end; 22 BezierCurve curve; 22 23 // Vector* direction; // unity direction vector: it is costy to always recalculate it 23 24 //Vector* up; // direction where up is ment to be - diffuse in space, eh? … … 25 26 Uint32 nextID; 26 27 28 Track* next; 29 Track* previous; 27 30 28 31 public: 29 32 Track (); 30 Track (Uint32 number, Uint32 next, Vector* start, Vector* finish);33 31 34 ~Track (); 32 35 virtual void init(); 36 37 void addPoint (Vector& point); 38 void addHotPoint (Vector& hotPoint); 33 39 34 40 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 919 919 munk = pow(1-t,(double)nodeCount); 920 920 921 for (k=0; k<=nodeCount ; k++) {921 for (k=0; k<=nodeCount-1; k++) { 922 922 nn = nodeCount; 923 923 kn = k; … … 947 947 } 948 948 949 Vector BezierCurve::calcDir ection(float t)949 Vector BezierCurve::calcDir (float t) 950 950 { 951 951 double diff = .00000000001; -
orxonox/branches/bezierTrack/src/vector.h
r3004 r3010 178 178 void addNode (const Vector& newNode); 179 179 Vector calcPos (float t); 180 Vector calcDir ection(float t);180 Vector calcDir (float t); 181 181 182 182 Vector getPos () const; -
orxonox/branches/bezierTrack/src/world.cc
r3005 r3010 101 101 this->pathnodes = new Vector[6]; 102 102 this->pathnodes[0] = Vector(0, 0, 0); 103 this->pathnodes[1] = Vector(10 00, 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); 108 108 109 109 // create the tracks 110 this->tracklen = 2;111 this->track = new Track [2];110 this->tracklen = 5; 111 this->track = new Track(); 112 112 for( int i = 0; i < this->tracklen; i++) 113 113 { 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]); 115 116 } 116 117 … … 152 153 for( int i = 0; i < this->tracklen; i++) 153 154 { 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]); 155 156 } 156 157 … … 428 429 } 429 430 430 for( int i = 0; i < tracklen; i++) track[i].tick (seconds);431 // for( int i = 0; i < tracklen; i++) track[i].tick (seconds); 431 432 } 432 433
Note: See TracChangeset
for help on using the changeset viewer.