Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Box.cpp

Go to the documentation of this file.
00001 
00007 #include "Box.h"
00008 
00009 Box::Box(float size) {
00010         m_pBoxVertices = NULL;
00011 
00012         char boxIndices[] = 
00013         {
00014                  0, 1, 2, 3,
00015                  4, 5, 6, 7,
00016                  8, 9,10,11,
00017                 12,13,14,15,
00018                 16,17,18,19,
00019                 20,21,22,23
00020         };
00021 
00022         Vertex boxVertices[24] = {
00023                 // front face
00024                 {0.0f, 0.0f,     0.0f, 0.0f, 1.0f,      -size,-size, size},
00025                 {1.0f, 0.0f,     0.0f, 0.0f, 1.0f,       size,-size, size},
00026                 {1.0f, 1.0f,     0.0f, 0.0f, 1.0f,       size, size, size},
00027                 {0.0f, 1.0f,     0.0f, 0.0f, 1.0f,      -size, size, size},
00028 
00029                 // Back face
00030                 {1.0f, 0.0f,     0.0f, 0.0f,-1.0f,      -size,-size,-size},
00031                 {1.0f, 1.0f,     0.0f, 0.0f,-1.0f,      -size, size,-size},
00032                 {0.0f, 1.0f,     0.0f, 0.0f,-1.0f,       size, size,-size},
00033                 {0.0f, 0.0f,     0.0f, 0.0f,-1.0f,       size,-size,-size},
00034 
00035                 // Top face
00036                 {0.0f, 1.0f,     0.0f, 1.0f, 0.0f,      -size, size,-size},
00037                 {0.0f, 0.0f,     0.0f, 1.0f, 0.0f,      -size, size, size},
00038                 {1.0f, 0.0f,     0.0f, 1.0f, 0.0f,       size, size, size},
00039                 {1.0f, 1.0f,     0.0f, 1.0f, 0.0f,       size, size,-size},
00040 
00041                 // Bottom face
00042                 {1.0f, 1.0f,     0.0f,-1.0f, 0.0f,      -size,-size,-size},
00043                 {0.0f, 1.0f,     0.0f,-1.0f, 0.0f,       size,-size,-size},
00044                 {0.0f, 0.0f,     0.0f,-1.0f, 0.0f,       size,-size, size},
00045                 {1.0f, 0.0f,     0.0f,-1.0f, 0.0f,      -size,-size, size},
00046 
00047                 // Right face
00048                 {1.0f, 0.0f,     1.0f, 0.0f, 0.0f,       size,-size,-size},
00049                 {1.0f, 1.0f,     1.0f, 0.0f, 0.0f,       size, size,-size},
00050                 {0.0f, 1.0f,     1.0f, 0.0f, 0.0f,       size, size, size},
00051                 {0.0f, 0.0f,     1.0f, 0.0f, 0.0f,       size,-size, size},
00052 
00053                 // Left face
00054                 {0.0f, 0.0f,    -1.0f, 0.0f, 0.0f,      -size,-size,-size},
00055                 {1.0f, 0.0f,    -1.0f, 0.0f, 0.0f,      -size,-size, size},
00056                 {1.0f, 1.0f,    -1.0f, 0.0f, 0.0f,      -size, size, size},
00057                 {0.0f, 1.0f,    -1.0f, 0.0f, 0.0f,      -size, size,-size}
00058         };
00059 
00060         m_pBoxVertices = new Vertex[24];
00061         memcpy(m_pBoxVertices, boxVertices, 24*sizeof(Vertex));
00062 
00063         addFormat(ATT_VERTEX, ATT_FLOAT, 3, sizeof(float)*5);
00064         addFormat(ATT_NORMAL, ATT_FLOAT, 3, sizeof(float)*2);
00065         addFormat(ATT_TEX, ATT_FLOAT, 2, 0);
00066         setPrimitive(PRIM_QUADS);
00067         setVertices(m_pBoxVertices, 24, sizeof(Vertex));
00068         //setIndices(boxIndices, numBoxIndices, sizeof(char));
00069 
00070         LOG_SUCCESS(("Object box loaded"));
00071 }
00072 
00073 Box::~Box() {
00074         m_pBoxVertices = NULL;          // deletion handled by Object.cpp
00075 }

Generated on Sun Jun 5 15:47:03 2005 for Defacto by  doxygen 1.4.3