Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.cc	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.cc	(revision 8342)
@@ -0,0 +1,15 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.h	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_animation.h	(revision 8342)
@@ -0,0 +1,47 @@
+/*!
+ * @file md3_animation.h
+ *
+ * Code heavely inspired by: JAVA MD3 Model Viewer - A Java based Quake 3 model viewer
+ * Copyright (C) 1999 Erwin 'KLR8' Vervaet
+ */
+
+#ifndef _MD3_ANIMATION_H
+#define _MD3_ANIMATION_H
+
+#include <string>
+
+
+typedef struct AnuimationType
+{};
+
+
+/**
+ * a class with metadata describing an MD3 model animation
+ */
+class MD3Animation
+{
+
+  public:
+    /** create an empty MD3Animation object */
+    MD3Animation() : first(0), numFrames(0), fps(0) {}
+    /** create a new MD3 Anumation object and initialize it with the data on the given line @param line: the line to read from*/
+    MD3Animation(std::string line) : first(0), numFrames(0), fps(0) { /* loadAnimation(); */ }
+
+    std::string toString() { return String("Type: " + this->type + " - name: " + this->name + " - fps: " + fps); }
+
+
+  public:
+    AnimationType    type;                        //!< specifies for what parts of a model this animation is appilcable (e.g. LEGS, BOTH)
+    std::string      name;                        //!< name of the animation
+
+    int              offset;                      //!< for LEGS animation, this is the offset value to skip TORSO frames
+    int              first;                       //!< first frame
+    int              numFrames;                   //!< the number of frames in the anumation. < 0 means that all available frames used
+    int              numLoopFrames;               //!< number of looping frames
+    int              fps;                         //!< frames per second
+
+
+};
+
+
+#endif /* _MD3_ANIMATION_H */
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.cc	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.cc	(revision 8342)
@@ -0,0 +1,15 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.h	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.h	(revision 8342)
@@ -0,0 +1,37 @@
+/*!
+ * @file md3_bone_frame.h
+ *
+ * Code heavely inspired by: JAVA MD3 Model Viewer - A Java based Quake 3 model viewer
+ * Copyright (C) 1999 Erwin 'KLR8' Vervaet
+ */
+
+#ifndef _MD3_BONE_FRAME_H
+#define _MD3_BONE_FRAME_H
+
+#include "vector.h"
+
+
+class MD3BoneFrame
+{
+  public:
+    /** create a MD3BoneFrame object with the data coming from the specified input stream */
+    MD3BoneFrame(int tagNum /*, DataInput din*/) { /* loadBoneFrame(this, din) */ }
+    MD3BoneFrame(int tagNum) { /* this->tags = new MD3Tag[tagNum] */ }
+    virtual ~MD3BondeFrame();
+
+
+  private:
+    Vector         mins;              //!< lower extrema of the bounding box of this bone anumation frame
+    Vector         maxs;              //!< upper extrema of the bounding box of this bone anumation frame
+    Vector         position;          //!< coordinate origin within the bounding box
+
+    std::string    cratorName;        //!< the name of the creator
+    float          scale;             //!< scale of the box
+
+    //MD3Tag      tags[];            //!< arrays of tags size
+
+
+};
+
+
+#endif /* _MD3_BONE_FRAME_H */
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.cc	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.cc	(revision 8342)
@@ -0,0 +1,15 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h	(revision 8342)
@@ -0,0 +1,41 @@
+/*!
+ * @file md3_mesh.h
+ *
+ * Code heavely inspired by: JAVA MD3 Model Viewer - A Java based Quake 3 model viewer
+ * Copyright (C) 1999 Erwin 'KLR8' Vervaet
+ */
+
+#ifndef _MD3_MESH_H
+#define _MD3_MESH_H
+
+class MD3Mesh
+{
+  public:
+
+
+
+  private:
+    std::string        id;                     //!< id of the mesh
+    std::string        name;                   //!< the name of the mesh
+
+    int                numFrameMesh;           //!< number of mesh fames
+    int                numTexture;             //!< number of textures
+    int                numVertex;              //!< number of verteces
+
+    int                numTriangle;            //!< number of triangles
+    int                triangleStart;          //!< start triangle
+    int                textureStart;           //!< start texture
+    int                texVecStart;            //!< texture vector start
+    int                vertexStart;            //!< start of the verteces
+
+    int                meshSize;               //!< the mesh size
+
+
+    //MD3Texture*      textures;                //!< array of textures of size textureNum
+    int*               triangles;               //!< indices into mesh frames and texture coord arrays
+    float*             textureCoords;           //!< U/V textures coordinates of vertices
+    sVec3D*            meshFrames;              //!< mesh frames
+};
+
+
+#endif /* _MD3_MESH_H */
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8342)
@@ -0,0 +1,525 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Patrick Boenzli
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
+
+#include "md2Model.h"
+#include "material.h"
+
+#include "debug.h"
+#include "util/loading/resource_manager.h"
+
+
+using namespace std;
+
+//! the model anorms
+sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
+ #include "anorms.h"
+};
+
+//! anormal dots, no idea of how this shall work, but it does
+float MD2Model::anormsDots[SHADEDOT_QUANT][256] = {
+  #include "anormtab.h"
+};
+
+
+//! the angle under which the model is viewd, used internaly
+float md2Angle = 0.0f;
+
+
+//! list of all different animations a std md2model supports
+sAnim MD2Model::animationList[21] =
+  {
+ // begin, end, fps, interruptable
+    {   0,  39,  9, 1 },   //!< STAND
+    {  40,  45, 10, 1 },   //!< RUN
+    {  46,  53, 10, 0 },   //!< ATTACK
+    {  54,  57,  7, 1 },   //!< PAIN_A
+    {  58,  61,  7, 1 },   //!< PAIN_B
+    {  62,  65,  7, 1 },   //!< PAIN_C
+    {  66,  71,  7, 0 },   //!< JUMP
+    {  72,  83,  7, 1 },   //!< FLIP
+    {  84,  94,  7, 1 },   //!< SALUTE
+    {  95, 111, 10, 1 },   //!< FALLBACK
+    { 112, 122,  7, 1 },   //!< WAVE
+    { 123, 134,  6, 1 },   //!< POINTT
+    { 135, 153, 10, 1 },   //!< CROUCH_STAND
+    { 154, 159,  7, 1 },   //!< CROUCH_WALK
+    { 160, 168, 10, 1 },   //!< CROUCH_ATTACK
+    { 196, 172,  7, 1 },   //!< CROUCH_PAIN
+    { 173, 177,  5, 0 },   //!< CROUCH_DEATH
+    { 178, 183,  10, 0 },   //!< DEATH_FALLBACK
+    { 184, 189,  10, 0 },   //!< DEATH_FALLFORWARD
+    { 190, 197,  10, 0 },   //!< DEATH_FALLBACKSLOW
+    { 198, 198,  5, 1 },   //!< BOOM
+  };
+
+
+
+/********************************************************************************
+ *   MD2Model                                                                   *
+ ********************************************************************************/
+
+/**
+  \brief simple constructor initializing all variables
+*/
+MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
+{
+  this->setClassID(CL_MD2_MODEL, "MD2Model");
+  /* this creates the data container via ressource manager */
+  if (!modelFileName.empty())
+    this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
+  if( unlikely(this->data == NULL))
+    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
+
+  this->scaleFactor = scale;
+
+  shadeDots = MD2Model::anormsDots[0];
+  /* set the animation stat mannualy */
+  this->animationState.type = STAND;
+  this->animationState.numPlays = 1;
+  this->setAnim(STAND);
+
+  this->debug();
+
+    //write the modelinfo information
+  this->pModelInfo.numVertices = this->data->numVertices;
+  this->pModelInfo.numTriangles = this->data->numTriangles;
+  this->pModelInfo.numNormals = 0;
+  this->pModelInfo.numTexCoor = this->data->numTexCoor;
+  this->pModelInfo.pVertices = (float*)this->data->pVertices;
+  this->pModelInfo.pNormals = NULL;
+  this->pModelInfo.pTexCoor = (float*)this->data->pTexCoor;
+
+  // triangle conversion
+  this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
+  for( int i = 0; i < this->data->numTriangles; i++)
+  {
+    this->pModelInfo.pTriangles[i].indexToVertices[0] = this->data->pTriangles[i].indexToVertices[0];
+    this->pModelInfo.pTriangles[i].indexToVertices[1] = this->data->pTriangles[i].indexToVertices[1];
+    this->pModelInfo.pTriangles[i].indexToVertices[2] = this->data->pTriangles[i].indexToVertices[2];
+
+    this->pModelInfo.pTriangles[i].indexToTexCoor[0] = this->data->pTriangles[i].indexToTexCoor[0];
+    this->pModelInfo.pTriangles[i].indexToTexCoor[1] = this->data->pTriangles[i].indexToTexCoor[1];
+    this->pModelInfo.pTriangles[i].indexToTexCoor[2] = this->data->pTriangles[i].indexToTexCoor[2];
+  }
+}
+
+
+/**
+  \brief simple destructor, dereferencing all variables
+
+  this is where the ressource manager is cleaning the stuff
+*/
+MD2Model::~MD2Model()
+{
+  this->pModelInfo.pVertices = NULL;
+  this->pModelInfo.pNormals = NULL;
+  this->pModelInfo.pTexCoor = NULL;
+  this->pModelInfo.pTriangles = NULL;
+
+  ResourceManager::getInstance()->unload(this->data);
+}
+
+
+/**
+ *  initializes an array of vert with the current frame scaled vertices
+ * @param this->verticesList: the list of vertices to interpolate between
+
+   we won't use the pVertices array directly, since its much easier and we need
+   saving of data anyway
+*/
+void MD2Model::interpolate(/*sVec3D* this->verticesList*/)
+{
+  sVec3D* currVec;
+  sVec3D* nextVec;
+
+  currVec = &this->data->pVertices[this->data->numVertices * this->animationState.currentFrame];
+  nextVec = &this->data->pVertices[this->data->numVertices * this->animationState.nextFrame];
+
+  for( int i = 0; i < this->data->numVertices; ++i)
+    {
+      this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
+      this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
+      this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
+    }
+}
+
+
+/**
+  \brief sets the animation type
+* @param type: animation type
+
+  the animation types can be looked up in the animationType table
+*/
+void MD2Model::setAnim(int type, int animPlayback)
+{
+  if( (type < 0) || (type > MAX_ANIMATIONS) )
+    type = STAND;
+
+  if( MD2Model::animationList[this->animationState.type].bStoppable == 0)
+  {
+    if( this->animationState.numPlays == 0 )
+      return;
+  }
+
+  this->animationState.startFrame = animationList[type].firstFrame;
+  this->animationState.endFrame = animationList[type].lastFrame;
+  this->animationState.nextFrame = animationList[type].firstFrame + 1;
+  this->animationState.fps = animationList[type].fps;
+  this->animationState.type = type;
+  this->animationState.numPlays = 0;
+  this->animationState.animPlaybackMode = animPlayback;
+
+  this->animationState.interpolationState = 0.0f;
+  this->animationState.localTime = 0.0f;
+  this->animationState.lastTime = 0.0f;
+  this->animationState.currentFrame = animationList[type].firstFrame;
+}
+
+
+/**
+  \brief sets the time in seconds passed since the last tick
+* @param time: in sec
+*/
+void MD2Model::tick(float time)
+{
+  this->animate(time);
+  this->processLighting();
+  this->interpolate(/*this->verticesList*/);
+}
+
+
+/**
+ * @brief draws the model: interface for all other classes out in the world
+ * @todo make it const and virtual
+ * FIXME
+ */
+void MD2Model::draw() const
+{
+  glPushMatrix();
+  this->renderFrame();
+  // renderFrameTriangles();
+  glPopMatrix();
+}
+
+
+/**
+  \brief this is an internal function to render this special frame selected by animate()
+*/
+void MD2Model::renderFrame() const
+{
+  int* pCommands = this->data->pGLCommands;
+
+  /* some face culling stuff */
+  glPushAttrib(GL_POLYGON_BIT);
+  glFrontFace(GL_CW);
+  glEnable(GL_CULL_FACE);
+  glCullFace(GL_BACK);
+
+  this->data->material.select();
+
+  /* draw the triangles */
+  while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */
+    {
+      if( i < 0)
+        {
+          glBegin(GL_TRIANGLE_FAN);
+          i = -i;
+        }
+      else
+        {
+          glBegin(GL_TRIANGLE_STRIP);
+        }
+
+      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
+        {
+          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
+          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
+          glVertex3fv(this->verticesList[pCommands[2]]);
+        }
+      glEnd();
+
+    }
+  glDisable(GL_CULL_FACE);
+  glPopAttrib();
+}
+
+
+void MD2Model::renderFrameTriangles() const
+{
+  //static sVec3D this->verticesList[MD2_MAX_VERTICES]; /* performance: created only once in a lifetime */
+  int* pCommands = this->data->pGLCommands;
+  /* some face culling stuff */
+//   glPushAttrib(GL_POLYGON_BIT);
+//   glFrontFace(GL_CW);
+//   glEnable(GL_CULL_FACE);
+//   glCullFace(GL_BACK);
+//
+//   this->processLighting();
+//   this->interpolate(/*this->verticesList*/);
+  this->data->material.select();
+
+  /* draw the triangles */
+  glBegin(GL_TRIANGLES);
+
+  for( int i = 0, k = 0; i < this->data->numTriangles; ++i, k += 3)
+  {
+    float* v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]];
+
+    printf("triangle: %i\n", i);
+    printf("     v0: (%f, %f, %f)\n", v[0], v[1], v[2]);
+    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]];
+    printf("     v1: (%f, %f, %f)\n", v[0], v[1], v[2]);
+    v = this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]];
+    printf("     v2: (%f, %f, %f)\n", v[0], v[1], v[2]);
+
+
+    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
+    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[0]]);
+
+    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
+    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[1]]);
+
+    glNormal3f(anorms[i][0], anorms[i][1], anorms[i][2]);
+    glVertex3fv(this->data->pVertices[this->data->pTriangles[i].indexToVertices[2]]);
+  }
+
+  glEnd();
+}
+
+
+/**
+  \brief animates the current model
+
+  depending on the time passed (tick function), the player will select another model
+*/
+void MD2Model::animate(float time)
+{
+  this->animationState.localTime += time;
+
+  if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
+    {
+      this->animationState.currentFrame = this->animationState.nextFrame;
+      this->animationState.nextFrame++;
+
+      if( this->animationState.nextFrame > this->animationState.endFrame )
+      {
+        if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
+        {
+          this->animationState.nextFrame = this->animationState.startFrame;
+          this->animationState.numPlays++;
+        }
+        else
+        {
+          this->animationState.nextFrame = this->animationState.endFrame;
+        }
+      }
+      this->animationState.lastTime = this->animationState.localTime;
+    }
+
+//     if( this->animationState.currentFrame > (this->data->numFrames - 1) )
+//       this->animationState.currentFrame = 0;
+
+//     if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
+//     this->animationState.nextFrame = 0;
+
+  this->animationState.interpolationState = this->animationState.fps *
+    (this->animationState.localTime - this->animationState.lastTime);
+}
+
+
+/**
+  \brief this is how id is precessing their lightning
+
+  the details of how the whole lighting process is beeing handled - i have no idea... :)
+*/
+void MD2Model::processLighting()
+{
+  shadeDots = anormsDots[((int)(md2Angle*(SHADEDOT_QUANT / 360.0)))&(SHADEDOT_QUANT - 1)];
+}
+
+
+/**
+  \brief prints out debug informations
+*/
+void MD2Model::debug()
+{
+  PRINT(0)("\n==========================| MD2Model::debug() |===\n");
+  PRINT(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
+  PRINT(0)("=  Skin FileName:\t%s\n", this->data->skinFileName.c_str());
+  PRINT(0)("=  Size in Memory:\t%i Bytes\n", this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
+  PRINT(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
+  PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
+  PRINT(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
+  PRINT(0)("=  Pointer to the data object: %p\n", this->data);
+  PRINT(0)("===================================================\n\n");
+}
+
+
+/********************************************************************************
+ *   MD2Data                                                                    *
+ ********************************************************************************/
+
+/**
+  \brief simple constructor
+*/
+MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
+{
+  scale *= 0.1f;
+
+  this->pVertices = NULL;
+  this->pGLCommands = NULL;
+  this->pLightNormals = NULL;
+  this->pTexCoor = NULL;
+
+  this->numFrames = 0;
+  this->numVertices = 0;
+  this->numGLCommands = 0;
+  this->numTexCoor = 0;
+
+//   this->scaleFactor = 1.0f;
+  this->scaleFactor = scale;
+
+  this->fileName = "";
+  this->skinFileName = "";
+  this->loadModel(modelFileName);
+  this->loadSkin(skinFileName);
+}
+
+
+/**
+  \brief simple destructor
+
+  this will clean out all the necessary data for a specific md2model
+*/
+MD2Data::~MD2Data()
+{
+  delete this->header;
+
+  delete [] this->pVertices;
+  delete [] this->pGLCommands;
+  delete [] this->pLightNormals;
+  delete [] this->pTexCoor;
+}
+
+
+
+/**
+  \brief this will load the whole model data (vertices, opengl command list, ...)
+* @param fileName: the name of the model file
+  \return true if success
+*/
+bool MD2Data::loadModel(const std::string& fileName)
+{
+  FILE *pFile;                            //file stream
+  char* buffer;                           //buffer for frame data
+  sFrame* frame;                          //temp frame
+  sVec3D *pVertex;
+  int* pNormals;
+
+  //! @todo this chek should include deleting a loaded model (eventually)
+  if (fileName.empty())
+    return false;
+
+  pFile = fopen(fileName.c_str(), "rb");
+  if( unlikely(!pFile))
+    {
+      PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
+      return false;
+    }
+  this->header = new MD2Header;
+  fread(this->header, 1, sizeof(MD2Header), pFile);
+  /* check for the header version: make sure its a md2 file :) */
+  if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
+    {
+      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
+      return false;
+    }
+
+  this->fileName =fileName;
+  /* got the data: map it to locals */
+  this->numFrames = this->header->numFrames;
+  this->numVertices = this->header->numVertices;
+  this->numTriangles = this->header->numTriangles;
+  this->numGLCommands = this->header->numGlCommands;
+  this->numTexCoor = this->header->numTexCoords;
+  /* allocate memory for the data storage */
+  this->pVertices = new sVec3D[this->numVertices * this->numFrames];
+  this->pGLCommands = new int[this->numGLCommands];
+  this->pLightNormals = new int[this->numVertices * this->numFrames];
+  this->pTriangles = new sTriangle[this->numTriangles];
+  this->pTexCoor = new sTexCoor[this->numTexCoor];
+  buffer = new char[this->numFrames * this->header->frameSize];
+
+
+  /* read frame data from the file to a temp buffer */
+  fseek(pFile, this->header->offsetFrames, SEEK_SET);
+  fread(buffer, this->header->frameSize, this->numFrames, pFile);
+  /* read opengl commands */
+  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
+  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
+  /* triangle list */
+  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
+  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
+  /*  read in texture coordinates */
+  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
+  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
+
+
+  for(int i = 0; i < this->numFrames; ++i)
+    {
+      frame = (sFrame*)(buffer + this->header->frameSize * i);
+      pVertex = this->pVertices + this->numVertices  * i;
+      pNormals = this->pLightNormals + this->numVertices * i;
+
+      for(int j = 0; j < this->numVertices; ++j)
+        {
+          /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
+           pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
+           pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
+           pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
+
+          //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
+
+          pNormals[j] = frame->pVertices[j].lightNormalIndex;
+        }
+    }
+    PRINTF(4)("Finished loading the md2 file\n");
+
+  delete [] buffer;
+  fclose(pFile);
+}
+
+
+/**
+  \brief loads the skin/material stuff
+* @param fileName: name of the skin file
+  \return true if success
+*/
+bool MD2Data::loadSkin(const std::string& fileName)
+{
+  if( fileName.empty())
+    {
+      this->skinFileName = "";
+      return false;
+    }
+
+  this->skinFileName = fileName;
+
+  this->material.setName("md2ModelMaterial");
+  this->material.setDiffuseMap(fileName);
+  this->material.setIllum(3);
+  this->material.setAmbient(1.0, 1.0, 1.0);
+}
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8342)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8342)
@@ -0,0 +1,269 @@
+/*!
+ * @file md2Model.h
+  *  Definition of an MD2 Model, a model format invented by ID Software.
+
+    We are deeply thankfull for all the wunderfull things id software made for us gamers!
+
+    The md2 file format is structured in a very simple way: it contains animations which are made out of
+    frames (so called keyframes). Each frame is a complete draweable model in a specific position.
+    A frame is a collection of vertex and its compagnions (normals, texture coordinates).
+
+    A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently
+    512 frames. The maximal vetices count is set to 2048 verteces, not enough?
+    You just have to change the MD2_MAX_* values if it doesn't fit your purposes...
+
+    Surface Culling is fully implemented in md2 models: quake2 uses front face culling.
+*/
+
+#ifndef _MD2MODEL_H
+#define _MD2MODEL_H
+
+#include "base_object.h"
+
+#include "model.h"
+#include "material.h"
+
+//! These are the needed defines for the max values when loading .MD2 files
+#define MD2_IDENT                       (('2'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md2 identifier tag in the bin file
+#define MD2_VERSION                     8                                        //!< the md2 version in the header
+#define MD2_MAX_TRIANGLES               4096                                     //!< maximal triangles count
+#define MD2_MAX_VERTICES                2048                                     //!< maximal vertices count
+#define MD2_MAX_TEXCOORDS               2048                                     //!< maximal tex coordinates
+#define MD2_MAX_FRAMES                  512                                      //!< maximal frames
+#define MD2_MAX_SKINS                   32                                       //!< maximal skins
+#define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)             //!< maximal framesize
+
+#define NUM_VERTEX_NORMALS              162                                      //!< number of vertex normals
+#define SHADEDOT_QUANT                  16                                       //!< shade dot quantity - no idea what it is
+
+//! This stores the speed of the animation between each key frame - currently conflicting with the animation framework
+#define kAnimationSpeed                 12.0f                                    //!< animation speed
+
+//! This holds the header information that is read in at the beginning of the file: id software definition
+struct MD2Header
+{
+   int ident;                           //!< This is used to identify the file
+   int version;                         //!< The version number of the file (Must be 8)
+
+   int skinWidth;                       //!< The skin width in pixels
+   int skinHeight;                      //!< The skin height in pixels
+   int frameSize;                       //!< The size in bytes the frames are
+
+   int numSkins;                        //!< The number of skins associated with the model
+   int numVertices;                     //!< The number of vertices (constant for each frame)
+   int numTexCoords;                    //!< The number of texture coordinates
+   int numTriangles;                    //!< The number of faces (polygons)
+   int numGlCommands;                   //!< The number of gl commands
+   int numFrames;                       //!< The number of animation frames
+
+   int offsetSkins;                     //!< The offset in the file for the skin data
+   int offsetTexCoords;                 //!< The offset in the file for the texture data
+   int offsetTriangles;                 //!< The offset in the file for the face data
+   int offsetFrames;                    //!< The offset in the file for the frames data
+   int offsetGlCommands;                //!< The offset in the file for the gl commands data
+   int offsetEnd;                       //!< The end of the file offset
+};
+
+
+//! compressed vertex data: char insetead of float, the value will be expanded by the scale value. only for loading
+typedef struct
+{
+  unsigned char    v[3];                 //!< the vector of the vertex
+  unsigned char    lightNormalIndex;     //!< the index of the light normal
+} sVertex;
+
+
+//! compressed texture offset data: coords scaled by the texture size. Only for loading
+typedef struct
+{
+  short            s;                    //!< the s,t coordinates of a texture
+  short            t;                    //!< the s,t coordinates of a texture
+} sTexCoor;
+
+
+//! holds tha informations about a md2 frame
+typedef struct
+{
+  sVec3D           scale;                //!< scales values of the model
+  sVec3D           translate;            //!< translates the model
+  char             name[16];             //!< frame name: something like "run32"
+  sVertex          pVertices[1];         //!< first vertex of thes frame
+} sFrame;
+
+
+//! holds the information about a triangle
+typedef struct
+{
+  unsigned short   indexToVertices[3];   //!< index to the verteces of the triangle
+  unsigned short   indexToTexCoor[3];    //!< index to the texture coordinates
+} sTriangle;
+
+
+
+//! the command list of the md2 model, very md2 specific
+typedef struct
+{
+  float            s;                    //!< texture coordinate 1
+  float            t;                    //!< texture coordinate 2
+  int              vertexIndex;          //!< index of the vertex in the vertex list
+} glCommandVertex;
+
+
+//! a md2 animation definition
+typedef struct
+{
+  int              firstFrame;           //!< first frame of the animation
+  int              lastFrame;            //!< last frame of the animation
+  int              fps;                  //!< speed: number of frames per second
+  int              bStoppable;           //!< 1 if the animation is stoppable 0 else
+} sAnim;
+
+
+//! animation state definition
+typedef struct
+{
+  int              startFrame;           //!< the start frame of an animation
+  int              endFrame;             //!< last frame of the animation
+  int              fps;                  //!< fps of the animaion (speed)
+
+  float            localTime;            //!< the local time
+  float            lastTime;             //!< last time stamp
+  float            interpolationState;   //!< the state of the animation [0..1]
+
+  int              type;                 //!< animation type
+
+  int              currentFrame;         //!< the current frame
+  int              nextFrame;            //!< the next frame in the list
+  int              numPlays;             //!< the number of times, this has been played in series
+
+  int              animPlaybackMode;     //!< the playback mode
+} sAnimState;
+
+
+//! animation names enumeration
+typedef enum animType
+  {
+    STAND,                       //0
+    RUN,                         //1
+    ATTACK,                      //2
+    PAIN_A,                      //3
+    PAIN_B,                      //4
+    PAIN_C,          //5
+    JUMP,            //6
+    FLIP,            //7
+    SALUTE,          //8
+    FALLBACK,        //9
+    WAVE,            //10
+    POINT,           //11
+    CROUCH_STAND,
+    CROUCH_WALK,
+    CROUCH_ATTACK,
+    CROUCH_PAIN,
+    CROUCH_DEATH,
+    DEATH_FALLBACK,
+    DEATH_FALLFORWARD,
+    DEATH_FALLBACKSLOW,
+    BOOM,
+
+    MAX_ANIMATIONS
+  };
+
+
+typedef enum animPlayback
+{
+  MD2_ANIM_LOOP = 0,
+  MD2_ANIM_ONCE,
+
+  MD2_ANIM_NUM
+};
+
+
+
+/* forward definitions */
+class Material;
+
+
+
+//! class to store the md2 data in
+class MD2Data : public BaseObject
+{
+ public:
+   MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
+  virtual ~MD2Data();
+
+ private:
+   bool loadModel(const std::string& fileName);
+   bool loadSkin(const std::string& fileName = "");
+
+ public:
+  int                numFrames;             //!< number of frames
+  int                numVertices;           //!< number of vertices
+  int                numTriangles;          //!< number of triangles
+  int                numTexCoor;            //!< number of texture coordinates
+  int                numGLCommands;         //!< number of gl commands in the glList (tells how to draw)
+  std::string        fileName;              //!< file name of the model File
+  std::string        skinFileName;          //!< file name of the skin file
+  MD2Header*         header;                //!< the header file
+
+  sVec3D*            pVertices;             //!< pointer to the vertices data block
+  sTriangle*         pTriangles;            //!< pointer to the triangles data
+  sTexCoor*          pTexCoor;              //!< pointer to the texture coordinate data
+  int*               pGLCommands;           //!< pointer to the gllist data block
+  int*               pLightNormals;         //!< pointer to the light normals
+
+  Material           material;              //!< pointer to the material
+  float              scaleFactor;           //!< the scale factor of the model, (global)
+};
+
+
+
+
+//! This is a MD2 Model class
+class MD2Model : public Model {
+
+public:
+  MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
+  virtual ~MD2Model();
+
+  virtual void draw() const;
+  void renderFrameTriangles() const;
+
+
+  void setAnim(int type, int animPlayback = MD2_ANIM_LOOP);
+  /**  returns the current animation @returns animation type */
+  inline int MD2Model::getAnim() { return this->animationState.type; }
+  /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
+  void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
+
+  virtual void tick(float dtS);
+  void debug();
+
+
+private:
+  void animate(float time);
+  void processLighting();
+  void interpolate(/*sVec3D* verticesList*/);
+  void renderFrame() const ;
+
+
+ public:
+  /* these variables are static, because they are all the same for every model */
+  static sVec3D       anorms[NUM_VERTEX_NORMALS];       //!< the anormals
+  static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
+  static sAnim        animationList[21];                //!< the anomation list
+   //! again one of these strange id software parts
+  float*              shadeDots;
+
+  MD2Data*            data;                             //!< the md2 data pointer
+
+ private:
+  float               scaleFactor;                      //!< the scale factor (individual)
+  sAnimState          animationState;                   //!< animation state of the model
+  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
+};
+
+
+
+
+
+#endif /* _MD2MODEL_H */
