Index: trunk/src/lib/collision_detection/cd_engine.cc
===================================================================
--- trunk/src/lib/collision_detection/cd_engine.cc	(revision 8450)
+++ trunk/src/lib/collision_detection/cd_engine.cc	(revision 8490)
@@ -20,4 +20,6 @@
 #include "debug.h"
 
+#include "class_list.h"
+
 #include "model.h"
 #include "world_entity.h"
@@ -30,4 +32,5 @@
 
 #include "bsp_manager.h"
+#include "bsp_entity.h"
 
 using namespace std;
@@ -97,21 +100,18 @@
 void CDEngine::checkCollisionGround(std::list<WorldEntity*>& list1)
 {
-  if( likely( this->terrain != NULL))
-  {
-//    Quadtree* q = dynamic_cast<Terrain*>(this->terrain)->ssp->getQuadtree();
-//    QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor());
-  }
 
-  if( likely( this->bspManager != NULL))
-  {
-    std::list<WorldEntity*>::iterator iterator;
-    PRINTF(3)("checking for collisions\n");
+  std::list<BaseObject*>::const_iterator bspIterator;
+  std::list<WorldEntity*>::iterator entityIterator;
+  const std::list<BaseObject*>* bspList = ClassList::getList(CL_BSP_ENTITY);
+  if( bspList == NULL)
+    return;
 
-    iterator = list1.begin();
-    while (iterator != list1.end())
-    {
-      bspManager->checkCollision(*iterator);
-      iterator++;
-    }
+  // for all bsp managers check all entities
+  for( bspIterator = bspList->begin(); bspIterator != bspList->end(); bspIterator++) {
+      for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
+      {
+//         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassName());
+        (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
+      }
   }
 }
@@ -128,5 +128,4 @@
   PRINT(0)("=  CDEngine: Spawning Tree: Finished\n");
   PRINT(0)("=======================================================\n");
-
 }
 
@@ -149,4 +148,5 @@
 }
 
+
 /**
  * this draws the debug spawn tree
Index: trunk/src/lib/collision_reaction/Makefile.am
===================================================================
--- trunk/src/lib/collision_reaction/Makefile.am	(revision 8450)
+++ trunk/src/lib/collision_reaction/Makefile.am	(revision 8490)
@@ -9,5 +9,6 @@
                      collision_handle.cc \
                      collision_reaction.cc \
-                     cr_object_damage.cc
+                     cr_object_damage.cc \
+                     cr_physics_ground_walk.cc
 
 
@@ -19,4 +20,5 @@
                      cr_defs.h \
                      collision_reaction.h \
-                     cr_object_damage.h
+                     cr_object_damage.h \
+                     cr_physics_ground_walk.h
 
Index: trunk/src/lib/collision_reaction/collision.h
===================================================================
--- trunk/src/lib/collision_reaction/collision.h	(revision 8450)
+++ trunk/src/lib/collision_reaction/collision.h	(revision 8490)
@@ -27,5 +27,5 @@
 
     /** collides two WorldEntities @param entityA world entity A, @param entityB world entity B, @param bvA volume A @param bvB volumeB */
-    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; }
+    inline void collide(WorldEntity* entityA, WorldEntity* entityB) { this->entityA = entityA; this->entityB = entityB; this->bDispatched = false; }
 
 
@@ -42,4 +42,5 @@
     /** sets the flag if it reacts @param flag true if it should react on entityB*/
     inline void setEntityBCollide(bool flag) { this->entityACollide = flag; }
+
 
     /** @returns true if this Collision has already been dispatched */
Index: trunk/src/lib/collision_reaction/collision_event.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_event.h	(revision 8450)
+++ trunk/src/lib/collision_reaction/collision_event.h	(revision 8490)
@@ -25,6 +25,6 @@
   { this->entityA = entityA; this->entityB = entityB; this->bvA = bvA; this->bvB = bvB; }
   /** collides two WorldEntities @param entity world entity , @param ground ground plane, @param position position on the ground */
-  inline void collide(WorldEntity* entity, Plane* ground, Vector position)
-  { this->entityA = entity; this->ground = ground; this->position = position; }
+  inline void collide(WorldEntity* entity, WorldEntity* groundEntity, Vector normal, Vector position)
+  { this->entityA = entity; this->entityB = groundEntity, this->groundNormal = normal; this->position = position; }
 
 
@@ -38,8 +38,9 @@
   inline BoundingVolume* getBVB() const { return this->bvB; }
 
+  /** @return ground plane if collided with bsp model */
+  inline Vector getGroundNormal() { return this->groundNormal; }
 
-  inline void operator()(WorldEntity* entityA, WorldEntity* entityB, BoundingVolume* bvA, BoundingVolume* bvB) { this->collide(entityA, entityB, bvA, bvB); }
-  inline void operator()(WorldEntity* entity, Plane* ground, Vector position) { this->collide(entity, ground, position); }
-
+  /** @return position of the position, only accurate if this is a collision with the ground!!! */
+  inline Vector getCollisionPosition() { return this->position; }
 
  private:
@@ -50,5 +51,5 @@
   BoundingVolume*   bvB;                           //!< reference to the bounding volume B
 
-  Plane*            ground;                        //!< the ground plane with which it collides (only for bsp-model collisions
+  Vector            groundNormal;                  //!< the ground plane with which it collides (only for bsp-model collisions
   Vector            position;                      //!< position of the collision on the ground plane
 };
Index: trunk/src/lib/collision_reaction/collision_handle.cc
===================================================================
--- trunk/src/lib/collision_reaction/collision_handle.cc	(revision 8450)
+++ trunk/src/lib/collision_reaction/collision_handle.cc	(revision 8490)
@@ -24,4 +24,5 @@
 
 #include "cr_object_damage.h"
+#include "cr_physics_ground_walk.h"
 
 #include "debug.h"
@@ -42,20 +43,24 @@
 
   this->bCollided = false;
-  this->bDispatched = false;
-
-  if( this->type == CREngine::CR_PHYSICS_STEP_BACK)
-    this->bContinuousPoll = false;
-  else
-    this->bContinuousPoll = true;
-
-  if( this->type == CREngine::CR_OBJECT_DAMAGE)
-    this->bStopOnFirstCollision = true;
-  else
-   this->bStopOnFirstCollision = false;
+  this->bDispatched = true;
+
+  this->collisionReaction = NULL;
+  this->bContinuousPoll = false;
+  this->bStopOnFirstCollision = false;
+
 
   switch( type)
   {
+    case CREngine::CR_PHYSICS_STEP_BACK:
+//       this->collisionReaction = new CRPhysicsGroundWalk();
+      this->bContinuousPoll = true;
+      break;
+    case CREngine::CR_PHYSICS_GROUND_WALK:
+      this->collisionReaction = new CRPhysicsGroundWalk();
+      this->bContinuousPoll = true;
+      break;
     case CREngine::CR_OBJECT_DAMAGE:
       this->collisionReaction = new CRObjectDamage();
+      this->bStopOnFirstCollision = true;
       break;
     default:
@@ -71,4 +76,6 @@
 {
   // delete what has to be deleted here
+  if( this->collisionReaction != NULL)
+    delete this->collisionReaction;
 }
 
@@ -169,4 +176,5 @@
 
  c->registerCollisionEvent(collisionEvent);
+ PRINTF(0)("Registering Collision Event: %s, %s\n", collisionEvent->getEntityA()->getClassName(), collisionEvent->getEntityB()->getClassName());
 }
 
@@ -186,4 +194,11 @@
 void CollisionHandle::handleCollisions()
 {
+  // if continuous poll poll the reaction
+  if( this->bContinuousPoll && !this->bCollided)
+  {
+    this->collisionReaction->update(this->owner);
+    return;
+  }
+
   // collision reaction calculations (for every collision there will be a reaction)
   vector<Collision*>::iterator it = this->collisionList.begin();
@@ -214,9 +229,15 @@
   {
     if( collisionEvent->getEntityA() == this->owner) {
-      if( collisionEvent->getEntityA()->isA((ClassID)(*it)))
+      if( collisionEvent->getEntityB()->isA((ClassID)(*it))) {
+        PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
+                  collisionEvent->getEntityB()->getClassName(), *it);
         return true; }
+    }
     else {
-      if( collisionEvent->getEntityB()->isA((ClassID)(*it)))
-        return true; }
+      if( collisionEvent->getEntityA()->isA((ClassID)(*it))) {
+        PRINTF(0)("I am: %s colliding with: %s is a %i filter ok\n", owner->getClassName(),
+                  collisionEvent->getEntityA()->getClassName(), *it);
+      return true; }
+    }
   }
 
Index: trunk/src/lib/collision_reaction/collision_handle.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_handle.h	(revision 8450)
+++ trunk/src/lib/collision_reaction/collision_handle.h	(revision 8490)
@@ -41,4 +41,6 @@
     /** @returns true if this handle should be pulled also if there are no collisions */
     inline bool isContinuousPoll() const { return this->bContinuousPoll; }
+    /** @returns the type */
+    inline CREngine::CRType getType() const { return this->type; }
 
     void handleCollisions();
Index: trunk/src/lib/collision_reaction/collision_reaction.h
===================================================================
--- trunk/src/lib/collision_reaction/collision_reaction.h	(revision 8450)
+++ trunk/src/lib/collision_reaction/collision_reaction.h	(revision 8490)
@@ -12,4 +12,6 @@
 
 class Collision;
+class WorldEntity;
+
 
 //! A class representing a simple collision
@@ -23,4 +25,7 @@
     virtual void reactToCollision(Collision* collision) = 0;
 
+    virtual void update(WorldEntity* owner) {}
+
+    /** use this to do some collision offline calculations, only called for bContinuousPoll == true */
     inline bool isContinuousPoll() const { return this->bContinuousPoll; }
 
