Index: orxonox/trunk/src/track.cc
===================================================================
--- orxonox/trunk/src/track.cc	(revision 2190)
+++ orxonox/trunk/src/track.cc	(revision 2551)
@@ -54,32 +54,46 @@
 
 /**
-	\brief calculate a camera Placement from a "look at"-Location
-	\param lookat: the Location the camera should be centered on
-	\param camplc: pointer to a buffer where the new camera Placement should be put into
-	
-	Theoretically you can place the camera wherever you want, but for the sake of common sense I suggest that you at least
-	try to keep the thing that should be looked at inside camera boundaries.
+   \brief calculate a camera Placement from a "look at"-Location
+   \param lookat: the Location the camera should be centered on
+   \param camplc: pointer to a buffer where the new camera Placement should be put into
+   
+   Theoretically you can place the camera wherever you want, but for the sake of 
+   common sense I suggest that you at least try to keep the thing that should be looked
+   at inside camera boundaries.
 */
 void Track::map_camera (Location* lookat, Placement* camplc)
 {
-	Line trace(*offset, *end - *offset);
-	float l = trace.len ();
-	
-//	camplc->r = *offset + Vector(0,0,0.5);
-//	camplc->w = Quaternion (trace.a, Vector(0,0,1));
-	float r = (lookat->dist)*PI / l;
-	camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
-	camplc->w = Quaternion(Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r)), Vector(0,sin(r),cos(r)));
-	
+  Line trace(*offset, *end - *offset);
+  float l = trace.len ();
+  
+  //	camplc->r = *offset + Vector(0,0,0.5);
+  //	camplc->w = Quaternion (trace.a, Vector(0,0,1));
+  float r = (lookat->dist)*PI / l;
+  camplc->r = trace.r + (trace.a * ((lookat->dist-10.0) / l)) + Vector(0,0,5.0);
+  
+  Vector w(0.0,0.0,0.0);
+  w=Vector(0,0,0) - ((trace.r + (trace.a * ((lookat->dist) / l)) - camplc->r));
+  //Vector up(0.0,sin(r),cos(r)); // corrupt...
+  Vector up(0.0, 0.0, 1.0);
+
+  camplc->w = Quaternion(w, up);
+
+  //printf("\n------\nup vector: [%f, %f, %f]\n", up.x, up.y, up.z);
+  //printf("direction: [%f, %f, %f]\n", w.x, w.y, w.z);
+  //printf("quaternion: w[ %f ], v[ %f, %f, %f ]\n", camplc->w.w, camplc->w.v.x, camplc->w.v.y, camplc->w.v.z);
 }
 
 /**
-	\brief calculate a Placement from a given Location
-	\param loc: the Location the entity is in
-	\param plc: a pointer to a buffer where the corresponding Placement should be put into
-	
-	There are no limitations to how you transform a Location into a Placement, but for the sake of placement compatibility between
-	track parts you should make sure that the resulting Placement at dist == 0 is equal to the offset Vector and the Placement at
-	dist == len() is equal to the end Vector. Elseway there will be ugly artifacts when transfering between track parts.
+   \brief calculate a Placement from a given Location
+   \param loc: the Location the entity is in
+   \param plc: a pointer to a buffer where the corresponding Placement should be put
+   into
+   \return: true if track changes - false if track stays
+   
+   There are no limitations to how you transform a Location into a Placement, but for 
+   the sake of placement compatibility between track parts you should make sure that 
+   the resulting Placement at dist == 0 is equal to the offset Vector and the Placement
+   at dist == len() is equal to the end Vector. Elseway there will be ugly artifacts 
+   when transfering between track parts.
 */
 bool Track::map_coords (Location* loc, Placement* plc)
@@ -88,13 +102,17 @@
 	float l = trace.len ();
 	
+	/* change to the next track? */
 	if( loc->dist > l)
 	{
 		loc->dist -= l;
 		loc->part = nextID;
+		//FIXME: loc->track = this;
 		return true;
 	}
 	
-	Quaternion dir(trace.a, Vector(0,0,1));
-	
+	/* this quaternion represents the rotation from start-vector (0,0,1) to the direction of
+	 * the track */
+	Quaternion dir(trace.a, Vector(0,0,1)); 
+
 	plc->r = trace.r + (trace.a * ((loc->dist) / l)) + /*dir.apply*/(loc->pos);
 	plc->w = dir * loc->rot;
@@ -107,5 +125,6 @@
 	\param entity: pointer to the WorldEntity in question
 	
-	You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
+	You can do stuff like add or remove effects, do some coordinate finetuning 
+	or whatever in here.
 */
 void Track::post_enter (WorldEntity* entity)
@@ -117,5 +136,6 @@
 	\param entity: pointer to the WorldEntity in question
 	
-	You can do stuff like add or remove effects, do some coordinate finetuning or whatever in here.
+	You can do stuff like add or remove effects, do some coordinate finetuning 
+	or whatever in here.
 */
 void Track::post_leave (WorldEntity* entity)
