Index: orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
===================================================================
--- orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc	(revision 4139)
+++ orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc	(revision 4140)
@@ -32,9 +32,9 @@
    \brief standard constructor
    
-   	creates a new model
+   creates a new model
 */
 MD2Model::MD2Model () 
 {
-   this->setClassName ("MD2Model");
+  this->setClassName ("MD2Model");
 }
 
@@ -50,30 +50,30 @@
 
 /**
-  \brief draw function
+   \brief draw function
   
-  these function will take NO argument in the final version, just for testing
+   these function will take NO argument in the final version, just for testing
 */
 void MD2Model::draw(t3DModel *pModel)
 {
-	if( pModel->objectList->getSize() <= 0) return;
-
-	t3DObject *pObject = pModel->objectList->firstElement();
-	glBegin(GL_TRIANGLES);
-		for(int j = 0; j < pObject->numOfFaces; j++)
-		{
-			for(int whichVertex = 0; whichVertex < 3; whichVertex++)
-			{
-				int index = pObject->pFaces[j].vertIndex[whichVertex];
-				int index2 = pObject->pFaces[j].coordIndex[whichVertex];
-				/* we invert the normals since the md2 file format uses different style */
-				glNormal3f(-pObject->pNormals[ index ].x, -pObject->pNormals[ index ].y, -pObject->pNormals[ index ].z);
-				if(pObject->pTexVerts) 
-				{
-					glTexCoord2f(pObject->pTexVerts[ index2 ].x, pObject->pTexVerts[ index2 ].y);
-				}
-				glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);
-			}
-		}
-	glEnd();
+  if( pModel->objectList->getSize() <= 0) return;
+
+  t3DObject *pObject = pModel->objectList->firstElement();
+  glBegin(GL_TRIANGLES);
+  for(int j = 0; j < pObject->numOfFaces; j++)
+    {
+      for(int whichVertex = 0; whichVertex < 3; whichVertex++)
+	{
+	  int index = pObject->pFaces[j].vertIndex[whichVertex];
+	  int index2 = pObject->pFaces[j].coordIndex[whichVertex];
+	  /* we invert the normals since the md2 file format uses different style */
+	  glNormal3f(-pObject->pNormals[ index ].x, -pObject->pNormals[ index ].y, -pObject->pNormals[ index ].z);
+	  if(pObject->pTexVerts) 
+	    {
+	      glTexCoord2f(pObject->pTexVerts[ index2 ].x, pObject->pTexVerts[ index2 ].y);
+	    }
+	  glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);
+	}
+    }
+  glEnd();
 }
 
@@ -84,15 +84,15 @@
 /**
    \brief standard deconstructor
-	creates a new model loader
+   creates a new model loader
 */
 MD2Loader::MD2Loader()
 {
-   this->setClassName ("MD2Loader");
-   /* initialize all data to initial state */
-   memset(&this->header, 0, sizeof(tMd2Header));
-   this->pSkins = NULL;
-   this->pTexCoords = NULL;
-   this->pTriangles = NULL;
-   this->pFrames = NULL;
+  this->setClassName ("MD2Loader");
+  /* initialize all data to initial state */
+  memset(&this->header, 0, sizeof(tMd2Header));
+  this->pSkins = NULL;
+  this->pTexCoords = NULL;
+  this->pTriangles = NULL;
+  this->pFrames = NULL;
 }
 
@@ -105,199 +105,199 @@
 
 /**
-	\brief this is called by the client to open the .Md2 file, read it, then clean up
-	\param model to load in
-	\param file name to load
-	\param texture name to load
+   \brief this is called by the client to open the .Md2 file, read it, then clean up
+   \param model to load in
+   \param file name to load
+   \param texture name to load
 */
 bool MD2Loader::importMD2(t3DModel *pModel, char *fileName, char *textureName)
 {
-	this->pFile = fopen(fileName, "rb");
-	if( unlikely(!pFile)) 
-	{
-		PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
-		return false;
-	}
-	fread(&this->header, 1, sizeof(tMd2Header), pFile);
-	/* check for the header version: make sure its a md2 file :) */
-	if( likely(this->header.version != 8))
-	{
-		PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName);
-		return false;
-	}
+  this->pFile = fopen(fileName, "rb");
+  if( unlikely(!pFile)) 
+    {
+      PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
+      return false;
+    }
+  fread(&this->header, 1, sizeof(tMd2Header), pFile);
+  /* check for the header version: make sure its a md2 file :) */
+  if( likely(this->header.version != 8))
+    {
+      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName);
+      return false;
+    }
 	
