00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00023 #ifndef INCLUDE_3D_BOX
00024 #define INCLUDE_3D_BOX
00025
00026 #include "coordonate.h"
00027 #include "material.h"
00028
00033 class Box3D
00034 {
00035 public:
00036 Material material;
00037 Coordonate<GLfloat> coor;
00038 Coordonate<GLfloat> delta;
00039
00040 public:
00041 Box3D()
00042 {
00043 Zero();
00044 }
00045
00046 void Zero()
00047 {
00048 coor.Zero();
00049 delta.Zero();
00050 material.Zero();
00051 }
00052
00053 void operator=(Box3D &source)
00054 {
00055 material=source.material;
00056 coor=source.coor;
00057 delta=source.delta;
00058 }
00059
00060 void Draw()
00061 {
00062 float x1 = coor.x;
00063 float x2 = x1+delta.x;
00064 float y1 = coor.y;
00065 float y2 = y1+delta.y;
00066 float z1 = coor.z;
00067 float z2 = z1+delta.z;
00068
00069 material.Use();
00070 glDisable(GL_BLEND);
00071 glDisable(GL_TEXTURE_2D);
00072 glBegin(GL_QUADS);
00073
00074 glVertex3f(x1,y1,z1);
00075 glVertex3f(x2,y1,z1);
00076 glVertex3f(x2,y2,z1);
00077 glVertex3f(x1,y2,z1);
00078
00079 glVertex3f(x1,y1,z1);
00080 glVertex3f(x1,y1,z2);
00081 glVertex3f(x1,y2,z2);
00082 glVertex3f(x1,y2,z1);
00083
00084 glVertex3f(x1,y1,z1);
00085 glVertex3f(x2,y1,z1);
00086 glVertex3f(x2,y1,z2);
00087 glVertex3f(x1,y1,z2);
00088
00089 glVertex3f(x2,y1,z1);
00090 glVertex3f(x2,y1,z2);
00091 glVertex3f(x2,y2,z2);
00092 glVertex3f(x2,y2,z1);
00093
00094 glVertex3f(x1,y2,z1);
00095 glVertex3f(x2,y2,z1);
00096 glVertex3f(x2,y2,z2);
00097 glVertex3f(x1,y2,z2);
00098
00099 glVertex3f(x1,y1,z2);
00100 glVertex3f(x2,y1,z2);
00101 glVertex3f(x2,y2,z2);
00102 glVertex3f(x1,y2,z2);
00103 glEnd();
00104 }
00105
00106 void CenterIt()
00107 {
00108 coor.x-=delta.x/2.0f;
00109 coor.y-=delta.y/2.0f;
00110 coor.z-=delta.z/2.0f;
00111 }
00112 };
00113
00114 #endif