Index: trunk/src/lib/collision_reaction/cr_engine.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_engine.cc	(revision 8450)
+++ trunk/src/lib/collision_reaction/cr_engine.cc	(revision 8490)
@@ -126,8 +126,6 @@
 {
   std::vector<CollisionHandle*>::iterator it;
-  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
-  {
-    if( *it == collisionHandle)
-    {
+  for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)  {
+    if( *it == collisionHandle) {
       this->collisionHandles.erase(it);
       delete collisionHandle;
@@ -147,5 +145,5 @@
   for( it = this->collisionHandles.begin(); it != this->collisionHandles.end(); it++)
   {
-    if( (*it)->isCollided() || (*it)->isContinuousPoll())  //does it have any collisions to report at all
+    if( !(*it)->isDispatched() || (*it)->isContinuousPoll())  //does it have any collisions to report at all
     {
       (*it)->handleCollisions();
Index: trunk/src/lib/collision_reaction/cr_object_damage.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 8450)
+++ trunk/src/lib/collision_reaction/cr_object_damage.cc	(revision 8490)
@@ -54,7 +54,7 @@
 void CRObjectDamage::reactToCollision(Collision* collision)
 {
-  float damage;
+  float damage = 0.0f;
 
-  PRINTF(0)("Dealing damage - Handling collision: %s vs %s\n",
+  PRINTF(4)("Dealing damage - Handling collision: %s vs %s\n",
             collision->getEntityA()->getClassName(),
             collision->getEntityB()->getClassName());
@@ -65,5 +65,5 @@
     collision->getEntityA()->decreaseHealth(damage);
   }
-  PRINTF(0)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
+  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityA()->getClassName());
 
   if( collision->isEntityBCollide()) {
@@ -71,5 +71,5 @@
     collision->getEntityB()->decreaseHealth(damage);
   }
-  PRINTF(0)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
+  PRINTF(4)("Dealing damage - %f damage to %s \n", damage, collision->getEntityB()->getClassName());
 
   collision->flushCollisionEvents();
Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8490)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8490)
@@ -0,0 +1,88 @@
+/*
+   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
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_COLLISION_REACTION
+
+#include "collision.h"
+#include "collision_event.h"
+
+#include "physics_interface.h"
+
+#include "world_entity.h"
+#include "cr_physics_ground_walk.h"
+
+#include "debug.h"
+
+#include <vector>
+
+using namespace std;
+
+
+/**
+ *  standard constructor
+ */
+CRPhysicsGroundWalk::CRPhysicsGroundWalk ()
+  : CollisionReaction()
+{
+  this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk");
+}
+
+
+/**
+ *  standard deconstructor
+ */
+CRPhysicsGroundWalk::~CRPhysicsGroundWalk ()
+{
+}
+
+
+/**
+ * caluculates and applys the reaction to a specific collision
+ *  @param collision the collision
+ */
+void CRPhysicsGroundWalk::reactToCollision(Collision* collision)
+{
+  CollisionEvent* ce = collision->getCollisionEvents().front();
+  Vector normal = ce->getGroundNormal();
+  normal.normalize();
+
+  // put it back
+//   PRINTF(0)("putting it back to lastPos: \n");
+//   this->lastPositions[0].debug();
+//   PRINTF(0)("current pos:\n");
+//   collision->getEntityB()->getAbsCoor().debug();
+
+  PRINTF(0)("Collision with Ground: \n");
+  collision->getEntityB()->getAbsCoor().debug();
+
+  //collision->getEntityB()->setVelocity(Vector());
+  //collision->getEntityB()->setAbsCoor(this->lastPositions[5]);
+}
+
+
+
+/**
+ * use this to do some collision offline calculations, only called for bContinuousPoll == true
+ */
+void CRPhysicsGroundWalk::update(WorldEntity* owner)
+{
+  for( int i = 9; i > 0; i--) {
+    this->lastPositions[i] = this->lastPositions[i-1];
+//     PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);
+  }
+  this->lastPositions[0] = owner->getAbsCoor();
+}
+
+
Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.h
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.h	(revision 8490)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.h	(revision 8490)
@@ -0,0 +1,33 @@
+/*!
+ * @file cr_object_damage.h
+ *  Definition of a collision reaction: dealing damage to an object
+ */
+
+#ifndef _CR_PHYSICS_GROUND_WALK_H
+#define _CR_PHYSICS_GROUND_WALK_H
+
+#include "collision_reaction.h"
+
+
+class Collision;
+
+//! A class representing a reaction to a collision: dealing damage to an object
+class CRPhysicsGroundWalk : public CollisionReaction
+{
+  public:
+    CRPhysicsGroundWalk();
+    virtual ~CRPhysicsGroundWalk();
+
+    virtual void reactToCollision(Collision* collision);
+
+    virtual void update(WorldEntity* entity);
+
+  private:
+    Vector       lastPosition;                //!< vector with the last valid position
+    Vector       afterLastPosition;           //!< vector for the after last
+    Quaternion   lastDirection;               //!< quat with the last valid direction
+
+    Vector       lastPositions[10];           //!< last 10 positions
+};
+
+#endif /* _CR_PHYSICS_GROUND_WALK_H */
Index: trunk/src/lib/coord/p_node.h
===================================================================
--- trunk/src/lib/coord/p_node.h	(revision 8450)
+++ trunk/src/lib/coord/p_node.h	(revision 8490)
@@ -103,4 +103,6 @@
   /** @returns the absolute position */
   inline const Vector& getAbsCoor () const { return this->absCoordinate; };
+  /** @returns the absolute position */
+  inline const Vector& getLastAbsCoor () const { return this->lastAbsCoordinate; };
   void shiftCoor (const Vector& shift);
   void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
@@ -238,5 +240,5 @@
     float roty;
     float rotz;
-    
+
   private:
     int relCoordinate_handle;
@@ -244,5 +246,5 @@
     Vector relCoordinate_write;
     Quaternion relDirection_write;
-    
+
   public:
     virtual void varChangeHandler( std::list<int> & id );
Index: trunk/src/lib/event/event_handler.cc
===================================================================
--- trunk/src/lib/event/event_handler.cc	(revision 8450)
+++ trunk/src/lib/event/event_handler.cc	(revision 8490)
@@ -355,5 +355,5 @@
   else
   {
-//    SDL_WM_GrabInput(SDL_GRAB_ON);
+    SDL_WM_GrabInput(SDL_GRAB_ON);
     SDL_ShowCursor(SDL_DISABLE);
   }
Index: trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- trunk/src/lib/graphics/graphics_engine.cc	(revision 8450)
+++ trunk/src/lib/graphics/graphics_engine.cc	(revision 8490)
@@ -66,4 +66,5 @@
 
   this->bDisplayFPS = false;
+  this->bAntialiasing = false;
   this->minFPS = 9999;
   this->maxFPS = 0;
@@ -283,9 +284,16 @@
   SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
 
-  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);	//Use at least 5 bits of Red
-  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);	//Use at least 5 bits of Green
-  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);	//Use at least 5 bits of Blue
-  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);	//Use at least 16 bits for the depth buffer
+  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);      //Use at least 5 bits of Red
+  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);    //Use at least 5 bits of Green
+  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);     //Use at least 5 bits of Blue
+  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);   //Use at least 16 bits for the depth buffer
   SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);  //Enable double buffering
+
+  // enable antialiasing?
+  if( this->bAntialiasing)
+  {
+    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES,4);
+    SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS,1);
+  }
 
   glEnable(GL_CULL_FACE);
Index: trunk/src/lib/graphics/graphics_engine.h
===================================================================
--- trunk/src/lib/graphics/graphics_engine.h	(revision 8450)
+++ trunk/src/lib/graphics/graphics_engine.h	(revision 8490)
@@ -46,4 +46,6 @@
     static void setBackgroundColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha = 1.0);
 
+    inline void setAntialiasing(bool flag) { this->bAntialiasing = flag; }
+    inline bool getAntialiasing() { return this->bAntialiasing; }
 
     /** @returns the x resolution */
@@ -109,4 +111,6 @@
     bool                       shadowsEnabled;     //!< If Shadows should be enabled.
     bool                       particlesEnabled;   //!< If particles should be enabled.
+    bool                       bAntialiasing;      //!< true if antialiasing enabled
+
     int                        particlesValue;     //!< How many particles
     int                        textureQuality;     //!< the quality of Textures
Index: trunk/src/lib/graphics/importer/Makefile.am
===================================================================
--- trunk/src/lib/graphics/importer/Makefile.am	(revision 8450)
+++ trunk/src/lib/graphics/importer/Makefile.am	(revision 8490)
@@ -5,4 +5,6 @@
 
 libORXimporter_a_SOURCES = model.cc \
+			   interactive_model.cc \
+			   md_model_structure.cc \
                            vertex_array_model.cc \
                            grid.cc \
@@ -10,5 +12,4 @@
                            objModel.cc \
                            primitive_model.cc \
-                           md2Model.cc \
                            height_map.cc \
                            bsp_manager.cc \
@@ -22,5 +23,19 @@
                            texture_sequence.cc \
                            media_container.cc \
-                           movie_player.cc
+                           movie_player.cc \
+                           \
+                           bsp_manager.cc \
+                           bsp_file.cc \
+                           bsp_tree_node.cc \
+                           bsp_tree_leaf.cc \
+                           \
+                           md2/md2Model.cc \
+                           \
+                           md3/md3_model.cc \
+                           md3/md3_animation.cc \
+                           md3/md3_bone_frame.cc \
+                           md3/md3_mesh.cc \
+                           md3/md3_data.cc \
+                           md3/md3_tag.cc
 
 
@@ -32,4 +47,6 @@
 noinst_HEADERS = \
 		model.h \
+		interactive_model.h \
+		md_model_structure.cc \
 		tc.h \
 		vertex_array_model.h \
