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;
00016 float life;
00017 float fade;
00018
00019 float r;
00020 float g;
00021 float b;
00022
00023 float x;
00024 float y;
00025 float z;
00026
00027 float xi;
00028 float yi;
00029 float zi;
00030
00031 float xg;
00032 float yg;
00033 float zg;
00034
00035 int texNum;
00036 } particle;
00037
00038
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
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;
00094 float xspeed;
00095 float yspeed;
00096 float zspeed;
00097 float zoom;
00098 float vScale;
00099
00100 GLuint loop;
00101 GLuint col;
00102 GLuint 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
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;
00129
00130
00131 };
00132
00133 #endif