Index: /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.cc
===================================================================
--- /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.cc	(revision 3767)
+++ /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.cc	(revision 3768)
@@ -37,7 +37,143 @@
 
 ////////////
+/// TEXT ///
+////////////
+
+Text::Text(void)
+{
+
+}
+
+Text::~Text(void)
+{
+
+}
+
+
+void Text::setBindNode(PNode* bindNode)
+{
+  this->bindNode = bindNode;
+}
+
+/**
+   \brief sets the Type of this Text
+   \param type the type to set.
+*/
+void Text::setType(int type)
+{
+  this->type = type;
+}
+
+
+/**
+   \brief Sets a new Text to the font
+   \param text the new text to set
+*/
+void Text::setText(const char* text)
+{
+  if (this->text)
+    delete []this->text;
+  this->text = new char[strlen(text)+1];
+  strcpy(this->text, text);
+}
+
+/**
+   \brief sets a Position.
+   \param x the x-position in pixels from the left border
+   \param y the y-position in pixels from the top border
+*/
+void Text::setPosition(int x, int y)
+{
+  this->posSize.x = x;
+  this->posSize.y = y;
+}
+
+
+/**
+   \brief draws the Font
+   \todo FIX this is to slow/static
+*/
+void Text::draw(void)
+{
+  // storing all the Transformation Matrices.
+
+  GLdouble modMat[16];
+  GLdouble projMat[16];
+  GLint viewPort[4];
+  glGetDoublev(GL_PROJECTION_MATRIX, projMat);
+  glGetDoublev(GL_MODELVIEW_MATRIX, modMat);
+  glGetIntegerv(GL_VIEWPORT, viewPort);
+//    this->enter2DMode();
+
+
+  // setting the Position of this Text.
+  Vector pos;
+  if (this->bindNode)
+    {
+      GLdouble x = this->bindNode->getAbsCoor().x;
+      GLdouble y = this->bindNode->getAbsCoor().y;
+      GLdouble z = this->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] + this->posSize.x;
+      pos.y = GraphicsEngine::getInstance()->getResolutionY() - tmp[1] + this->posSize.y;
+      pos.z = tmp[2];
+    }
+  else 
+    {
+      pos.x = this->posSize.x;
+      pos.y = this->posSize.y;
+      pos.z = 0;
+    }
+
+  // drawing this Text.
+  if(type == TEXT_STATIC)
+    {
+      glBindTexture(GL_TEXTURE_2D, this->texture);
+      glEnable(GL_TEXTURE_2D);
+      glBegin(GL_QUADS);
+      
+      glTexCoord2f(this->texCoord.minU, this->texCoord.minV);
+      glVertex2i(pos.x,   pos.y  );
+      
+      glTexCoord2f(this->texCoord.maxU, this->texCoord.minV);
+      glVertex2i(pos.x + this->posSize.w, pos.y  );
+      
+      glTexCoord2f(this->texCoord.maxU, this->texCoord.maxV);
+      glVertex2i(pos.x + this->posSize.w, pos.y + this->posSize.h);
+      
+      glTexCoord2f(this->texCoord.minU, this->texCoord.maxV);
+      glVertex2i(pos.x, pos.y + this->posSize.h);
+      
+      glEnd();
+    }
+  else //(if type & TEXT_DYNAMIC)
+    {
+      Glyph** glyphArray = this->font->getGlyphArray();
+      glBindTexture(GL_TEXTURE_2D, this->font->getFastTextureID());
+      //      glEnable(GL_TEXTURE_2D);
+      glTranslatef(pos.x, pos.y, 0);
+
+      printf("%d, %d\n", this->font->getFastTextureID(), glyphArray[65]->displayList);
+      char* tmpText = this->text;
+      while (*tmpText != '\0')
+	{
+	  if(glyphArray[*tmpText])
+	    {
+	      glCallList(glyphArray[*tmpText]->displayList);
+	      glTranslatef(glyphArray[*tmpText]->width, 0, 0);
+	    }
+	  tmpText++;
+	}
+    }
+  //  this->leave2DMode();
+}
+
+
+
+////////////
 /// FONT ///
 ////////////