@@ -38,5 +55,4 @@
 		objModel.h \
 		primitive_model.h \
-		md2Model.h \
 		anorms.h \
 		anormtab.h \
@@ -54,3 +70,13 @@
 		bsp_file.h \
 		bsp_tree_node.h \
-		bsp_tree_leaf.h
+		bsp_tree_leaf.h \
+		\
+                md2/md2Model.h \
+                \
+                md3/md3_model.h \
+                md3/md3_animation.h \
+                md3/md3_bone_frame.h \
+                md3/md3_mesh.h \
+                md3/md3_data.h \
+                md3/md3_tag.h
+
Index: trunk/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_file.cc	(revision 8450)
+++ trunk/src/lib/graphics/importer/bsp_file.cc	(revision 8490)
@@ -37,4 +37,7 @@
 #include <SDL/SDL_image.h>
 
+// STL Containers
+#include <vector>
+
 using namespace std;
 
@@ -50,5 +53,5 @@
 int BspFile::read(const char* name)
 {
-  //this->scale = 0.4;
+  this->scale = 1.0;
   int offset;
   int size;
@@ -211,8 +214,8 @@
     bspFile.read(this->visData, size);
 
-    PRINTF(4)("BSP FILE: VisDataSize: %i Bytes. \n", size);
-    PRINTF(4)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
-    PRINTF(4)("BSP FILE: Remainder: %i. \n", size % 1);
-    PRINTF(4)("BSP FILE: VisDataOffset: %i. \n", offset);
+    PRINTF(0)("BSP FILE: VisDataSize: %i Bytes. \n", size);
+    PRINTF(0)("BSP FILE: NumVisData: %i. \n", size /1 - 8);
+    PRINTF(0)("BSP FILE: Remainder: %i. \n", size % 1);
+    PRINTF(0)("BSP FILE: VisDataOffset: %i. \n", offset);
 
     // Get the Textures
@@ -388,6 +391,8 @@
 {
   ::std::string absFileName;
-  char fileName [228];
-  char ext [100];
+  char* baseName = "/worlds/bsp/";
+
+  char fileName [500];
+  char ext [500];
   struct stat results;
 
@@ -401,6 +406,7 @@
     if(strlen(fileName) == 0)
     {
+
      //         Default Material
-      this->Materials[i].mat = new Material();
+    this->Materials[i].mat = new Material();
     this->Materials[i].mat->setDiffuse(0.1,0.1,1.0);
     this->Materials[i].mat->setAmbient(0.1,0.1,1.0 );
@@ -417,7 +423,11 @@
 
       // Check for mov
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".mov");
-    strncat (fileName, ext, strlen(fileName));
+    strncat (fileName, ext, strlen(fileName) );
+
+    PRINTF(0)("BSP FILE: Name %s . \n", fileName);
 
     absFileName = ResourceManager::getFullName(fileName);
@@ -430,5 +440,7 @@
 
     // Check for avi
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".avi");
     strncat (fileName, ext, strlen(fileName));
@@ -443,5 +455,7 @@
 
        // Check for mpg
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".mpg");
     strncat (fileName, ext, strlen(fileName));
@@ -456,5 +470,7 @@
 
     // Check for tga
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".tga");
     strncat (fileName, ext, strlen(fileName));
@@ -468,5 +484,7 @@
     }
     // Check for TGA
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".TGA");
     strncat (fileName, ext, strlen(fileName));
@@ -479,5 +497,7 @@
     }
     // Check for jpg
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".jpg");
     strncat (fileName, ext, strlen(fileName));
@@ -491,5 +511,7 @@
 
     // Check for JPG
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".JPG");
     strncat (fileName, ext, strlen(fileName));
@@ -504,5 +526,7 @@
 
     // Check for bmp
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".bmp");
     strncat (fileName, ext, strlen(fileName));
@@ -516,5 +540,7 @@
 
     // Check for BMP
-    strcpy(fileName, &this->textures[8+ 72*i]);
+    strcpy(fileName, baseName);
+    strcpy(ext, &this->textures[8+ 72*i]);
+    strncat(fileName, ext, strlen(fileName) + strlen(&this->textures[8+ 72*i]) );
     strcpy(ext, ".BMP");
     strncat (fileName, ext, strlen(fileName));
@@ -577,4 +603,6 @@
   MoviePlayer * testMC = new MoviePlayer(mat);
   testMC->start(0);
+  
+  this->MovieMaterials.push_back(testMC);
 
   //Material* tmp = new Material();
@@ -605,5 +633,7 @@
   sc =  ((unsigned char *)(&lightMapTexture))[i];
   sc *= 1/255.0;
-  scale = 2.0;
+
+  scale = 1.0f; // Adjust brightness here
+
   if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp;
   scale*=255.0;
Index: trunk/src/lib/graphics/importer/bsp_file.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp_file.h	(revision 8450)
+++ trunk/src/lib/graphics/importer/bsp_file.h	(revision 8490)
@@ -18,4 +18,5 @@
 */
 
+#include <vector>
 class SDL_Surface;
 class BspTreeNode;
@@ -212,5 +213,5 @@
 
  
-
+  ::std::vector<MoviePlayer* > MovieMaterials; //!< Movieplayer Materials
 };
 
Index: trunk/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 8450)
+++ trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 8490)
@@ -39,6 +39,4 @@
 #include "movie_player.h"
 
-#include "cd_engine.h"
-
 #include "world_entity.h"
 
@@ -47,8 +45,11 @@
 
 
+
 //CREATE_FACTORY( BspManager, CL_BSP_MODEL);
 
