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

glshape.h

00001 /***************************************************************************
00002                           glshape.h  -  description
00003                              -------------------
00004     begin                : Thu Jul 10 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLSHAPE_H
00019 #define GLSHAPE_H
00020 
00021 #include "constants.h"
00022 #include "shape.h"
00023 #include <vector>
00024 
00025 using namespace std;
00026 
00027 class WallTheme;
00028 
00032 struct surface {
00033         float vertices[4][3];
00034   //    float matrix[9];
00035   //    float s_dist, t_dist;
00036 };
00037 
00038 class ShapePalette;
00039 
00040 class GLShape : public Shape  {
00041 private:
00046   GLuint *tex;
00047   Uint8 shapePalIndex;
00048   int skipside;
00049   bool useTexture;
00050   bool lightBlocking;
00051   float xIconRot, yIconRot, zIconRot;
00052   GLuint displayListStart;
00053   bool initialized;
00054   vector<GLShape*> variationShape;
00055   int variationTextureIndex;
00056 
00057   struct surface *surfaces[5];
00058   enum { 
00059     LEFT_SURFACE=0, 
00060     RIGHT_SURFACE, 
00061     FRONT_SURFACE, 
00062     TOP_SURFACE, 
00063     BOTTOM_SURFACE 
00064   };
00065 
00066 #define LIGHTMAP_SIZE 16
00067 
00068  protected:
00069   Uint32 color;
00070   
00071  public:
00072   static const float DIV = 0.06f;
00073   static const int FRONT_SIDE = 0;
00074   static const int TOP_SIDE = 1;
00075   static const int LEFT_RIGHT_SIDE = 2;  
00076   
00077   inline void setUseTexture(bool b) { useTexture = b; }
00078   inline bool getUseTexture() { return useTexture; }
00079   
00080   bool useShadow;
00081 
00082 public:
00083 
00088   GLShape(GLuint texture[],
00089           int width, int depth, int height,
00090           char *name, int descriptionGroup,
00091           Uint32 color, Uint8 shapePalIndex=0);
00092   
00093   ~GLShape();  
00094 
00095   virtual void initialize();
00096 
00097   void deleteVariationShapes();
00098   void createVariationShape( int textureIndex, GLuint *textureGroup );
00099   inline void setVariationTextureIndex( int index ) { variationTextureIndex = index; }
00100   inline int getVariationTextureIndex() { return variationTextureIndex; }
00101   inline int getVariationShapesCount() { return variationShape.size(); }
00102   inline GLShape *getVariationShape( int index ) { return variationShape[ index ]; }
00103 
00104   static void createDarkTexture( WallTheme *theme );
00105   void setTexture( GLuint *textureGroup );
00106 
00107   inline void setSkipSide(int n) { skipside = n; }
00108   bool fitsInside(GLShape *smaller);  
00109   bool isLightBlocking();
00110   void setLightBlocking(bool b);
00111   void draw();   
00112   void outline( float r, float g, float b );
00113   inline void setupToDraw() {};
00114   
00115   inline Uint8 getShapePalIndex() { return shapePalIndex; }
00116   
00117   inline void setCameraRot(GLfloat xrot, GLfloat yrot, GLfloat zrot) { this->xrot = xrot; this->yrot = yrot; this->zrot = zrot; }
00118   inline void setCameraPos(GLfloat xpos, GLfloat ypos, GLfloat zpos, GLfloat xpos2, GLfloat ypos2, GLfloat zpos2) { this->xpos = xpos; this->ypos = ypos; this->zpos = zpos; this->xpos2 = xpos2; this->ypos2 = ypos2; this->zpos2 = zpos2;}
00119   inline void setLocked(bool locked) { this->locked = locked; }
00120   inline GLfloat getYRot() { return yrot; }
00121   inline GLfloat getZRot() { return zrot; }
00122   
00123   inline bool drawFirst() { return true; }
00124   // if true, the next two functions are called
00125   inline bool drawLater() { return false; }
00126   //inline void setupBlending() { glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA); }
00127   void setupBlending();
00128   inline void endBlending() { }
00129   inline void setIconRotation(float x, float y, float z) { xIconRot = x; yIconRot = y; zIconRot = z; }
00130   inline void applyIconRotation() { glRotatef(xIconRot, 1, 0, 0); glRotatef(yIconRot, 0, 1, 0); glRotatef(zIconRot, 0, 0, 1); }
00131 
00132   virtual void setCurrentAnimation (int numAnim, bool force=false);      
00133   virtual void setPauseAnimation(bool pause);
00134   
00135  protected:
00136   bool locked;
00137   GLfloat xrot, yrot, zrot;
00138   GLfloat xpos, ypos, zpos, xpos2, ypos2, zpos2;
00139   void commonInit(GLuint tex[], Uint32 color, Uint8 shapePalIndex);
00140   static struct surface *new_surface(float vertices[4][3]);
00141   void initSurfaces();
00142   void drawShadow();
00143   void createShadowList( GLuint listName );
00144   void createBodyList( GLuint listName );
00145   void createTopList( GLuint listName );
00146 };
00147 
00148 #endif

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