Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

box.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
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

Generated on Fri Aug 20 19:19:42 2004 for 3d Controls by doxygen 1.3.6