-BspManager::BspManager()
-{
+BspManager::BspManager(WorldEntity* parent)
+{
+ 
+  this->parent = parent;
   /*// open a BSP file
   this->bspFile = new BspFile();
@@ -59,5 +60,5 @@
   this->alreadyVisible = new bool [this->bspFile->numFaces];
   */
-  CDEngine::getInstance()->setBSPModel(this);
+
 }
 
@@ -76,6 +77,5 @@
 void BspManager::load(const char* fileName, float scale)
 {
-  //this->setClassID(CL_BSP_MODEL, "BspManager");
-    // open a BSP file
+  // open a BSP file
   this->bspFile = new BspFile();
   this->bspFile->scale =  scale;
@@ -85,5 +85,5 @@
   this->alreadyVisible = new bool [this->bspFile->numFaces];
 
-
+  this->outputFraction = 1.0f;
 }
 /*
@@ -102,4 +102,21 @@
 */
 
+const void BspManager::tick(float time)
+{
+
+  if(!this->bspFile->MovieMaterials.empty())
+  {
+      ::std::vector<MoviePlayer *>::iterator it = this->bspFile->MovieMaterials.begin() ;
+      while(it != this->bspFile->MovieMaterials.end())
+      {
+         (*it)->tick(time);
+        it++;
+      }
+ //this->bspFile->MovieMaterials.front()->tick(time );
+
+
+  }
+
+}
 const void BspManager::draw()
 {
@@ -109,17 +126,19 @@
   this->out1 = this->out;
   this->out2 = this->out;
-  if(this->collPlane != NULL)
-  {
-  this->out1.x += this->collPlane->x*5.0;
-  this->out1.y += this->collPlane->y*5.0;
-  this->out1.z += this->collPlane->z*5.0;
-
-  this->out2.x += this->collPlane->x*10.0;
-  this->out2.y += this->collPlane->y*10.0;
-  this->out2.z += this->collPlane->z*10.0;
+  if(this->collPlane != NULL) {
+    this->out1.x += this->collPlane->x*5.0;
+    this->out1.y += this->collPlane->y*5.0;
+    this->out1.z += this->collPlane->z*5.0;
+
+    this->out2.x += this->collPlane->x*10.0;
+    this->out2.y += this->collPlane->y*10.0;
+    this->out2.z += this->collPlane->z*10.0;
   }
   this->drawDebugCube(&this->out1);
   this->drawDebugCube(&this->out2);
+
   */
+
+
   // Draw Debug Terrain
   /*
@@ -148,5 +167,5 @@
 
 
-  // this->viewDir=    State::getCameraTarget()->getAbsCoor() -  State::getCamera()->getAbsCoor() ;
+  this->viewDir=    State::getCamera()->getAbsDirX();
   float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);
 
@@ -157,14 +176,12 @@
 
 
-  this->cam = State::getCameraTargetNode()->getAbsCoor();
-  // this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
+
+ // this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
+
+
   this->outputStartsOut = true;
   this->outputAllSolid = false;
   this->outputFraction = 1.0f;
 
-  this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);
-
-  //if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
-
   if ( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
   {
@@ -172,5 +189,5 @@
 
 
-    // Iterate through all Leafspublic final double readLEDouble()
+    // Iterate through all Leafs
     for(int i = 0; i <  this->bspFile->numLeafs   ; i++ )
     {
@@ -179,12 +196,8 @@
       if(curLeaf.cluster<0) continue;
 
-
       /** Do Frustum culling and draw 'em all **/
-      bool inFrustum = true;
-
-      Vector dir;
-      dir.x = State::getCameraNode()->getAbsDirX().x;
-      dir.y =  State::getCameraNode()->getAbsDirX().y;
-      dir.z =  State::getCameraNode()->getAbsDirX().z;
+
+      Vector dir = State::getCameraNode()->getAbsDirX();
+
       float dist =  dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z;
       //if(dist < 0) dist = -dist;
@@ -192,8 +205,8 @@
       const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ;
 
-      if(dMins < -150.0 && dMaxs < -150.0) {
+      if(dMins < -300.0 && dMaxs < -300.0) {
         continue;
       }
-      if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 3000  && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 3000) {
+      if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 2000  && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 2000) {
         continue;
       }
@@ -206,5 +219,4 @@
         if (f >=0 && !this->isAlreadyVisible(f)) {
           this->alreadyVisible[f] = true;
-
           addFace(f); // "visibleFaces.append(f)"
         }
@@ -302,17 +314,20 @@
     return;
   }
-  if(curFace.type != 1) return;
+ // if(curFace.type != 1) return;
   if((char*)(this->bspFile->textures)[curFace.texture*72]== 0) return;
 
   if(this->lastTex != curFace.texture) {
     if(this->bspFile->Materials[curFace.texture].animated) {
-      glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR);
-      glEnable(GL_BLEND);
+     // glBlendFunc(GL_ZERO,GL_ONE);
+
+
+
       if(this->bspFile->Materials[curFace.texture].aviMat->getStatus() == 2) this->bspFile->Materials[curFace.texture].aviMat->start(0);
-      this->bspFile->Materials[curFace.texture].aviMat->tick(0.005);
+      //this->bspFile->Materials[curFace.texture].aviMat->tick(0.005);
       int n =  this->bspFile->Materials[curFace.texture].aviMat->getTexture();
       glActiveTextureARB(GL_TEXTURE0_ARB);
       glBindTexture(GL_TEXTURE_2D, n );
-      glDisable(GL_BLEND);
+      this->lastTex = curFace.texture;
+
     } else {
       this->bspFile->Materials[curFace.texture].mat->select();
@@ -322,11 +337,16 @@
 
   if(curFace.lm_index < 0) {
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glActiveTextureARB(GL_TEXTURE1_ARB);
     glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap );
     glEnable(GL_TEXTURE_2D);
   } else {
+   // glEnable(GL_BLEND);
+    //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glActiveTextureARB(GL_TEXTURE1_ARB);
     glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[curFace.lm_index]);
     glEnable(GL_TEXTURE_2D);
+  //  glDisable(GL_BLEND);
   }
 
@@ -573,9 +593,78 @@
   float startFraction = -1.0f;
   float endFraction = 1.0f;
-  bool startsOut = false;
-  bool endsOut = false;
-
-  Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor();
-  Vector inputEnd   = State::getCameraTargetNode()->getAbsCoor();
+  bool  startsOut = false;
+  bool  endsOut = false;
+
+ // Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor();
+ // Vector inputEnd   = State::getCameraTargetNode()->getAbsCoor();
+
+  for (int i = 0; i < curBrush->n_brushsides; i++) {
+    brushside& curBrushSide =   this->bspFile->brushSides[curBrush->brushside + i]   ;
+    plane& curPlane  =   this->bspFile->planes[curBrushSide.plane] ;
+
+    startDistance = inputStart.x * curPlane.x + inputStart.y * curPlane.y+ inputStart.z * curPlane.z - curPlane.d;
+    endDistance = inputEnd.x * curPlane.x +inputEnd.y * curPlane.y +inputEnd.z * curPlane.z -curPlane.d;
+
+    if (startDistance > 0)
+      startsOut = true;
+    if (endDistance > 0)
+      endsOut = true;
+
+    // make sure the trace isn't completely on one side of the brush
+    if (startDistance > 0 && endDistance > 0) {   // both are in front of the plane, its outside of this brush
+      return;
+    }
+    if (startDistance <= 0 && endDistance <= 0) {   // both are behind this plane, it will get clipped by another one
+      continue;
+    }
+
+    // MMM... BEEFY
+    if (startDistance > endDistance) {   // line is entering into the brush
+      float fraction = (startDistance - EPSILON) / (startDistance - endDistance);  // *
+      if (fraction > startFraction)
+        startFraction = fraction;
+      // store plane
+      this->collPlane = &curPlane;
+
+    } else {   // line is leaving the brush
+      float fraction = (startDistance + EPSILON) / (startDistance - endDistance);  // *
+      if (fraction < endFraction)
+        endFraction = fraction;
+      // store plane
+      this->collPlane = & curPlane;
+
+    }
+
+  }
+  if (startsOut == false) {
+    this->outputStartsOut = false;
+    if (endsOut == false)
+      this->outputAllSolid = true;
+    return;
+  }
+
+  if (startFraction < endFraction) {
+    if (startFraction > -1.0f && startFraction < outputFraction) {
+      if (startFraction < 0)
+        startFraction = 0;
+      this->outputFraction = startFraction;
+    }
+  }
+
+}
+
+void BspManager::checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd)
+{
+  float EPSILON = 0.000001;
+  float startDistance;
+  float endDistance;
+
+  float startFraction = -1.0f;
+  float endFraction = 1.0f;
+  bool  startsOut = false;
+  bool  endsOut = false;
+
+  //Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor();
+  //Vector inputEnd   = State::getCameraTargetNode()->getAbsCoor();
 
   for (int i = 0; i < curBrush->n_brushsides; i++) {
@@ -736,9 +825,10 @@
 
   float EPSILON = 0.000001;
-  float  endDistance = (end)->x * (node->plane.x) +(end)->y * (node->plane.y) +(end)->z * (node->plane.z)  - node->d;
-  float  startDistance = (start)->x * (node->plane.x)+ (start)->y * (node->plane.y)+ (start)->z * (node->plane.z)- node->d;
-
-
-  if(node->isLeaf) {
+
+  float endDistance = end->dot(node->plane) - node->d;
+  float startDistance = start->dot(node->plane) - node->d;
+
+
+  if( node->isLeaf) {
     leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
     for (int i = 0; i <  curLeaf.n_leafbrushes ; i++) {
@@ -793,10 +883,7 @@
 
     // STEP 3: calculate the middle point for the first side
-    middleFraction = startFraction +
-        (endFraction - startFraction) * fraction1;
-
-    middle.x = start->x + fraction1 * (end->x - start->x);
-    middle.y = start->y + fraction1 * (end->y - start->y);
-    middle.z = start->z + fraction1 * (end->z - start->z);
+    middleFraction = startFraction + (endFraction - startFraction) * fraction1;
+    middle = (*start) + ((*end) - (*start)) * fraction1;
+
 
     // STEP 4: check the first side
@@ -805,13 +892,9 @@
 
     else this->checkCollisionRayN(node->right,startFraction, middleFraction,
-                                 start, &middle );
+                                    start, &middle );
 
     // STEP 5: calculate the middle point for the second side
-    middleFraction = startFraction +
-        (endFraction - startFraction) * fraction2;
-
-    middle.x = start->x + fraction2 * (end->x - start->x);
-    middle.y = start->y + fraction2 * (end->y - start->y);
-    middle.z = start->z + fraction2 * (end->z - start->z);
+    middleFraction = startFraction + (endFraction - startFraction) * fraction2;
+    middle = (*start) + ((*end) - (*start)) * fraction2;
 
     // STEP 6: check the second side
@@ -824,64 +907,101 @@
 
 }
+void BspManager::checkCollisionBox(void)
+{
+
+};
+
+void BspManager::TraceBox( Vector& inputStart, Vector& inputEnd,
+               Vector& inputMins, Vector& inputMaxs )
+{
+  if (inputMins.x == 0 && inputMins.y == 0 && inputMins.z == 0 &&
+      inputMaxs.x == 0 && inputMaxs.y == 0 && inputMaxs.z == 0)
+  {   // the user called TraceBox, but this is actually a ray
+   //!> FIXME TraceRay( inputStart, inputEnd );
+  }
+  else
+  {   // setup for a box
+    //traceType = TT_BOX;
+    this->traceMins = inputMins;
+    this->traceMaxs = inputMaxs;
+    this->traceExtents.x = -traceMins.x > traceMaxs.x ?
+        -traceMins.x : traceMaxs.x;
+    this->traceExtents.y = -traceMins.y > traceMaxs.y ?
+        -traceMins.y : traceMaxs.y;
+    this->traceExtents.z = -traceMins.z > traceMaxs.z ?
+        -traceMins.z : traceMaxs.z;
+   //!> FIXME Trace( inputStart, inputEnd );
+  }
+}
 
 void BspManager::checkCollision(WorldEntity* worldEntity)
 {
-  return;
-
+  
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  
   Vector position = worldEntity->getAbsCoor();
 
 
   Vector forwardDir = worldEntity->getAbsDirX();
-  forwardDir.x =2.0*forwardDir.x;
-  forwardDir.y =2.0*forwardDir.y;
-  forwardDir.z =2.0*forwardDir.z;
+  forwardDir = forwardDir * 8.0f;
 
   Vector upDir = worldEntity->getAbsDirY();
-  Vector dest = position;
+  upDir.x = 0.0;
+  upDir.y = 1.0;
+  upDir.z = 0.0;
+  Vector dest;
+  /*
   dest.x  += forwardDir.x;
   dest.y  += forwardDir.y;
   dest.z  += forwardDir.z;
-  Vector out = Vector(-1875.0,-1875.0,-1875.0);
-  if(!worldEntity->isA(CL_PLAYABLE)) {
-
-
-
-
+  */
+
+  dest = worldEntity->getAbsCoor() - upDir*40.0;
+  Vector out = dest;
+
+
+
+
+  bool collision = false;
+  Vector position1 = position + Vector(0.0,0.1,0.0);
+  Vector position2 = position + Vector(0.0,0.2,0.0);
+  Vector dest1 = position1 + forwardDir;
+  Vector dest2 = position2 + forwardDir;
+  dest = position - Vector(0.0, 40.0,0.0);
+  Vector out1;
+  Vector out2;
+
+
+  float height = 40;
+  
+  this->inputStart =  position;
+  this->inputEnd =   dest;
+  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
+
+  PRINTF(0)(" checking collision: %s, solid = %i, fraction = %f\n", worldEntity->getClassName(), this->outputAllSolid, this->outputFraction);
+  PRINTF(0)("checking collision!! Pos.Coords: %f , %f , %f\n", position.x , position.y, position.z);
+  PRINTF(0)("checking collision!! Dest.Coords: %f , %f , %f\n", dest.x , dest.y, dest.z);  
+//   position1.debug();
+
+  if( this->outputFraction == 1.0f)
+  {
+    if(this->outputAllSolid)
+    {
+      this->collPlane = new plane;
+      this->collPlane->x = 1.0f;
+      this->collPlane->y = 0.0f;
+      this->collPlane->z = 0.0f;
+      collision = true;
+    }
+    else
+      collision = false;
+
+
+    out = dest;
   }
   else {
-    bool collision = false;
-    Vector position1 = position + Vector(0.0,0.1,0.0);
-    Vector position2 = position + Vector(0.0,0.2,0.0);
-    Vector dest1 = position1 + forwardDir;
-    Vector dest2 = position2 + forwardDir;
-    dest = position - upDir;
-    Vector out1;
-    Vector out2;
-
-    this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
-    if(this->outputFraction == 1.0f)  out1 = dest;
-    else {
-      collision = true;
-      out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction;
-      out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction;
-      out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction;
-
-    }
-
-    this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
-    if(this->outputFraction == 1.0f) out2= dest;
-    else
-    {
-      collision = true;
-    out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction;
-    out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction;
-    out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction;
-
-    }
-
-    this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
-    if(this->outputFraction == 1.0f) out = dest;
-    else
-    {
+
     collision = true;
     out.x = position.x + (dest.x -position.x) * this->outputFraction;
@@ -889,21 +1009,16 @@
     out.z = position.z + (dest.z -position.z) * this->outputFraction;
 
-    //Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
-    //this->out = out;
-    //this->out1 = out1;
-    //this->out2 = out2;
-    //this->drawDebugCube(&out1);
-    //this->drawDebugCube(&out2);
-
-    //this->drawDebugCube(&out3);
-
-    }
-
-    // Return the normal here: Normal's stored in this->collPlane;
-//    if(collision) worldEntity->collidesWithGround(out,out1,out2);
-
-  }
-
-}
+    Vector out3 = out + Vector(height*this->collPlane->x,height*this->collPlane->y,height*this->collPlane->z);
+    this->out = out;
+  }
+
+  // Return the normal here: Normal's stored in this->collPlane;
+  if( collision) {
+    PRINTF(0)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
+    worldEntity->registerCollision(this->parent, worldEntity, Vector(this->collPlane->x, this->collPlane->y, this->collPlane->z), out);
+  }
+
+}
+
 
 void  BspManager::checkCollision(BspTreeNode* node, Vector* cam)
@@ -938,6 +1053,6 @@
       this->drawDebugCube(&this->cam);
       this->drawDebugCube(&next);
-      State::getPlayer()->getPlayable()->setRelCoor(-100,-100,-100);
-      State::getPlayer()->getPlayable()->collidesWith(NULL, State::getCameraTargetNode()->getLastAbsCoor());
+     // State::getPlayer()->getPlayable()->setRelCoor(-100,-100,-100);
+      //State::getPlayer()->getPlayable()->collidesWith(NULL, State::getCameraTargetNode()->getLastAbsCoor());
     }
 
