// // Draw a Cube // void Cube(const Matrix &m, const Vector &v0, const Vector &v1, Color color, Color specular) { // Cube face definition const U16 CUBE_FACES[] = { 0, 4, 7, // left 0, 7, 3, 6, 5, 1, // right 2, 6, 1, 7, 6, 2, // front 3, 7, 2, 5, 4, 0, // back 1, 5, 0, 7, 4, 5, // top 7, 5, 6, 1, 0, 3, // bottom 1, 3, 2, }; const U32 CUBE_NFACES = sizeof(CUBE_FACES) / sizeof(CUBE_FACES[0]); const U32 CUBE_NVERTS = 8; Vector verts[CUBE_NVERTS]; verts[0].Set(v1.x, v0.y, v0.z); verts[1].Set(v0.x, v0.y, v0.z); verts[2].Set(v0.x, v0.y, v1.z); verts[3].Set(v1.x, v0.y, v1.z); verts[4].Set(v1.x, v1.y, v0.z); verts[5].Set(v0.x, v1.y, v0.z); verts[6].Set(v0.x, v1.y, v1.z); verts[7].Set(v1.x, v1.y, v1.z); RenderFaces(&m, verts, CUBE_NVERTS, CUBE_FACES, CUBE_NFACES, color, specular, DP_DONOTLIGHT); }
void Mesh::Display() const { RenderFaces(); if (renderNormals) { RenderNormals(); } }
// // Draw a pyramid // void Pyramid(const Matrix &m, const Vector verts[5], Color color, Color specular) { // Pyramid face definition const U16 PYRAMID_FACES[] = { 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0, 4, 0, 3, 2, 0, 2, 1, }; const U32 PYRAMID_NFACES = sizeof(PYRAMID_FACES) / sizeof(PYRAMID_FACES[0]); const U32 PYRAMID_NVERTS = 5; RenderFaces(&m, verts, PYRAMID_NVERTS, PYRAMID_FACES, PYRAMID_NFACES, color, specular, DP_DONOTLIGHT); }
// // Draw Tetrahedron // void Tetrahedron(const Matrix &m, Color color, Color specular) { // Tetrahedron offsets const Vector offsets[4] = { Vector(0.0f, -1.0f, 0.0f), Vector(0.0f, 0.5f, -0.866025403784f), Vector(0.75f, 0.5f, 0.433012701892f), Vector(-0.75f, 0.5f, 0.433012701892f) }; // Tetrahedron verticies Vector verts[4] = { offsets[0], offsets[1], offsets[2], offsets[3] }; m.Rotate(verts[0]); m.Rotate(verts[1]); m.Rotate(verts[2]); m.Rotate(verts[3]); verts[0] += m.posit; verts[1] += m.posit; verts[2] += m.posit; verts[3] += m.posit; // Tetrahedron face definition const U16 TETRAHEDRON_FACES[] = { 0, 1, 3, 0, 3, 2, 0, 2, 1, 1, 2, 3 }; const U32 TETRAHEDRON_NFACES = sizeof (TETRAHEDRON_FACES) / sizeof (TETRAHEDRON_FACES[0]); const U32 TETRAHEDRON_NVERTS = 4; RenderFaces(NULL, verts, TETRAHEDRON_NVERTS, TETRAHEDRON_FACES, TETRAHEDRON_NFACES, color, specular, 0); }