00001 00008 #ifndef CUBE_H 00009 #define CUBE_H 00010 00011 #include <gl/glew.h> 00012 #include "Color4.h" 00013 #include "MathCommon.h" 00014 00015 const unsigned short MAX_PLANES = 512; // Must be less then 10922 00016 const unsigned short START_PLANE_COUNT = 1; 00017 00023 class Cube 00024 { 00025 public: 00026 00030 Cube(); 00031 00035 ~Cube(); 00036 00040 void Init(); 00041 00045 void Draw(); 00046 00050 void DrawOutline(); 00051 00055 void DrawPlanes(); 00056 00062 void SetNumberOfPlanes(int n); 00063 00069 void SetViewDirection(const Vector3f &vd) { dir = Normalize(vd); UpdatePlanes(); } 00070 00076 void SetCubeColor(const Color4f &c) { mainColor.Set(c.r, c.g, c.b); } 00077 00083 void SetOutlineColor(const Color4f &c) { outlineColor.Set(c.r, c.g, c.b); } 00084 00090 void SetPlaneColor(const Color4f &c) { planeColor.Set(c.r, c.g, c.b); } 00091 00092 private: 00093 00094 void UpdatePlanes(); 00095 00096 Color4f mainColor; 00097 Color4f outlineColor; 00098 Color4f planeColor; 00100 CubeFrame frame; // Used for clipping and drawing the cube outline. 00101 CubePlanes planes; 00102 00103 // Plane definition data 00104 int numberOfPlanes; 00105 int triangleCount; 00106 00107 Vector3f dir; 00108 00109 // OpenGL ids 00110 GLuint facesVbo; 00111 GLuint linesVbo; 00112 00113 GLuint planeVertsVbo; 00114 GLuint planeIndicesVbo; 00115 }; 00116 00117 #endif