Index: trunk/src/lib/graphics/importer/bsp_manager.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.h	(revision 8450)
+++ trunk/src/lib/graphics/importer/bsp_manager.h	(revision 8490)
@@ -1,25 +1,31 @@
 /*
    orxonox - the future of 3D-vertical-scrollers
- 
+
    Copyright (C) 2006 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: bottac@ee.ethz.ch
-   
+
    Inspired by:
    Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
-   
+
    Collision detection adapted from:
    Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
 */
 
+#ifndef _BSP_MANAGER_H
+#define _BSP_MANAGER_H
+
+
 #include <vector>
 #include <deque>
+
+
 
 // FORWARD DECLARATIONS
@@ -45,6 +51,6 @@
 public:
   // Constructors
-  BspManager();
-  
+  BspManager(WorldEntity* parent);
+
   BspManager(const char* fileName, float scale = 0.4f);
   void load(const char* fileName, float scale);
@@ -52,23 +58,29 @@
   // Functions
   const void draw();
-  void draw_debug_face(int Face); 
+  const void tick(float time);
+  void draw_debug_face(int Face);
   void draw_face(int Face);
   void draw_patch(face* Face);
-  
 
-  void checkCollision(WorldEntity* worldEntity);
+
+  void checkCollision(WorldEntity* worldEntity); /*!< WorldEntities use this function to check wheter they collided with the BspEntity.
+                                                      If a collision has been detected, the collides-function of worldEntity will be called.*/
 
 private:
   // Functions
   BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
-  void  checkCollision(BspTreeNode* node, Vector* cam);
-  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 
-  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end); 
+  void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
+  void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
+  void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
+  void TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
+  void  checkCollisionBox(void);
   void  checkBrushRay(brush* curBrush);
   void  checkBrushRayN(brush* curBrush);
+  void   checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
+
   void drawDebugCube(Vector* cam);
   bool isAlreadyVisible(int Face);
   void addFace(int Face);
-  
+
   // Data
   BspFile*  bspFile;
@@ -79,10 +91,19 @@
   plane* collPlane;
   int lastTex;
-  
-  //obsolete
+
+  //obsolete: global variables for collision detection
   bool  outputStartsOut;
   bool  outputAllSolid;
   float outputFraction;
+  Vector inputStart;
+  Vector inputEnd;
   
+  Vector traceMins; //!< Mins of current bbox
+  Vector traceMaxs; //!< Maxs of current bbox
+  Vector traceExtents; /*!< Stores the maximum of the absolute value of each axis in the box.
+                            For example, if traceMins was (-100,-3,-15) and traceMaxs was (55,22,7), traceExtents */
+
+  WorldEntity* parent;          //!< the parent entity of the bspManager: interface to this
+
   bool * alreadyVisible;
   // Deques to store the visible faces
@@ -90,7 +111,10 @@
   ::std::deque<int> opal; //!< the others here.
 
-  Vector out;
-  Vector out1;
-  Vector out2;
+  Vector out;  //!< For debugging only
+  Vector out1; //!< For debugging only
+  Vector out2; //!< For debugging only
+                        
+  int tgl;
 };
 