-
 /**
    \brief constructs a Font
@@ -66,13 +202,12 @@
   
   this->setSize(fontSize);
-  this->setType(TEXT_DYNAMIC);
-  
-  this->currentText->renderStyle = TTF_STYLE_NORMAL;
-
+  this->setStyle(TTF_STYLE_NORMAL);
   this->setFont(fontFile);
 
-  this->setPosition(0, 0);
-
-  this->setText(FONT_DEFAULT_TEXT);
+
+  this->currentText->setType(TEXT_DYNAMIC);
+  this->currentText->setPosition(0, 0);
+
+  this->currentText->setText(FONT_DEFAULT_TEXT);
   
   this->setColor(r, g, b);
@@ -128,31 +263,4 @@
 }
 
-void Font::setBindNode(PNode* bindNode)
-{
-  this->currentText->bindNode = bindNode;
-}
-
-/**
-   \brief sets the Type of this Text
-   \param type the type to set.
-*/
-void Font::setType(int type)
-{
-  this->currentText->type = type;
-}
-
-
-/**
-   \brief Sets a new Text to the font
-   \param text the new text to set
-*/
-void Font::setText(const char* text)
-{
-  if (this->currentText->text)
-    delete []this->currentText->text;
-  this->currentText->text = new char[strlen(text)+1];
-  strcpy(this->currentText->text, text);
-}
-
 /**
    \brief sets a specific renderStyle
@@ -162,19 +270,21 @@
 void Font::setStyle(char* renderStyle)
 {
-  this->currentText->renderStyle = TTF_STYLE_NORMAL;
+  this->renderStyle = TTF_STYLE_NORMAL;
   
   for (int i = 0; i < strlen(renderStyle); i++)
     if (strncmp(renderStyle+i, "b", 1) == 0) 
-      this->currentText->renderStyle |= TTF_STYLE_BOLD;
+      this->renderStyle |= TTF_STYLE_BOLD;
     else if (strncmp(renderStyle+i, "i", 1) == 0)
-      this->currentText->renderStyle |= TTF_STYLE_ITALIC;
+      this->renderStyle |= TTF_STYLE_ITALIC;
     else if (strncmp(renderStyle+i, "u", 1) == 0) 
-      this->currentText->renderStyle |= TTF_STYLE_UNDERLINE;
+      this->renderStyle |= TTF_STYLE_UNDERLINE;
 
   if (this->font)
-    TTF_SetFontStyle(this->font, this->currentText->renderStyle);
+    TTF_SetFontStyle(this->font, this->renderStyle);
   else
     PRINTF(2)("Font was not initialized, please do so before setting the Font-Style.\n");
 }
+
+
 
 /**
@@ -198,92 +308,4 @@
   this->currentText->color.g = g;
   this->currentText->color.b = b;
-}
-
-/**
-   \brief sets a Position.
-   \param x the x-position in pixels from the left border
-   \param y the y-position in pixels from the top border
-*/
-void Font::setPosition(int x, int y)
-{
-  this->currentText->textPosSize.x = x;
-  this->currentText->textPosSize.y = y;
-}
-
-/**
-   \brief draws the Font
-   \todo FIX this is to slow/static
-*/
-void Font::draw(void)
-{
-  // storing all the Transformation Matrices.
-  GLdouble modMat[16];
-  GLint viewPort[4];
-  glGetDoublev(GL_PROJECTION_MATRIX, this->projMat);
-  glGetDoublev(GL_MODELVIEW_MATRIX, modMat);
-  glGetIntegerv(GL_VIEWPORT, viewPort);
-  this->enter2DMode();
-
-  // setting the Position of this Text.
-  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] + this->currentText->textPosSize.x;
-      pos.y = GraphicsEngine::getInstance()->getResolutionY() - tmp[1] + this->currentText->textPosSize.y;
-      pos.z = tmp[2];
-    }
-  else 
-    {
-      pos.x = this->currentText->textPosSize.x;
-      pos.y = this->currentText->textPosSize.y;
-      pos.z = 0;
-    }
-
-  // drawing this Text.
-  if(currentText->type == TEXT_STATIC)
-    {
-      glBindTexture(GL_TEXTURE_2D, this->currentText->texture);
-      glEnable(GL_TEXTURE_2D);
-      glBegin(GL_QUADS);
-      
-      glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.minV);
-      glVertex2i(pos.x,   pos.y  );
-      
-      glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.minV);
-      glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y  );
-      
-      glTexCoord2f(this->currentText->texCoord.maxU, this->currentText->texCoord.maxV);
-      glVertex2i(pos.x + this->currentText->textPosSize.w, pos.y + this->currentText->textPosSize.h);
-      
-      glTexCoord2f(this->currentText->texCoord.minU, this->currentText->texCoord.maxV);
-      glVertex2i(pos.x, pos.y + this->currentText->textPosSize.h);
-      
-      glEnd();
-    }
-  else //(if currentText->type & TEXT_DYNAMIC)
-    {
-      glBindTexture(GL_TEXTURE_2D, this->fastTextureID);
-      //      glEnable(GL_TEXTURE_2D);
-      glTranslatef(pos.x, pos.y, 0);
-
-      printf("%d, %d\n", this->fastTextureID, glyphArray[65]->displayList);
-      char* tmpText = this->currentText->text;
-      while (*tmpText != '\0')
-	{
-	  if(glyphArray[*tmpText])
-	    {
-	      glCallList(this->glyphArray[*tmpText]->displayList);
-	      glTranslatef(this->glyphArray[*tmpText]->width, 0, 0);
-	    }
-	  tmpText++;
-	}
-    }
-  this->leave2DMode();
 }
 
