00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #ifndef GLCUBE_H
00019 #define GLCUBE_H
00020 
00021 #include <vector>
00022 #include "glgeometricobject.h"
00023 #include "gllocalcoordinatesystem.h"
00024 #include "glquad.h"
00025 #include "glsphere.h"
00026 
00027 
00031 namespace GLScene
00032 {
00033   
00034    class GLCube : public GLGeometricObject,
00035                   public GLLocalCoordinateSystem
00036    {
00037       bool changed;
00038       
00039       GLQuad quads[6];
00040       GLfloat width, height, length;
00041    public: 
00042       GLCube(GLfloat _w = 1 , GLfloat _h = 1, GLfloat _l = 1);
00043     ~GLCube();
00044 
00045       SML_TAG(cube);
00046       
00047    
00048 
00049 
00050 
00051 
00052       virtual bool intersection( GLGeometricObject* obj ) { return obj->intersection((GLCube*)this); };
00053       virtual bool intersection( GLCube* ) { exit(1); return false; };
00054       virtual bool intersection( GLSphere* sp );
00055       virtual bool inclusion( GLGeometricObject*) { exit(1); return false;};
00056 
00057       inline void setWidth(GLfloat v) { width = v/2; changed = true; };
00058       inline void setHeight(GLfloat v) { height = v/2; changed = true; };
00059       inline void setLength(GLfloat v) { length = v/2; changed = true; };
00060 
00061       inline GLfloat getWidth() { return 2*width; };
00062       inline GLfloat getHeight() { return 2*height; };
00063       inline GLfloat getLength() { return 2*length; };
00064       
00065       GLPlane* const getPlanes();
00066       virtual void render( );
00067       void renderForSelection(GLuint& previousName);
00068 
00069       protected:
00070       
00071       void makeQuads();
00072 
00073       
00074 
00075 
00076 
00077    };
00078 };
00079 #endif