/* ==================== idSurface_Polytope::SetupTetrahedron ==================== */ void idSurface_Polytope::SetupTetrahedron( const idBounds &bounds ) { idVec3 center, scale; float c1, c2, c3; c1 = 0.4714045207f; c2 = 0.8164965809f; c3 = -0.3333333333f; center = bounds.GetCenter(); scale = bounds[1] - center; verts.SetNum( 4 ); verts[0].xyz = center + idVec3( 0.0f, 0.0f, scale.z ); verts[1].xyz = center + idVec3( 2.0f * c1 * scale.x, 0.0f, c3 * scale.z ); verts[2].xyz = center + idVec3( -c1 * scale.x, c2 * scale.y, c3 * scale.z ); verts[3].xyz = center + idVec3( -c1 * scale.x, -c2 * scale.y, c3 * scale.z ); indexes.SetNum( 4*3 ); indexes[0*3+0] = 0; indexes[0*3+1] = 1; indexes[0*3+2] = 2; indexes[1*3+0] = 0; indexes[1*3+1] = 2; indexes[1*3+2] = 3; indexes[2*3+0] = 0; indexes[2*3+1] = 3; indexes[2*3+2] = 1; indexes[3*3+0] = 1; indexes[3*3+1] = 3; indexes[3*3+2] = 2; GenerateEdgeIndexes(); }
/* ==================== idSurface_Polytope::SetupHexahedron ==================== */ void idSurface_Polytope::SetupHexahedron(const idBounds &bounds) { idVec3 center, scale; center = bounds.GetCenter(); scale = bounds[1] - center; verts.SetNum(8); verts[0].xyz = center + idVec3(-scale.x, -scale.y, -scale.z); verts[1].xyz = center + idVec3(scale.x, -scale.y, -scale.z); verts[2].xyz = center + idVec3(scale.x, scale.y, -scale.z); verts[3].xyz = center + idVec3(-scale.x, scale.y, -scale.z); verts[4].xyz = center + idVec3(-scale.x, -scale.y, scale.z); verts[5].xyz = center + idVec3(scale.x, -scale.y, scale.z); verts[6].xyz = center + idVec3(scale.x, scale.y, scale.z); verts[7].xyz = center + idVec3(-scale.x, scale.y, scale.z); indexes.SetNum(12*3); indexes[ 0*3+0] = 0; indexes[ 0*3+1] = 3; indexes[ 0*3+2] = 2; indexes[ 1*3+0] = 0; indexes[ 1*3+1] = 2; indexes[ 1*3+2] = 1; indexes[ 2*3+0] = 0; indexes[ 2*3+1] = 1; indexes[ 2*3+2] = 5; indexes[ 3*3+0] = 0; indexes[ 3*3+1] = 5; indexes[ 3*3+2] = 4; indexes[ 4*3+0] = 0; indexes[ 4*3+1] = 4; indexes[ 4*3+2] = 7; indexes[ 5*3+0] = 0; indexes[ 5*3+1] = 7; indexes[ 5*3+2] = 3; indexes[ 6*3+0] = 6; indexes[ 6*3+1] = 5; indexes[ 6*3+2] = 1; indexes[ 7*3+0] = 6; indexes[ 7*3+1] = 1; indexes[ 7*3+2] = 2; indexes[ 8*3+0] = 6; indexes[ 8*3+1] = 2; indexes[ 8*3+2] = 3; indexes[ 9*3+0] = 6; indexes[ 9*3+1] = 3; indexes[ 9*3+2] = 7; indexes[10*3+0] = 6; indexes[10*3+1] = 7; indexes[10*3+2] = 4; indexes[11*3+0] = 6; indexes[11*3+1] = 4; indexes[11*3+2] = 5; GenerateEdgeIndexes(); }
/* ==================== idSurface_Polytope::SetupOctahedron ==================== */ void idSurface_Polytope::SetupOctahedron(const idBounds &bounds) { idVec3 center, scale; center = bounds.GetCenter(); scale = bounds[1] - center; verts.SetNum(6); verts[0].xyz = center + idVec3(scale.x, 0.0f, 0.0f); verts[1].xyz = center + idVec3(-scale.x, 0.0f, 0.0f); verts[2].xyz = center + idVec3(0.0f, scale.y, 0.0f); verts[3].xyz = center + idVec3(0.0f, -scale.y, 0.0f); verts[4].xyz = center + idVec3(0.0f, 0.0f, scale.z); verts[5].xyz = center + idVec3(0.0f, 0.0f, -scale.z); indexes.SetNum(8*3); indexes[0*3+0] = 4; indexes[0*3+1] = 0; indexes[0*3+2] = 2; indexes[1*3+0] = 4; indexes[1*3+1] = 2; indexes[1*3+2] = 1; indexes[2*3+0] = 4; indexes[2*3+1] = 1; indexes[2*3+2] = 3; indexes[3*3+0] = 4; indexes[3*3+1] = 3; indexes[3*3+2] = 0; indexes[4*3+0] = 5; indexes[4*3+1] = 2; indexes[4*3+2] = 0; indexes[5*3+0] = 5; indexes[5*3+1] = 1; indexes[5*3+2] = 2; indexes[6*3+0] = 5; indexes[6*3+1] = 3; indexes[6*3+2] = 1; indexes[7*3+0] = 5; indexes[7*3+1] = 0; indexes[7*3+2] = 3; GenerateEdgeIndexes(); }