Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

SparklerDrawingWidget.H

Go to the documentation of this file.
00001 #ifndef __SPARKLER_DRAWING_WIDGET__
00002 #define __SPARKLER_DRAWING_WIDGET__
00003 
00004 #include <IS3D.H>
00005 #include <GL/gl.h>
00006 #include <GL/glu.h>
00007 #include "SDL.h"
00008 
00009 #define MAX_PARTICLES 12
00010 
00011 typedef ReferenceCountedPointer<class SparklerDrawingWidget> SparklerDrawingWidgetRef;
00012 
00013 typedef struct
00014         {
00015             int   active; /* Active (Yes/No) */
00016             float life;   /* Particle Life   */
00017             float fade;   /* Fade Speed      */
00018 
00019             float r;      /* Red Value       */
00020             float g;      /* Green Value     */
00021             float b;      /* Blue Value      */
00022 
00023             float x;      /* X Position      */
00024             float y;      /* Y Position      */
00025             float z;      /* Z Position      */
00026 
00027             float xi;     /* X Direction     */
00028             float yi;     /* Y Direction     */
00029             float zi;     /* Z Direction     */
00030 
00031             float xg;     /* X Gravity       */
00032             float yg;     /* Y Gravity       */
00033             float zg;     /* Z Gravity       */
00034 
00035             int texNum;   /* Which texture we're using */
00036         } particle;
00037 
00038         /* Rainbow of colors */
00039         static GLfloat gabesOriginalColors[12][3] =
00040         {
00041             { 1.0f,  0.5f,  0.5f},
00042             { 1.0f,  0.75f, 0.5f},
00043             { 1.0f,  1.0f,  0.5f},
00044             { 0.75f, 1.0f,  0.5f},
00045             { 0.5f,  1.0f,  0.5f},
00046             { 0.5f,  1.0f,  0.75f},
00047             { 0.5f,  1.0f,  1.0f},
00048             { 0.5f,  0.75f, 1.0f},
00049             { 0.5f,  0.5f,  1.0f},
00050             { 0.75f, 0.5f,  1.0f},
00051             { 1.0f,  0.5f,  1.0f},
00052             { 1.0f,  0.5f,  0.75f}
00053         };
00054 
00055         /* Rainbow of colors */
00056         static GLfloat colors[12][3] =
00057         {
00058             { 1.0f,  0.8f,  0.8f},
00059             { 1.0f,  0.9f,  0.8f},
00060             { 1.0f,  0.9f,  0.9f},
00061             { 1.0f,  1.0f,  0.9f},
00062             { 1.0f,  1.0f,  1.0f},
00063             { 1.0f,  0.9f,  0.9f},
00064             { 0.9f,  0.9f,  0.9f},
00065             { 0.8f,  0.9f,  0.9f},
00066             { 0.8f,  0.9f,  1.0f},
00067             { 1.0f,  0.8f,  0.8f},
00068             { 1.0f,  1.0f,  0.8f},
00069             { 0.8,  0.8f,  1.0f},
00070         };
00071 
00072 
00073 class SparklerDrawingWidget : public DrawObj {
00074     public:
00075         SparklerDrawingWidget( Array<std::string> brushTrackerTriggers,
00076                    Array<std::string> otherTrackerTriggers);
00077 
00078         virtual void draw();
00079         virtual void drawSparkler();
00080 
00081     private:
00082         void brushMovement( EventRef e );
00083         void otherMovement( EventRef e );
00084 
00085         void headMovement(EventRef e);
00086         int loadGLTextures();
00087         void ResetParticle( int num, int color, double  xDir, double yDir, float zDir , float x, float y, float z, int newCol);
00088         int initGL( GLvoid );
00089 
00090 
00091         TextureRef tex1, tex2, tex3, m_smokeTexture;
00092 
00093         float slowdown; /* Slow Down Particles                                */
00094         float xspeed;          /* Base X Speed (To Allow Keyboard Direction Of Tail) */
00095         float yspeed;          /* Base Y Speed (To Allow Keyboard Direction Of Tail) */
00096         float zspeed;
00097         float zoom;   /* Used To Zoom Out                                   */
00098   float vScale; 
00099 
00100         GLuint loop;           /* Misc Loop Variable                                 */
00101         GLuint col;        /* Current Color Selection                            */
00102         GLuint delay;          /* Rainbow Effect Delay                               */
00103 
00104         GLdouble particleStartX;
00105         GLdouble particleStartY;
00106         GLdouble particleStartZ;
00107 
00108         GLdouble prevStartX;
00109         GLdouble prevStartY;
00110         GLdouble prevStartZ;
00111         
00112         CoordinateFrame _brush_frame, _other_hand_frame;
00113         CoordinateFrame m_originalCoordFrame;
00114 
00115         CoordinateFrame m_headTrackerFrame;
00116 
00117         /* Vertex Arrays for Sparkler */
00118         VAR m_vertexVar;
00119         VAR m_textureVar;
00120         VAR m_colorVar;
00121         VARAreaRef m_writeOnce;
00122         Array<Vector3> m_vertexArray;
00123         Array<uint32> m_indexArray;
00124         Array<Vector2> m_textureArray;
00125         Array<Color4> m_colorArray;
00126         particle* particles;
00127         
00128         GLuint* texture;     /* Storage For Our Particle Texture                   */
00129 
00130 
00131 };
00132 
00133 #endif

Generated on Sun Apr 17 13:34:27 2005 for cavewriting by  doxygen 1.4.0