@@ -304,6 +326,6 @@
     this->currentText->texture = loadTexture(tmpSurf, &this->currentText->texCoord);
 
-  this->currentText->textPosSize.w = tmpSurf->w;
-  this->currentText->textPosSize.h = tmpSurf->h;
+  this->currentText->posSize.w = tmpSurf->w;
+  this->currentText->posSize.h = tmpSurf->h;
   SDL_FreeSurface(tmpSurf);
 }
@@ -748,58 +770,14 @@
 
 
-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;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+///////////////////
+/// TEXT-ENGINE ///
+///////////////////
 /**
    \brief standard constructor
Index: /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.h
===================================================================
--- /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.h	(revision 3767)
+++ /orxonox/branches/textEngine/src/lib/graphics/font/text_engine.h	(revision 3768)
@@ -26,4 +26,5 @@
 // FORWARD DECLARATION
 class PNode;
+class Font;
 template<class T> class tList;
 
@@ -85,8 +86,25 @@
 };
 
+////////////
+/// TEXT ///
+////////////
 //! Represents one textElement.
 class Text
 {
  public:
+  Text(void);
+  ~Text(void);
+
+  void setBindNode(PNode* bindNode);
+
+  void setType(int type);
+  void setText(const char* text);
+  void setPosition(int x, int y);
+
+  virtual void draw(void);
+
+
+  Font* font;
+
   int type;                      //!< The type of this Font.
   char* text;                    //!< The text to display
@@ -95,11 +113,12 @@
   GLuint texture;                //!< A GL-texture to hold the text
   TexCoord texCoord;             //!< Texture-coordinates \todo fix this to have a struct
-  SDL_Rect textPosSize;          //!< An SDL-Rectangle representing the position and size of the Text on the screen.
-  int renderStyle;               //!< The Renderstyle
+  SDL_Rect posSize;          //!< An SDL-Rectangle representing the position and size of the Text on the screen.
   
   PNode* bindNode;               //!< A node the Text is bind to. (if NULL thr node will not be bound to anything.)
 };
 
-
+////////////
+/// FONT ///
+////////////
 //! A class to handle a Font of a certain ttf-File, Size and Color.
 class Font
@@ -114,15 +133,11 @@
   void setSize(unsigned int fontSize);
   void setColor(Uint8 r, Uint8 g, Uint8 b);
-
-  // text
-  void setBindNode(PNode* bindNode);
-  void setType(int type);
-  void setText(const char* text);
   void setStyle(char* renderStyle);
-  void setPosition(int x, int y);
+
+  inline Glyph** getGlyphArray(void) {return glyphArray;}
+  inline GLuint getFastTextureID(void) {return fastTextureID;}
   void createTexture(void);
   
-  virtual void draw(void);
-
+  
  private:
   // general purpose
@@ -133,4 +148,5 @@
   char* fontFile;                   //!< The fontfile from whitch the font was loaded.
   unsigned int fontSize;            //!< The size of the font in pixels. each Font has one size.
+  int renderStyle;               //!< The Renderstyle
   
   Glyph** glyphArray;               //!< An Array of all the Glyphs stored in the Array of Glyphs.
@@ -159,7 +175,4 @@
 
 };
-
-void m_inverse(const float *m, float *out);
-Vector mvMult(const float *mat, const Vector* vec);
 
 
@@ -183,4 +196,6 @@
   static TextEngine* singletonRef;
 
+  tList<Font>* fontList;
+
 };
 