+#endif /* _BSP_MANAGER_H */
Index: trunk/src/lib/graphics/importer/interactive_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/interactive_model.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/interactive_model.cc	(revision 8490)
@@ -0,0 +1,40 @@
+/*
+   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
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_MODEL
+
+#include "interactive_model.h"
+
+#include "glincl.h"
+
+using namespace std;
+
+/**
+ * standard constructor
+ * @todo this constructor is not jet implemented - do it
+*/
+InteractiveModel::InteractiveModel()
+{
+  this->setClassID(CL_INTERACTIVE_MODEL, "InteractiveModel");
+}
+
+
+/**
+ * standard deconstructor
+*/
+InteractiveModel::~InteractiveModel()
+{}
+
+
Index: trunk/src/lib/graphics/importer/interactive_model.h
===================================================================
--- trunk/src/lib/graphics/importer/interactive_model.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/interactive_model.h	(revision 8490)
@@ -0,0 +1,42 @@
+/*
+   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
+   co-programmer:
+*/
+
+/*!
+ * @file interactive_model.h
+ *  Definition of an abstract interactive model.
+ *   it offers a skeletton for choosing animations, ticking the model a.s.o
+ */
+
+#ifndef _INTERACTIVE_MODEL_H
+#define _INTERACTIVE_MODEL_H
+
+#include "model.h"
+#include "vector.h"
+
+
+
+class InteractiveModel : public Model
+{
+  public:
+    InteractiveModel();
+    ~InteractiveModel();
+
+    virtual void tick(float) = 0;
+
+    virtual void setAnimation(int animNum, int playbackMode = 0) = 0;
+};
+
+
+#endif /* _INTERACTIVE_MODEL_H */
Index: trunk/src/lib/graphics/importer/md2/md2Model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 8490)
@@ -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->setAnimation(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::setAnimation(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: trunk/src/lib/graphics/importer/md2/md2Model.h
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 8490)
@@ -0,0 +1,196 @@
+/*!
+ * @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 "interactive_model.h"
+#include "material.h"
+
+#include "md_model_structure.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
+};
+
+
+//! 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 InteractiveModel {
+
+public:
+  MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
+  virtual ~MD2Model();
+
+  virtual void draw() const;
+  void renderFrameTriangles() const;
+
+
+  virtual void setAnimation(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 */
Index: trunk/src/lib/graphics/importer/md2Model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2Model.cc	(revision 8450)
+++ 	(revision )
@@ -1,567 +1,0 @@
-/*
-   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 "config.h"
-#ifdef HAVE_SDL_SDL_H
-#include <SDL/SDL.h>
-#include <SDL/SDL_endian.h>
-#else
-#include <SDL.h>
-#include <SDL_endian.h>
-#endif
-#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
-  };
-
-
-#ifdef SDL_LIL_ENDIAN
-#define BULK_CONV( _ptr, _num ) do { \
-	int  _cnt = _num;\
-	int* _iptr = (int*)_ptr;\
-	for( int _l = 0; _l<_cnt; ++_l )\
-		_iptr[_l] = SDL_SwapLE32( _iptr[_l] );\
-} while( 0 )
-#define BULK_CONV16( _ptr, _num ) do { \
-	short  _cnt = _num;\
-	short* _iptr = (short*)_ptr;\
-	for( int _l = 0; _l<_cnt; ++_l )\
-		_iptr[_l] = SDL_SwapLE16( _iptr[_l] );\
-} while( 0 )
-#else
-#define BULK_CONV( _ptr, _num )
-#define BULK_CONV16( _ptr, _num )
-#endif
-
-/********************************************************************************
- *   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);
-
-	//When arriving here it is assumed that everything is in the correct byte order.
-  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()
-{
-  //PRINTF(0)("\n==========================| MD2Model::debug() |===\n");
-  PRINTF(0)("=  Model FileName:\t%s\n", this->data->fileName.c_str());
-  PRINTF(0)("=  Skin FileName:\t%s\n",
-		this->data->skinFileName.c_str());
-  PRINTF(0)("=  Size in Memory:\t%i Bytes\n",
-		this->data->header->frameSize * this->data->header->numFrames + 64); // 64bytes is the header size
-  PRINTF(0)("=  Number of Vertices:\t%i\n", this->data->header->numVertices);
-  PRINTF(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
-  PRINTF(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
-  PRINTF(0)("=  Pointer to the data object: %p\n", this->data);
-  //PRINTF(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);
-	BULK_CONV( this->header, sizeof(MD2Header)/4 );
-  /* 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);
-	//BULK_CONV( buffer, this->header->frameSize*this->numFrames*sizeof(char)/4 );
-  /* read opengl commands */
-  fseek(pFile, this->header->offsetGlCommands, SEEK_SET);
-
-  fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);
-	BULK_CONV( this->pGLCommands, this->numGLCommands );
-  /* triangle list */
-  fseek(pFile, this->header->offsetTriangles, SEEK_SET);
-  fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);
-	BULK_CONV16( this->pTriangles, this->numTriangles*sizeof(sTriangle)/2 );
-
-  /*  read in texture coordinates */
-  fseek(pFile, this->header->offsetTexCoords, SEEK_SET);
-  fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);
-	BULK_CONV16( this->pTexCoor, this->numTexCoor*sizeof(sTexCoor)/2 );
-
-  for(int i = 0; i < this->numFrames; ++i)
-    {
-      frame = (sFrame*)(buffer + this->header->frameSize * i);
-			//Convert the translate and scale Vec3D if needed.
-			BULK_CONV( frame, 6 );
-			BULK_CONV( frame->pVertices, 3 );
-      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);
-  return true;
-}
-
-
-/**
-  \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);
-  return true;
-}
Index: trunk/src/lib/graphics/importer/md2Model.h
===================================================================
--- trunk/src/lib/graphics/importer/md2Model.h	(revision 8450)
+++ 	(revision )
@@ -1,269 +1,0 @@
-/*!
- * @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 */
Index: trunk/src/lib/graphics/importer/md3/md3_animation.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_animation.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_animation.cc	(revision 8490)
@@ -0,0 +1,60 @@
+/*
+   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 "md3_animation.h"
+
+
+
+namespace md3
+{
+
+  /**
+   * create an empty MD3Animation object
+   */
+  MD3Animation::MD3Animation()
+  {
+    this->init();
+  }
+
+
+  /**
+   * create a new MD3 Anumation object and initialize it with the data on the given line
+   * @param line: the line to read from
+   */
+  MD3Animation::MD3Animation(std::string line)
+  {
+    this->init();
+    // loadAnimation()
+  }
+
+
+  /**
+   * deconstructor
+   */
+  MD3Animation::~MD3Animation()
+  {}
+
+
+  void MD3Animation::init()
+  {
+    this->first = 0;
+    this->numFrames = 0;
+    this->fps = 0;
+  }
+
+
+}
+
Index: trunk/src/lib/graphics/importer/md3/md3_animation.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_animation.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_animation.h	(revision 8490)
@@ -0,0 +1,48 @@
+/*!
+ * @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 AnimationType
+{};
+
+
+/**
+ * a class with metadata describing an MD3 model animation
+ */
+class MD3Animation
+{
+
+  public:
+    MD3Animation();
+    MD3Animation(std::string line);
+    virtual ~MD3Animation();
+
+    void init();
+
+    std::string toString() { return std::string("Name: " + this->name); }
+
+
+  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: trunk/src/lib/graphics/importer/md3/md3_bone_frame.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_bone_frame.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_bone_frame.cc	(revision 8490)
@@ -0,0 +1,41 @@
+/*
+   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 "md3_bone_frame.h"
+
+
+
+namespace md3
+{
+
+
+  /**
+   * create a MD3BoneFrame object with the data coming from the specified input stream
+   */
+  MD3BoneFrame::MD3BoneFrame(int tagNum /*, DataInput din*/)
+  { /* loadBoneFrame(this, din) */ }
+
+
+  MD3BoneFrame::MD3BoneFrame(/*int tagNum*/)
+  { /* this->tags = new MD3Tag[tagNum] */ }
+
+
+  MD3BoneFrame::~MD3BoneFrame()
+  {}
+
+
+
+};
Index: trunk/src/lib/graphics/importer/md3/md3_bone_frame.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_bone_frame.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_bone_frame.h	(revision 8490)
@@ -0,0 +1,53 @@
+/*!
+ * @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_ANIMATION_H
+#define _MD3_ANIMATION_H
+
+#include "vector.h"
+
+#include <string>
+
+namespace md3
+{
+
+typedef struct MD3BoneFrameData {
+  sVec3D  mins;
+  sVec3D  maxs;
+  sVec3D  position;
+  float   scale;
+  char    creator[16];
+};
+
+
+class MD3Tag;
+
+class MD3BoneFrame
+{
+  public:
+    /** create a MD3BoneFrame object with the data coming from the specified input stream */
+    MD3BoneFrame(int tagNum /*, DataInput din*/);
+    MD3BoneFrame(/*int tagNum*/);
+    virtual ~MD3BoneFrame();
+
+
+  public:
+    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
+
+    MD3BoneFrameData*   data;              //!< reference md3 bone frames data
+};
+
+}
+
+#endif /* _MD3_ANIMATION_H */
Index: trunk/src/lib/graphics/importer/md3/md3_data.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_data.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_data.cc	(revision 8490)
@@ -0,0 +1,401 @@
+/*
+   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 "md3_data.h"
+
+#include "md3_bone_frame.h"
+#include "md3_tag.h"
+#include "md3_mesh.h"
+
+#include "material.h"
+
+#include "debug.h"
+
+namespace md3
+{
+
+/********************************************************************************
+ *   MD3Data                                                                    *
+ ********************************************************************************/
+
+/**
+  \brief simple constructor
+*/
+MD3Data::MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
+{
+
+
+
+  this->loadModel(modelFileName);
+//   this->loadSkin(skinFileName);
+}
+
+
+/**
+  \brief simple destructor
+
+  this will clean out all the necessary data for a specific md2model
+*/
+MD3Data::~MD3Data()
+{
+  delete this->header;
+}
+
+
+
+/**
+  \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 MD3Data::loadModel(const std::string& fileName)
+{
+  FILE *pFile;                            //file stream
+//  char* buffer;                           //buffer for frame data
+  int fileOffset = 0;                     // file data offset
+
+
+
+  //! @todo this chek should include deleting a loaded model (eventually)
+  if (fileName.empty())
+    return false;
+
+  PRINTF(0)("opening file: %s\n", fileName.c_str());
+  pFile = fopen(fileName.c_str(), "rb");
+  if( unlikely(!pFile))
+    {
+      PRINTF(1)("Couldn't open the MD3 File for loading. Exiting.\n");
+      return false;
+    }
+  fileOffset += this->readHeader(pFile, fileOffset);
+  /* check for the header version: make sure its a md2 file :) */
+  if( unlikely(this->header->version != MD3_VERSION) && unlikely(this->header->ident != MD3_IDENT))
+    {
+      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
+      return false;
+    }
+
+
+    // check if the filesize is correct
+    if( this->header->fileSize > this->header->tagStart &&
+        this->header->fileSize >= this->header->meshStart)
+    {
+      bool bBoneFrames, bTags, bMeshes;
+      bBoneFrames = ( this->header->boneFrameNum == 0);
+      bTags = ( this->header->tagNum == 0);
+      bMeshes = ( this->header->meshNum == 0);
+
+      // read different parts of the model in correct order
+      while( !(bBoneFrames && bTags && bMeshes))
+      {
+        printf("while, fileOffset = %i\n", fileOffset);
+        if( fileOffset == this->header->boneFrameStart && !bBoneFrames)
+        {
+          fileOffset += this->readBoneFrames(pFile, fileOffset);
+          bBoneFrames = true;
+        }
+        else if( fileOffset == this->header->tagStart && !bTags)
+        {
+          fileOffset += this->readTags(pFile, fileOffset);
+          bTags = true;
+        }
+        else if( fileOffset == this->header->meshStart && !bMeshes)
+        {
+          fileOffset += this->readMeshes(pFile, fileOffset);
+          bMeshes = true;
+        }
+      }
+
+    }
+
+  fclose(pFile);
+
+  return true;
+}
+
+
+/**
+  \brief loads the skin/material stuff
+* @param fileName: name of the skin file
+  \return true if success
+*/
+bool MD3Data::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);
+
+  return true;
+}
+
+
+/**
+ * read heaader
+ */
+int MD3Data::readHeader(FILE* pFile, int fileOffset)
+{
+  PRINTF(0)("Reading Header\n");
+
+  this->header = new MD3Header;
+  fread(this->header, 1, sizeof(MD3Header), pFile);
+
+    //header debug:
+  PRINTF(0)("MD3 Header debug section======================================\n");
+  printf("ident: %i\n", this->header->ident);
+  printf("version: %i\n", this->header->version);
+  printf("filename: %s\n", this->header->filename);
+  printf("boneFrameNum: %i\n", this->header->boneFrameNum);
+  printf("tag number: %i\n", this->header->tagNum);
+  printf("mesh number: %i\n", this->header->meshNum);
+  printf("max tex num: %i\n", this->header->maxTexNum);
+  printf("bone frame start: %i\n", this->header->boneFrameStart);
+  printf("tag start: %i\n", this->header->tagStart);
+  printf("mesh start: %i\n", this->header->meshStart);
+  printf("fileSize: %i\n", this->header->fileSize);
+
+  return sizeof(MD3Header);
+}
+
+
+/**
+ * read bone frames
+ */
+int MD3Data::readBoneFrames(FILE* pFile, int fileOffset)
+{
+  PRINTF(0)("Reading Bone Frames\n");
+
+  this->boneFrames = new MD3BoneFrame*[this->header->boneFrameNum];
+
+  for( int i = 0; i < this->header->boneFrameNum; i++)
+  {
+    this->boneFrames[i] = new MD3BoneFrame(i);
+
+    MD3BoneFrameData* md = new MD3BoneFrameData;
+    fread(md, 1, sizeof(MD3BoneFrameData), pFile);
+    this->boneFrames[i]->data = md;
+  }
+
+  return this->header->boneFrameNum * sizeof(MD3BoneFrameData);
+}
+
+
+/**
+ * read the tags
+ */
+int MD3Data::readTags(FILE* pFile, int fileOffset)
+{
+  PRINTF(0)("Reading Tags\n");
+
+  for( int i = 0; i < this->header->boneFrameNum; i++)
+  {
+    this->boneFrames[i]->tags = new MD3Tag*[this->header->tagNum];
+
+    for( int j = 0; j < this->header->tagNum; j++)
+    {
+      this->boneFrames[i]->tags[j] = new MD3Tag();
+      MD3TagData* md = new MD3TagData;
+      fread(md, 1, sizeof(MD3TagData), pFile);
+      this->boneFrames[i]->tags[j]->data = md;
+    }
+  }
+
+  return this->header->boneFrameNum * this->header->tagNum * sizeof(MD3TagData);
+}
+
+
+/**
+ * read meshes
+ */
+int MD3Data::readMeshes(FILE* pFile, int fileOffset)
+{
+  PRINTF(0)("Reading Mesh Data\n");
+
+  fileOffset = 0;
+
+  this->meshes = new MD3Mesh*[this->header->meshNum];
+
+  for( int i = 0; i < this->header->meshNum; i++)
+  {
+    this->meshes[i] = new MD3Mesh();
+
+    int localFileOffset = 0;
+    bool   bTriangles, bTexVecs, bVertices, bTextures;            //!< the parts that have been read so far
+
+    //start reading mesh data
+    MD3MeshHeader* md = new MD3MeshHeader;
+    fread(md, 1, sizeof(MD3MeshHeader), pFile);
+    this->meshes[i]->header = md;
+    localFileOffset += sizeof(MD3MeshHeader);
+
+    PRINTF(0)("MD3 Mesh Header debug section\n");
+    printf("ident: %i\n", md->id);
+    printf("filename: %s\n", md->name);
+    printf("meshFrameNum: %i\n", md->meshFrameNum);
+    printf("textureNum: %i\n", md->textureNum);
+    printf("vertexNum: %i \n", md->vertexNum);
+    printf("triangleNum: %i\n", md->triangleNum);
+    printf("triangleStart: %i\n", md->triangleStart);
+    printf("textureStart: %i\n", md->textureStart);
+    printf("texVecStart: %i\n", md->texVecStart);
+    printf("vertexStart: %i\n", md->vertexStart);
+    printf("fileSize: %i\n", md->meshSize);
+
+    if( unlikely(this->meshes[i]->header->id != MD3_IDENT))
+    {
+      PRINTF(1)("Wrong MD3 mesh file tag, file %s could be corrupt\n", this->filename.c_str());
+      return false;
+    }
+
+    // check which parts to be loaded
+    bTriangles = ( this->meshes[i]->header->triangleNum == 0);
+    bTexVecs = ( this->meshes[i]->header->vertexNum == 0);
+    bVertices = ( this->meshes[i]->header->meshFrameNum == 0);
+    bTextures = ( this->meshes[i]->header->textureNum == 0);
+
+    // now read the data block whise
+    while( !(bTriangles && bTexVecs && bVertices && bTextures))
+    {
+      PRINTF(0)("while2: localOffset = %i\n", localFileOffset);
+      if( localFileOffset == this->meshes[i]->header->triangleStart  && !bTriangles)
+      {
+        localFileOffset += this->readMeshTriangles(pFile, localFileOffset, i);
+        bTriangles = true;
+      }
+      else if( localFileOffset == this->meshes[i]->header->textureStart && !bTextures)
+      {
+        localFileOffset += this->readMeshTextures(pFile, localFileOffset, i);
+        bTextures = true;
+      }
+      else if( localFileOffset == this->meshes[i]->header->texVecStart && !bTexVecs)
+      {
+        localFileOffset += this->readMeshTexVecs(pFile, localFileOffset, i);
+        bTexVecs = true;
+      }
+      else if( localFileOffset == this->meshes[i]->header->vertexStart && !bVertices)
+      {
+        localFileOffset += this->readMeshVertices(pFile, localFileOffset, i);
+        bVertices = true;
+      }
+    }
+    fileOffset += localFileOffset;
+    PRINTF(0)("finished reading mesh %i, got %i of %i byes\n", i, localFileOffset, md->meshSize);
+  }
+  return fileOffset;
+}
+
+
+
+/**
+ * reading in the mesh triangles
+ */
+int MD3Data::readMeshTriangles(FILE* pFile, int fileOffset, int mesh)
+{
+  PRINTF(0)("Reading Mesh Triangles\n");
+  // create the memomry to save the triangles
+  this->meshes[mesh]->triangles = new MD3Triangle[this->meshes[mesh]->header->triangleNum];
+  fread(this->meshes[mesh]->triangles, 1, sizeof(MD3Triangle) * this->meshes[mesh]->header->triangleNum, pFile);
+
+  return this->meshes[mesh]->header->triangleNum * sizeof(MD3Triangle);
+}
+
+
+/**
+ * reading in the mesh textures
+ */
+int MD3Data::readMeshTextures(FILE* pFile, int fileOffset, int mesh)
+{
+  PRINTF(0)("Reading Mesh Textures\n");
+
+  // create the textures
+  this->meshes[mesh]->material = new Material[this->meshes[mesh]->header->textureNum];
+
+  MD3Texture* tex = new MD3Texture[this->meshes[mesh]->header->textureNum];
+  fread(tex, 1, sizeof(MD3Texture) * this->meshes[mesh]->header->textureNum, pFile);
+
+  for( int i = 0; i < this->meshes[mesh]->header->textureNum; i++) {
+    PRINTF(0)(" texture file: %s\n", tex[i].fileName);
+    this->meshes[mesh]->material[i].setDiffuseMap(tex[i].fileName);
+    this->meshes[mesh]->material[i].setAmbient(1, 1, 1);
+  }
+
+  return this->meshes[mesh]->header->textureNum * sizeof(MD3Texture);
+}
+
+
+/**
+ * reading in the mesh tex vecs
+ */
+int MD3Data::readMeshTexVecs(FILE* pFile, int fileOffset, int mesh)
+{
+  PRINTF(0)("Reading Mesh TexVecs\n");
+
+  this->meshes[mesh]->texVecs = new MD3TexVecs[this->meshes[mesh]->header->vertexNum];
+  fread(this->meshes[mesh]->texVecs, 1, sizeof(MD3TexVecs) * this->meshes[mesh]->header->vertexNum, pFile);
+
+  return this->meshes[mesh]->header->vertexNum * sizeof(MD3TexVecs);
+}
+
+
+/**
+ * reading in the mesh vertices
+ */
+int MD3Data::readMeshVertices(FILE* pFile, int fileOffset, int mesh)
+{
+  PRINTF(0)("Reading Mesh Vertices\n");
+
+  // reserver memory for the vertex informations
+  this->meshes[mesh]->meshFrames = new sVec3D[this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum];
+  this->meshes[mesh]->normals = new MD3Normal[this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum];
+
+  for( int i = 0; i < this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum; i++)
+  {
+    // read out the compressed data
+    MD3VertexCompressed* vc = new MD3VertexCompressed;
+    fread(vc, 1, sizeof(MD3VertexCompressed), pFile);
+
+    this->meshes[mesh]->meshFrames[i][0] = (float)vc->vector[0] / 64.0f;
+    this->meshes[mesh]->meshFrames[i][1] = (float)vc->vector[1] / 64.0f;
+    this->meshes[mesh]->meshFrames[i][2] = (float)vc->vector[2] / 64.0f;
+
+    this->meshes[mesh]->normals[i].vertexNormal[0] = vc->vertexNormal[0];
+    this->meshes[mesh]->normals[i].vertexNormal[1] = vc->vertexNormal[1];
+
+    delete vc;
+  }
+
+  // delete the temp memory again
+//   delete vc;
+
+  return this->meshes[mesh]->header->meshFrameNum * this->meshes[mesh]->header->vertexNum * sizeof(MD3VertexCompressed);
+}
+
+}
+
+
+
+
+
+
+
Index: trunk/src/lib/graphics/importer/md3/md3_data.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_data.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_data.h	(revision 8490)
@@ -0,0 +1,131 @@
+/*!
+ * @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 _MD3_DATA_H
+#define _MD3_DATA_H
+
+#include "base_object.h"
+
+#include "model.h"
+#include "material.h"
+#include "md_model_structure.h"
+
+
+//! These are the needed defines for the max values when loading .MD2 files
+#define MD3_IDENT                       (('3'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md3 identifier tag in the bin file
+#define MD3_VERSION                     15                                       //!< 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
+
+
+namespace md3
+{
+
+  class MD3BoneFrame;
+  class MD3Mesh;
+
+//! This holds the header information that is read in at the beginning of the file: id software definition
+struct MD3Header
+{
+   int ident;                           //!< This is used to identify the file
+   int version;                         //!< The version number of the file (Must be 8)
+
+   char filename[68];                   //!< The filename of the model
+
+   int boneFrameNum;                    //!< number of frames
+   int tagNum;                          //!< number of tags
+   int meshNum;                         //!< number of mesh
+   int maxTexNum;                       //!< number of texture
+
+   int boneFrameStart;                  //!< start of bone frames
+   int tagStart;                        //!< start of the tag
+   int meshStart;                       //!< mesh start
+
+   int fileSize;                        //!< file size
+};
+
+
+
+//! class to store the md2 data in
+class MD3Data : public BaseObject
+{
+ public:
+   MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
+  virtual ~MD3Data();
+
+
+ private:
+   bool loadModel(const std::string& fileName);
+   bool loadSkin(const std::string& fileName = "");
+
+   int readHeader(FILE* pFile, int fileOffset);
+   int readBoneFrames(FILE* pFile, int fileOffset);
+   int readTags(FILE* pFile, int fileOffset);
+   int readMeshes(FILE* pFile, int fileOffset);
+
+
+   int readMeshTriangles(FILE* pFile, int fileOffset, int mesh);
+   int readMeshTextures(FILE* pFile, int fileOffset, int mesh);
+   int readMeshTexVecs(FILE* pFile, int fileOffset, int mesh);
+   int readMeshVertices(FILE* pFile, int fileOffset, int mesh);
+
+ public:
+
+  MD3Header*          header;            //!< the header file
+
+  std::string         filename;          //!< the name of the file as recorded in the .md3 file
+  std::string         loadFilename;      //!< filename of the actual file from which data was loaded
+
+  int                 boneFrameNum;      //!< number of anumation key fames in the models
+  int                 tagNum;            //!< number of tags
+  int                 meshNum;           //!< number of meshes
+
+  int                 maxTextureNum;     //!< maximum number of unique used in an md3 file
+  int                 boneFrameStart;    //!< starting position of bone frame data structures
+  int                 tagStart;          //!< starting position of tag-structures
+
+  int                 meshStart;         //!< starting position of mesh structures
+
+  int                 fileSize;          //!< file size
+
+
+  MD3BoneFrame**      boneFrames;        //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame
+  MD3Mesh**           meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
+
+  int                 parentTagIndex;    //!< tag index
+
+  //MD3Model*           parent;            //!< reference to the MD3Model
+
+
+};
+
+
+}
+
+
+
+#endif /* _MD3_DATA_H */
Index: trunk/src/lib/graphics/importer/md3/md3_mesh.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_mesh.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_mesh.cc	(revision 8490)
@@ -0,0 +1,38 @@
+/*
+   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 "md3_mesh.h"
+
+
+namespace md3
+{
+
+/**
+ *  md3 mesh constructor
+ */
+MD3Mesh::MD3Mesh()
+{
+}
+
+
+/**
+ * md3 mesh deconstructor
+ */
+MD3Mesh::~MD3Mesh()
+{}
+
+}
+
Index: trunk/src/lib/graphics/importer/md3/md3_mesh.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_mesh.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_mesh.h	(revision 8490)
@@ -0,0 +1,86 @@
+/*!
+ * @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
+
+
+#include <string>
+
+#include "md_model_structure.h"
+
+#include "vector.h"
+
+class Material;
+
+
+namespace md3
+{
+
+  typedef struct MD3MeshHeader {
+
+    int     id;                             //!< individual id, must be IDP3
+    char    name[68];                       //!< the name of the mesh
+
+    int     meshFrameNum;                   //!< numbers of frames
+    int     textureNum;                     //!< numbers of textures
+    int     vertexNum;                      //!< numbers of verteces
+    int     triangleNum;                    //!< number of triangles
+
+    int     triangleStart;                  //!< triangle start offset
+    int     textureStart;                   //!< texture start offset
+    int     texVecStart;                    //!< tex vec start offset
+    int     vertexStart;                    //!< vertex start offset
+
+    int     meshSize;                       //!< total mesh size
+  };
+
+
+  typedef struct MD3Triangle  {
+    int     vertexOffset[3];                //!< the vertex offsets of the triangles in the vertex array
+  };
+
+  typedef struct MD3Texture {
+    char    fileName[68];                   //!< the filename of the texture. path relativly to the model file
+  };
+
+  typedef struct MD3TexVecs {
+    float   textureCoord[2];                //!< the texture u/v coordinates
+  };
+
+  typedef struct MD3Normal {
+    int     vertexNormal[2];                //!< vertex normals
+  };
+
+  typedef struct MD3VertexCompressed {
+    short   vector[3];                      //!< compressed vertex information
+    unsigned char vertexNormal[2];          //!< vertex normals compressed
+  };
+
+
+
+class MD3Mesh
+{
+  public:
+    MD3Mesh();
+    virtual ~MD3Mesh();
+
+
+  public:
+    MD3MeshHeader*     header;                  //!< the header of the mesh
+
+    Material*          material;                //!< the material/textures of the models
+    MD3Triangle*       triangles;               //!< indices into mesh frames and texture coord arrays
+    MD3TexVecs*        texVecs;                 //!< tex vecs coordinates
+    sVec3D*            meshFrames;              //!< mesh frames
+    MD3Normal*         normals;                 //!< 3d array of normals with spherical coordinates giving the dir of the vertex normal
+
+};
+
+}
+
+#endif /* _MD3_MESH_H */
Index: trunk/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_model.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_model.cc	(revision 8490)
@@ -0,0 +1,39 @@
+/*
+   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 "md3_model.h"
+
+#include "md3_data.h"
+
+
+namespace md3
+{
+
+  /**
+   * md3 model
+   */
+  MD3Model::MD3Model(std::string filename, float scaling)
+  {
+    this->md3Data = new MD3Data(filename, filename, scaling);
+  }
+
+
+
+  MD3Model::~MD3Model()
+  {}
+
+
+}
Index: trunk/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_model.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_model.h	(revision 8490)
@@ -0,0 +1,37 @@
+/*!
+ * @file md3_model.h
+ *
+ * Code heavely inspired by: JAVA MD3 Model Viewer - A Java based Quake 3 model viewer
+ * Copyright (C) 1999 Erwin 'KLR8' Vervaet
+ */
+
+#ifndef _MD3_MODEL_H
+#define _MD3_MODEL_H
+
+#include <string>
+#include "interactive_model.h"
+
+
+namespace md3
+{
+
+
+class MD3Data;
+
+class MD3Model : public InteractiveModel
+{
+
+  public:
+    MD3Model(std::string filename, float scaling);
+    ~MD3Model();
+
+    virtual void tick(float dt) {}
+    virtual void setAnimation(int animNum, int playbackMode = 0) {}
+
+  private:
+    MD3Data*            md3Data;           //!< reference to the md3 model data
+};
+
+}
+
+#endif /* _MD3_MODEL_H */
Index: trunk/src/lib/graphics/importer/md3/md3_tag.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_tag.cc	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_tag.cc	(revision 8490)
@@ -0,0 +1,35 @@
+/*
+   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 "md3_tag.h"
+
+
+
+namespace md3
+{
+
+
+
+  MD3Tag::MD3Tag()
+  { /* loadMesh(this, din) */ }
+
+
+  MD3Tag::~MD3Tag()
+  {}
+
+
+}
+
Index: trunk/src/lib/graphics/importer/md3/md3_tag.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_tag.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md3/md3_tag.h	(revision 8490)
@@ -0,0 +1,43 @@
+/*!
+ * @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_TAG_H
+#define _MD3_TAG_H
+
+#include <string>
+
+#include "vector.h"
+
+namespace md3
+{
+
+typedef struct MD3TagData
+{
+  char       name[64];                                //!< name of the tag
+  sVec3D     position;                                //!< position of the tag
+  float      matrix[3][3];                            //!< matrix of the rotation
+};
+
+
+class MD3Tag
+{
+  public:
+    MD3Tag();
+    virtual ~MD3Tag();
+
+
+  public:
+    std::string               name;                   //!< name of tag as its usualy called in the md3 file
+    Vector                    position;               //!< the position of the tag reltive to the models containing that tag
+    float                     matrix[3][3];           //!< 3x3 rotation matrix
+
+    MD3TagData*               data;                   //!< data reference
+};
+
+}
+
+#endif /* _MD3_TAG_H */
Index: trunk/src/lib/graphics/importer/md_model_structure.h
===================================================================
--- trunk/src/lib/graphics/importer/md_model_structure.h	(revision 8490)
+++ trunk/src/lib/graphics/importer/md_model_structure.h	(revision 8490)
@@ -0,0 +1,88 @@
+/*!
+ * @file md_model_structure.h
+ */
+
+
+
+#ifndef _MD3_MODEL_STRUCTURE_H
+#define _MD3_MODEL_STRUCTURE_H
+
+
+#include "vector.h"
+
+
+//! 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;
+
+#endif /* _MD3_MODEL_STRUCTURE_H */
Index: trunk/src/lib/math/vector.h
===================================================================
--- trunk/src/lib/math/vector.h	(revision 8450)
+++ trunk/src/lib/math/vector.h	(revision 8490)
@@ -46,4 +46,6 @@
   /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
   inline bool operator== (const Vector& v) const { return (this->x==v.x&&this->y==v.y&&this->z==v.z)?true:false; };
+  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are different, false otherwise */
+  inline bool operator!= (const Vector& v) const { return (this->x!=v.x&&this->y!=v.y&&this->z!=v.z)?true:false; };
   /** @param index The index of the "array" @returns the x/y/z coordinate */
   inline float operator[] (float index) const {if( index == 0) return this->x; if( index == 1) return this->y; if( index == 2) return this->z; }
Index: trunk/src/lib/util/loading/resource_manager.cc
===================================================================
--- trunk/src/lib/util/loading/resource_manager.cc	(revision 8450)
+++ trunk/src/lib/util/loading/resource_manager.cc	(revision 8490)
@@ -27,5 +27,5 @@
 #include "objModel.h"
 #include "primitive_model.h"
-#include "md2Model.h"
+#include "md2/md2Model.h"
 #endif /* NO_MODEL */
 #ifndef NO_TEXTURES