-	this->readMD2Data();
-	this->convertDataStructures(pModel);
-
-	if( likely((int)textureName))
-	{
-		tMaterialInfo* textureInfo = new tMaterialInfo;
-		strcpy(textureInfo->strFile, textureName);
-		/* since there is only one texture for a .Md2 file, the ID is always 0 */
-		textureInfo->texureId = 0;
-		textureInfo->uTile = 1;
-		/* we only have 1 material for a model */
-		pModel->numOfMaterials = 1;
-		pModel->materialList->add(textureInfo);
-	}
+  this->readMD2Data();
+  this->convertDataStructures(pModel);
+
+  if( likely((int)textureName))
+    {
+      tMaterialInfo* textureInfo = new tMaterialInfo;
+      strcpy(textureInfo->strFile, textureName);
+      /* since there is only one texture for a .Md2 file, the ID is always 0 */
+      textureInfo->texureId = 0;
+      textureInfo->uTile = 1;
+      /* we only have 1 material for a model */
+      pModel->numOfMaterials = 1;
+      pModel->materialList->add(textureInfo);
+    }
 	
-	this->cleanUp();
-	return true;
-}
-
-/**
-	\brief This function reads in all of the model's data, except the animation frames
+  this->cleanUp();
+  return true;
+}
+
+/**
+   \brief This function reads in all of the model's data, except the animation frames
 */
 void MD2Loader::readMD2Data()
 {
-	unsigned char buffer[MD2_MAX_FRAMESIZE];
-	this->pSkins     = new tMd2Skin[this->header.numSkins];
-	this->pTexCoords = new tMd2TexCoord[this->header.numTexCoords];
-	this->pTriangles = new tMd2Face[this->header.numTriangles];
-	this->pFrames    = new tMd2Frame[this->header.numFrames];
-
-	/* we read the skins */
-	fseek(this->pFile, this->header.offsetSkins, SEEK_SET);
-	fread(this->pSkins, sizeof(tMd2Skin), this->header.numSkins, this->pFile);
-	/* read all vertex data */
-	fseek(this->pFile, this->header.offsetTexCoords, SEEK_SET);
-	fread(this->pTexCoords, sizeof(tMd2TexCoord), this->header.numTexCoords, this->pFile);
-	/* read face data for each triangle (normals) */
-	fseek(this->pFile, this->header.offsetTriangles, SEEK_SET);
-	fread(this->pTriangles, sizeof(tMd2Face), this->header.numTriangles, this->pFile);
-	/* reading all frame data */
-	fseek(this->pFile, this->header.offsetFrames, SEEK_SET);
-	for(int i = 0; i < this->header.numFrames; i++)
-	{
-		tMd2AliasFrame *pFrame = (tMd2AliasFrame *) buffer;
-		this->pFrames[i].pVertices = new tMd2Triangle [this->header.numVertices];
-
-		/* read the frame animation data */
-		fread(pFrame, 1, this->header.frameSize, this->pFile);
-		strcpy(this->pFrames[i].strName, pFrame->name);
-		tMd2Triangle *pVertices = this->pFrames[i].pVertices;
-		/* 
-		   scale translations, store vertices: since id used a non-opengl xyz notation, we have to swap y and z
-		   and negate z axis 
-		*/
-		for(int j = 0; j < this->header.numVertices; j++)
-		{
-			pVertices[j].vertex[0] = pFrame->aliasVertices[j].vertex[0] * pFrame->scale[0] + pFrame->translate[0];
-			pVertices[j].vertex[2] = -1 * (pFrame->aliasVertices[j].vertex[1] * pFrame->scale[1] + pFrame->translate[1]);
-			pVertices[j].vertex[1] = pFrame->aliasVertices[j].vertex[2] * pFrame->scale[2] + pFrame->translate[2];
-		}
-	}
-}
-
-/**
-	\brief this function fills in the animation list for each animation by name and frame
-	\param model
+  unsigned char buffer[MD2_MAX_FRAMESIZE];
+  this->pSkins     = new tMd2Skin[this->header.numSkins];
+  this->pTexCoords = new tMd2TexCoord[this->header.numTexCoords];
+  this->pTriangles = new tMd2Face[this->header.numTriangles];
+  this->pFrames    = new tMd2Frame[this->header.numFrames];
+
+  /* we read the skins */
+  fseek(this->pFile, this->header.offsetSkins, SEEK_SET);
+  fread(this->pSkins, sizeof(tMd2Skin), this->header.numSkins, this->pFile);
+  /* read all vertex data */
+  fseek(this->pFile, this->header.offsetTexCoords, SEEK_SET);
+  fread(this->pTexCoords, sizeof(tMd2TexCoord), this->header.numTexCoords, this->pFile);
+  /* read face data for each triangle (normals) */
+  fseek(this->pFile, this->header.offsetTriangles, SEEK_SET);
+  fread(this->pTriangles, sizeof(tMd2Face), this->header.numTriangles, this->pFile);
+  /* reading all frame data */
+  fseek(this->pFile, this->header.offsetFrames, SEEK_SET);
+  for(int i = 0; i < this->header.numFrames; i++)
+    {
+      tMd2AliasFrame *pFrame = (tMd2AliasFrame *) buffer;
+      this->pFrames[i].pVertices = new tMd2Triangle [this->header.numVertices];
+
+      /* read the frame animation data */
+      fread(pFrame, 1, this->header.frameSize, this->pFile);
+      strcpy(this->pFrames[i].strName, pFrame->name);
+      tMd2Triangle *pVertices = this->pFrames[i].pVertices;
+      /* 
+	 scale translations, store vertices: since id used a non-opengl xyz notation, we have to swap y and z
+	 and negate z axis 
+      */
+      for(int j = 0; j < this->header.numVertices; j++)
+	{
+	  pVertices[j].vertex[0] = pFrame->aliasVertices[j].vertex[0] * pFrame->scale[0] + pFrame->translate[0];
+	  pVertices[j].vertex[2] = -1 * (pFrame->aliasVertices[j].vertex[1] * pFrame->scale[1] + pFrame->translate[1]);
+	  pVertices[j].vertex[1] = pFrame->aliasVertices[j].vertex[2] * pFrame->scale[2] + pFrame->translate[2];
+	}
+    }
+}
+
+/**
+   \brief this function fills in the animation list for each animation by name and frame
+   \param model
 */
 void MD2Loader::parseAnimations(t3DModel *pModel)
 {
-	tAnimationInfo* animationInfo = new tAnimationInfo;
-	string strLastName = "";
-
-	/* the animation parse process looks a little bit weired: this is because there are no 
-	   fix bounds for the animation lengths, so the frames are destingushed using their names
-	   which is normaly composed of <animationname><number>
-	*/
-
-	for(int i = 0; i < pModel->numOfObjects; i++)
-	{
-		string strName  = this->pFrames[i].strName;
-		int frameNum = 0;
+  tAnimationInfo* animationInfo = new tAnimationInfo;
+  string strLastName = "";
+
+  /* the animation parse process looks a little bit weired: this is because there are no 
+     fix bounds for the animation lengths, so the frames are destingushed using their names
+     which is normaly composed of <animationname><number>
+  */
+
+  for(int i = 0; i < pModel->numOfObjects; i++)
+    {
+      string strName  = this->pFrames[i].strName;
+      int frameNum = 0;
 		
-		for(unsigned int j = 0; j < strName.length(); j++)
-		{
-			if( isdigit(strName[j]) && j >= strName.length() - 2)
-			{
-				frameNum = atoi(&strName[j]);
-				strName.erase(j, strName.length() - j);
-				break;
-			}
-		}
-
-		/* animations are sorted through their names: this is how its been done: */
-		if(strName != strLastName || i == pModel->numOfObjects - 1)
-		{
-			if(strLastName != "")
-			{
-				strcpy(animationInfo->strName, strLastName.c_str());
-				animationInfo->endFrame = i;
-				pModel->animationList->add(animationInfo);
-				memset(&animationInfo, 0, sizeof(tAnimationInfo));
-				pModel->numOfAnimations++;
-			}
-			animationInfo->startFrame = frameNum - 1 + i;
-		}
-		strLastName = strName;
-	}
-}
-
-/**
-	\brief this function converts the .md2 structures to our own model and object structures: decompress
-	\param model
+      for(unsigned int j = 0; j < strName.length(); j++)
+	{
+	  if( isdigit(strName[j]) && j >= strName.length() - 2)
+	    {
+	      frameNum = atoi(&strName[j]);
+	      strName.erase(j, strName.length() - j);
+	      break;
+	    }
+	}
+
+      /* animations are sorted through their names: this is how its been done: */
+      if(strName != strLastName || i == pModel->numOfObjects - 1)
+	{
+	  if(strLastName != "")
+	    {
+	      strcpy(animationInfo->strName, strLastName.c_str());
+	      animationInfo->endFrame = i;
+	      pModel->animationList->add(animationInfo);
+	      memset(&animationInfo, 0, sizeof(tAnimationInfo));
+	      pModel->numOfAnimations++;
+	    }
+	  animationInfo->startFrame = frameNum - 1 + i;
+	}
+      strLastName = strName;
+    }
+}
+
+/**
+   \brief this function converts the .md2 structures to our own model and object structures: decompress
+   \param model
 */
 void MD2Loader::convertDataStructures(t3DModel *pModel)
 {
-	int j = 0, i = 0;
+  int j = 0, i = 0;
 	
-	memset(pModel, 0, sizeof(t3DModel));
-	pModel->numOfObjects = this->header.numFrames;
-
-	this->parseAnimations(pModel);
-
-	for (i = 0; i < pModel->numOfObjects; i++)
-	{
-		t3DObject* currentFrame = new t3DObject;
-
-		currentFrame->numOfVerts = this->header.numVertices;
-		currentFrame->numTexVertex = this->header.numTexCoords;
-		currentFrame->numOfFaces = this->header.numTriangles;
-
-		currentFrame->pVerts = new CVector3[currentFrame->numOfVerts];
-
-		for (j = 0; j < currentFrame->numOfVerts; j++)
-		{
-			currentFrame->pVerts[j].x = this->pFrames[i].pVertices[j].vertex[0];
-			currentFrame->pVerts[j].y = this->pFrames[i].pVertices[j].vertex[1];
-			currentFrame->pVerts[j].z = this->pFrames[i].pVertices[j].vertex[2];
-		}
-
-		delete this->pFrames[i].pVertices;
-
-		if( likely(i > 0))
-		{
-			pModel->objectList->add(currentFrame);
-			continue;
-		}
+  memset(pModel, 0, sizeof(t3DModel));
+  pModel->numOfObjects = this->header.numFrames;
+
+  this->parseAnimations(pModel);
+
+  for (i = 0; i < pModel->numOfObjects; i++)
+    {
+      t3DObject* currentFrame = new t3DObject;
+
+      currentFrame->numOfVerts = this->header.numVertices;
+      currentFrame->numTexVertex = this->header.numTexCoords;
+      currentFrame->numOfFaces = this->header.numTriangles;
+
+      currentFrame->pVerts = new CVector3[currentFrame->numOfVerts];
+
+      for (j = 0; j < currentFrame->numOfVerts; j++)
+	{
+	  currentFrame->pVerts[j].x = this->pFrames[i].pVertices[j].vertex[0];
+	  currentFrame->pVerts[j].y = this->pFrames[i].pVertices[j].vertex[1];
+	  currentFrame->pVerts[j].z = this->pFrames[i].pVertices[j].vertex[2];
+	}
+
+      delete this->pFrames[i].pVertices;
+
+      if( likely(i > 0))
+	{
+	  pModel->objectList->add(currentFrame);
+	  continue;
+	}
 			
-		currentFrame->pTexVerts = new CVector2[currentFrame->numTexVertex];
-		currentFrame->pFaces = new tFace[currentFrame->numOfFaces];
-
-		for(j = 0; j < currentFrame->numTexVertex; j++)
-		{
-			currentFrame->pTexVerts[j].x = this->pTexCoords[j].u / float(this->header.skinWidth);
-			currentFrame->pTexVerts[j].y = 1 - this->pTexCoords[j].v / float(this->header.skinHeight);
-		}
-
-		for(j = 0; j < currentFrame->numOfFaces; j++)
-		{
-			currentFrame->pFaces[j].vertIndex[0] = this->pTriangles[j].vertexIndices[0];
-			currentFrame->pFaces[j].vertIndex[1] = this->pTriangles[j].vertexIndices[1];
-			currentFrame->pFaces[j].vertIndex[2] = this->pTriangles[j].vertexIndices[2];
-
-			currentFrame->pFaces[j].coordIndex[0] = this->pTriangles[j].textureIndices[0];
-			currentFrame->pFaces[j].coordIndex[1] = this->pTriangles[j].textureIndices[1];
-			currentFrame->pFaces[j].coordIndex[2] = this->pTriangles[j].textureIndices[2];
-		}
-		pModel->objectList->add(currentFrame);
-	}
-}
-
-
-/**
-	\brief this function conputes the normals of the model
-	\param model
+      currentFrame->pTexVerts = new CVector2[currentFrame->numTexVertex];
+      currentFrame->pFaces = new tFace[currentFrame->numOfFaces];
+
+      for(j = 0; j < currentFrame->numTexVertex; j++)
+	{
+	  currentFrame->pTexVerts[j].x = this->pTexCoords[j].u / float(this->header.skinWidth);
+	  currentFrame->pTexVerts[j].y = 1 - this->pTexCoords[j].v / float(this->header.skinHeight);
+	}
+
+      for(j = 0; j < currentFrame->numOfFaces; j++)
+	{
+	  currentFrame->pFaces[j].vertIndex[0] = this->pTriangles[j].vertexIndices[0];
+	  currentFrame->pFaces[j].vertIndex[1] = this->pTriangles[j].vertexIndices[1];
+	  currentFrame->pFaces[j].vertIndex[2] = this->pTriangles[j].vertexIndices[2];
+
+	  currentFrame->pFaces[j].coordIndex[0] = this->pTriangles[j].textureIndices[0];
+	  currentFrame->pFaces[j].coordIndex[1] = this->pTriangles[j].textureIndices[1];
+	  currentFrame->pFaces[j].coordIndex[2] = this->pTriangles[j].textureIndices[2];
+	}
+      pModel->objectList->add(currentFrame);
+    }
+}
+
+
+/**
+   \brief this function conputes the normals of the model
+   \param model
 */
 void MD2Loader::computeNormals(t3DModel *pModel)
@@ -306,13 +306,13 @@
 
 /**
-	\brief This function cleans up our allocated memory and closes the file
+   \brief This function cleans up our allocated memory and closes the file
 */
 void MD2Loader::cleanUp()
 {
-	fclose(this->pFile);			
+  fclose(this->pFile);			
 	
-	if( this->pSkins) delete [] this->pSkins;		
-	if( this->pTexCoords) delete this->pTexCoords;
-	if( this->pTriangles) delete this->pTriangles;
-	if( this->pFrames) delete this->pFrames;
-}
+  if( this->pSkins) delete [] this->pSkins;		
+  if( this->pTexCoords) delete this->pTexCoords;
+  if( this->pTriangles) delete this->pTriangles;
+  if( this->pFrames) delete this->pFrames;
+}
Index: orxonox/branches/md2_loader/src/story_entities/world.cc
===================================================================
--- orxonox/branches/md2_loader/src/story_entities/world.cc	(revision 4139)
+++ orxonox/branches/md2_loader/src/story_entities/world.cc	(revision 4140)
@@ -491,6 +491,6 @@
   this->model = new t3DModel;
   this->md2Model = new MD2Model();
-  
-  md2loader->importMD2(model, "test.md2", "test.bmp");
+
+  md2loader->importMD2(model, "../data/models/jack/tris.md2", "test.bmp");
 
 }
@@ -953,5 +953,5 @@
 
   /* TESTGING TESTING TESTING */
-  this->md2Model->draw(this->model);
+  //this->md2Model->draw(this->model);
   
   glCallList (objectList);
