Index: orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc
===================================================================
--- orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc	(revision 3714)
+++ orxonox/branches/textEngine/src/lib/graphics/font/glfont.cc	(revision 3715)
@@ -55,4 +55,6 @@
 #include <string.h>
 
+#include "p_node.h"
+#include "vector.h"
 #include "debug.h"
 
@@ -128,4 +130,5 @@
   this->currentText = new Text;
 
+  this->currentText->bindNode = NULL;
   this->currentText->text = NULL;
   this->currentText->texture = 0;
@@ -171,4 +174,10 @@
 }
 
+void GLFont::setBindNode(PNode* bindNode)
+{
+  this->currentText->bindNode = bindNode;
+}
+
+
 /**
    \brief Sets a new Text to the font
@@ -245,21 +254,41 @@
 void GLFont::draw(void)
 {
+  GLdouble modMat[16];
+  GLint viewPort[4];
+  glGetDoublev(GL_PROJECTION_MATRIX, this->projMat);
+  glGetDoublev(GL_MODELVIEW_MATRIX, modMat);
+  glGetIntegerv(GL_VIEWPORT, viewPort);
   this->enter2DMode();
+
+
+  Vector pos;
+  if (this->currentText->bindNode)
+    {
+      GLdouble x = this->currentText->bindNode->getAbsCoor().x;
+      GLdouble y = this->currentText->bindNode->getAbsCoor().y;
+      GLdouble z = this->currentText->bindNode->getAbsCoor().z;
+      GLdouble tmp[3];
+      gluProject(x, y, z, modMat, projMat, viewPort, tmp, tmp+1, tmp+2);
+      printf("test %f %f %f,\n", tmp[0], tmp[1], tmp[2]);
+      pos.x = tmp[0];
+      pos.y = tmp[1];
+      pos.z = tmp[2];
+    }
 
   glBindTexture(GL_TEXTURE_2D, this->currentText->texture);
   glEnable(GL_TEXTURE_2D);
   glBegin(GL_QUADS);
-
+  
   glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV);
-  glVertex2i(20,   20  );
+  glVertex2i(pos.x,   pos.y  );
 
   glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV);
-  glVertex2i(20+this->currentText->textPosSize.w, 20  );
+  glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y  );
 
   glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV);
-  glVertex2i(20+this->currentText->textPosSize.w, 20+this->currentText->textPosSize.h);
+  glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h);
 
   glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV);
-  glVertex2i(20, 20+this->currentText->textPosSize.h);
+  glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h);
 
   glEnd();
@@ -555,2 +584,43 @@
 
 }
+
+
+void m_inverse(const float *m, float *out)
+{
+    float det;
+    det=  m[0]*m[5]*m[10];
+    det+= m[4]*m[9]*m[2];
+    det+= m[8]*m[1]*m[6];
+    det-= m[8]*m[5]*m[2];
+    det-= m[4]*m[1]*m[10];
+    det-= m[0]*m[9]*m[6];
+    
+    if(det!= 0.0)
+	det=1.0/det;
+    out[0]=  (m[5]*m[10]-m[9]*m[6])*det;
+    out[1]= -(m[1]*m[10]-m[9]*m[2])*det;
+    out[2]=  (m[1]*m[6]-m[5]*m[2])*det;
+    out[3]= 0.0;
+    out[4]= -(m[4]*m[10]-m[8]*m[6])*det;
+    out[5]=  (m[0]*m[10]-m[8]*m[2])*det;
+    out[6]= -(m[0]*m[6]-m[4]*m[2])*det;
+    out[7]= 0.0;
+    out[8]=  (m[4]*m[9]-m[8]*m[5])*det;
+    out[9]= -(m[0]*m[9]-m[8]*m[1])*det;
+    out[10]= (m[0]*m[5]-m[4]*m[1])*det;
+    out[11]= 0.0;
+    out[12]=- (m[12]*out[0]+m[13]*out[4]+m[14]*out[8]);
+    out[13]=- (m[12]*out[1]+m[13]*out[5]+m[14]*out[9]);
+    out[14]=- (m[12]*out[2]+m[13]*out[6]+m[14]*out[10]);
+    out[15]= 1.0;
+}
+
+
+Vector mvMult(const float *mat, const Vector* vec)
+{
+  Vector tmp;
+  tmp.x = mat[0]*vec->x+mat[1]*vec->y+mat[2]*vec->z;
+  tmp.y = mat[4]*vec->x+mat[5]*vec->y+mat[6]*vec->z;
+  tmp.z = mat[8]*vec->x+mat[9]*vec->y+mat[10]*vec->z;
+  return tmp;
+}
Index: orxonox/branches/textEngine/src/lib/graphics/font/glfont.h
===================================================================
--- orxonox/branches/textEngine/src/lib/graphics/font/glfont.h	(revision 3714)
+++ orxonox/branches/textEngine/src/lib/graphics/font/glfont.h	(revision 3715)
@@ -10,6 +10,10 @@
 #include "SDL_ttf.h"
 
-// FORWARD DECLARATION 
+#include "vector.h"
+
+// FORWARD DECLARATION
+class PNode;
 template<class T> class tList;
+
 
 /* some default values */
@@ -20,5 +24,4 @@
 #define FONT_DEFAULT_COLOR_B    256                  //!< the default red blue (color) of the text
 #define FONT_NUM_COLORS         256                  //!< The number of colors.
-
 
 
@@ -57,15 +60,18 @@
   virtual ~GLFont();
 
+  // general
   static void enableFonts(void);
   static void disableFonts(void);
 
+  // font
   bool setFont(const char* fontFile);
-  void setText(const char* text);
-
-  void setStyle(char* renderStyle);
   void setSize(unsigned int fontSize);
   void setColor(Uint8 r, Uint8 g, Uint8 b);
+
+  // text
+  void setBindNode(PNode* bindNode);
+  void setText(const char* text);
+  void setStyle(char* renderStyle);
   void setPosition(int x, int y);
-
   void createTexture(void);
   
@@ -73,4 +79,7 @@
 
  private:
+  // general purpose
+  GLdouble projMat[16];             //!< The Projection Matrix
+
   // information about the Font
   TTF_Font* font;                  //!< The font we use for this.
@@ -88,4 +97,6 @@
     SDL_Rect textPosSize;            //!< An SDL-Rectangle representing the position and size of the Text on the screen.
     int renderStyle;                 //!< The Renderstyle
+
+    PNode* bindNode;                 //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.)
   };
   tList<Text>* textList;
@@ -113,3 +124,5 @@
 };
 
+void m_inverse(const float *m, float *out);
+Vector mvMult(const float *mat, const Vector* vec);
 #endif /* _GLFONT_H */
Index: orxonox/branches/textEngine/src/story_entities/world.cc
===================================================================
--- orxonox/branches/textEngine/src/story_entities/world.cc	(revision 3714)
+++ orxonox/branches/textEngine/src/story_entities/world.cc	(revision 3715)
@@ -302,5 +302,5 @@
 	    this->spawn (this->localPlayer);
 	    /*monitor progress*/
-	    //this->glmis->step();	    
+	    //this->glmis->step();
 	    this->glmis->step();
 
@@ -347,4 +347,5 @@
 	    PNode* tn = trackManager->getTrackNode();
 	    tn->addChild(this->localPlayer);
+	    tmpFont->setBindNode(tn);
 
 	    //localCamera->setParent(TrackNode::getInstance());
