Index: trunk/src/lib/graphics/importer/md2/md2Model.h
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 9235)
+++ trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 9869)
@@ -20,4 +20,5 @@
 
 #include "base_object.h"
+#include "count_pointer.h"
 
 #include "interactive_model.h"
@@ -45,24 +46,24 @@
 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
+  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
 };
 
@@ -70,30 +71,30 @@
 //! animation names enumeration
 typedef enum MD2animType
-  {
-    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,
-    WALK,
-
-    MAX_ANIMATIONS
-  };
+{
+  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,
+  WALK,
+
+  MAX_ANIMATIONS
+};
 
 
@@ -116,13 +117,17 @@
 class MD2Data : public BaseObject
 {
- public:
-   MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
+public:
+  typedef CountPointer<MD2Data>    Pointer;
+public:
+  MD2Data();
+  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:
+private:
+  void init();
+  bool loadModel(const std::string& fileName);
+  bool loadSkin(const std::string& fileName = "");
+
+public:
   int                numFrames;             //!< number of frames
   int                numVertices;           //!< number of vertices
@@ -148,9 +153,16 @@
 
 //! This is a MD2 Model class
-class MD2Model : public InteractiveModel {
-
-public:
+class MD2Model : public InteractiveModel
+{
+  ObjectListDeclaration(MD2Model);
+public:
+  MD2Model();
   MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
+  MD2Model(const MD2Model& model);
   virtual ~MD2Model();
+
+  MD2Model& operator=(const MD2Model& md2model);
+
+  bool load(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
 
   virtual void draw() const;
@@ -160,10 +172,13 @@
   virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
   /**  returns the current animation @returns animation type */
-  inline int MD2Model::getAnimation() { return this->animationState.type; }
+  inline int getAnimation() const { return this->animationState.type; }
   virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
-  virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
+virtual bool isAnimationFinished() const { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
   /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
   void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
 
+
+  void acquireData(const MD2Data::Pointer& data) { this->data = data; rebuildInfo(); };
+  const MD2Data::Pointer& dataPointer() const { return this->data; };
   virtual void tick(float dtS);
   void debug();
@@ -171,4 +186,7 @@
 
 private:
+  void init();
+  void rebuildInfo();
+
   void animate(float time);
   void processLighting();
@@ -177,19 +195,19 @@
 
 
- public:
+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[22];                //!< 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)
-  float               animationSpeed;                   //!< the speed of the animation (factor for the time)
-  sAnimState          animationState;                   //!< animation state of the model
-  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
+  static sVec3D         anorms[NUM_VERTEX_NORMALS];       //!< the anormals
+  static float          anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
+  static sAnim          animationList[22];                //!< the anomation list
+  //! again one of these strange id software parts
+  float*                shadeDots;
+
+  CountPointer<MD2Data> data;                           //!< the md2 data pointer
+
+private:
+  float                 scaleFactor;                      //!< the scale factor (individual)
+  float                 animationSpeed;                   //!< the speed of the animation (factor for the time)
+  sAnimState            animationState;                   //!< animation state of the model
+  sVec3D                verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
 };
 
