Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

md2shape.h

00001 
00013 /***************************************************************************
00014                           md2shape.h  -  description
00015                              -------------------
00016     begin                : Fri Oct 3 2003
00017     copyright            : (C) 2003 by Gabor Torok
00018     email                : cctorok@yahoo.com
00019  ***************************************************************************/
00020 
00021 /***************************************************************************
00022  *                                                                         *
00023  *   This program is free software; you can redistribute it and/or modify  *
00024  *   it under the terms of the GNU General Public License as published by  *
00025  *   the Free Software Foundation; either version 2 of the License, or     *
00026  *   (at your option) any later version.                                   *
00027  *                                                                         *
00028  ***************************************************************************/
00029 
00030 #ifndef MD2SHAPE_H
00031 #define MD2SHAPE_H
00032 
00033 #include <iostream>
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 
00037 # include <string>
00038 # include <vector>
00039 # include <map>
00040 
00041 #include "constants.h"
00042 #include "glshape.h"
00043 
00044 class MD2Shape : public GLShape  {
00045 
00046 // uncomment to show debug shapes
00047 //#define DEBUG_MD2 1
00048 
00049 private:
00050   bool attackEffect;
00051   float div;
00052   char *skin_name;
00053   GLuint textureId;
00054   //float movex, movey, movez;  
00055   t3DModel * g_3DModel;                 // This holds the 3D Model info that we load in
00056   int g_ViewMode;                       // make this GL_LINE_STRIP for outline
00057   int dir;      
00058   vect3d *vect;     
00059       
00060   // Animation stuff
00061   float elapsedTime;
00062   float lastTime;  
00063   bool pauseAnimation;
00064   int currentAnim;
00065   int currentFrame; 
00066   int animationWaiting; // memorizes one animation waiting to be played
00067   float angle;
00068 
00069   bool debug;
00070   
00071   // To ensure that animations with few frames are played at least once entirely
00072   bool playedOnce; 
00073 
00074   float creatureSpeed;
00075       
00076    
00077   // This draws and animates the .md2 model by interpoloated key frame animation
00078   void AnimateMD2Model();
00079   
00080   // This returns time t for the interpolation between the current and next key frame
00081   float ReturnCurrentTime(int nextFrame);
00082 
00083   GLShape *debugShape;
00084 
00085   MD2Shape(t3DModel * g_3DModel, GLuint textureId, float div,
00086            GLuint texture[], int width, int depth, int height,
00087            char *name, int descriptionGroup,
00088            Uint32 color, Uint8 shapePalIndex=0);
00089 
00090 public:     
00091         ~MD2Shape();
00092 
00093   inline GLShape *getDebugShape() { return debugShape; }
00094 
00095   inline void setCreatureSpeed( float n ) { creatureSpeed = n; }
00096 
00097   inline void setDebug(bool b) { debug = b; }
00098 
00099   inline bool getAttackEffect() { return attackEffect; }
00100   inline void setAttackEffect(bool b) { attackEffect = b; }
00101 
00102   void setCurrentAnimation(int numAnim, bool force=false);
00103   inline int getCurrentAnimation() { return currentAnim; }
00104 
00105   void draw();
00106   void outline( float r, float g, float b );
00107   void setupToDraw();
00108 
00109   void setDir(int dir);  
00110   bool drawFirst();
00111   // if true, the next two functions are called
00112   bool drawLater();
00113   void setupBlending();
00114   void endBlending();  
00115   inline void setPauseAnimation(bool pause) { pauseAnimation = pause; }
00116   inline GLuint getTextureId() { return textureId; }
00117   inline void setSkinName(char *s) { skin_name = s; }
00118   inline char *getSkinName() { return skin_name; }
00119 
00120   inline void setAngle(float angle) { 
00121     float a = angle + 90.0f;
00122     if(a >= 360.0f) a -= 360.0f;
00123     this->angle = a; 
00124   }
00125 
00126   // Factory method to create shape. It computes the dimensions and normalizes the
00127   // model's points.
00128   static MD2Shape *createShape(t3DModel *g_3DModel, GLuint textureId, float div,
00129                                GLuint texture[], char *name, int descriptionGroup,
00130                                Uint32 color, Uint8 shapePalIndex);
00131 
00132 protected:
00133   void commonInit(t3DModel * g_3DModel, GLuint textureId, float div);
00134 };
00135 
00136 #endif

Generated on Thu Jun 16 21:50:43 2005 for scourge by  doxygen 1.4.0