// *************************************************************************** void CShapeInfo::build(const CMeshBase &meshBase, const CMeshGeom &meshGeom) { // Get the vertex buffer const CVertexBuffer &vb=meshGeom.getVertexBuffer(); CVertexBufferRead vba; vb.lock (vba); // For each matrix block uint numBlock=meshGeom.getNbMatrixBlock(); for (uint block=0; block<numBlock; block++) { // For each render pass uint numRenderPass=meshGeom.getNbRdrPass(block); for (uint pass=0; pass<numRenderPass; pass++) { // Get the material const CMaterial &material = meshBase.getMaterial (meshGeom.getRdrPassMaterial ( block, pass)); if (material.getBlend()) continue; // don't test against transparent materials //if (material.getAlphaTest()) continue; // don't test against transparent materials // Get the primitive block const CIndexBuffer &primitive=meshGeom.getRdrPassPrimitiveBlock ( block, pass); // Copy triangles CIndexBufferRead iba; primitive.lock (iba); if (iba.getFormat() == CIndexBuffer::Indices32) { const uint32* triIndex= (const uint32*) iba.getPtr (); uint numTri=primitive.getNumIndexes ()/3; uint tri; for (tri=0; tri<numTri; tri++) { // Vertex CVector v0= *vba.getVertexCoordPointer (triIndex[tri*3]); CVector v1= *vba.getVertexCoordPointer (triIndex[tri*3+1]); CVector v2= *vba.getVertexCoordPointer (triIndex[tri*3+2]); Tris.push_back(NLMISC::CTriangle (v0, v1, v2)); } } else { const uint16* triIndex= (const uint16*) iba.getPtr (); uint numTri=primitive.getNumIndexes ()/3; uint tri; for (tri=0; tri<numTri; tri++) { // Vertex CVector v0= *vba.getVertexCoordPointer (triIndex[tri*3]); CVector v1= *vba.getVertexCoordPointer (triIndex[tri*3+1]); CVector v2= *vba.getVertexCoordPointer (triIndex[tri*3+2]); Tris.push_back(NLMISC::CTriangle (v0, v1, v2)); } } } } }
void FlagVerticesMRM (CMeshMRMGeom &mg, uint InMatID, vector<bool> &verticesNeedRemap) { CVertexBuffer &vertexBuffer = const_cast<CVertexBuffer&>(mg.getVertexBuffer()); // For each matrix block uint matrixBlock; uint nbMatrixBlock=1;//mg.getNbMatrixBlock(); // ASK YOYO for (matrixBlock=0; matrixBlock<nbMatrixBlock; matrixBlock++) { // For each render pass uint renderPass; uint numRenderPass=mg.getNbRdrPass(matrixBlock); for (renderPass=0; renderPass<numRenderPass; renderPass++) { // Render pass material uint32 matId=mg.getRdrPassMaterial(matrixBlock, renderPass); if (matId == InMatID) // Same Material -> Flag all vertices of this pass { // Get primitives const CIndexBuffer &primitiveBlock=mg.getRdrPassPrimitiveBlock(matrixBlock,renderPass); CIndexBufferRead iba; primitiveBlock.lock (iba); // Set of vertex to remap std::set<uint> vertexToRemap; // Remap triangles uint index; if (iba.getFormat() == CIndexBuffer::Indices32) { const uint32 *indexPtr=(const uint32 *)iba.getPtr(); uint32 numIndex=primitiveBlock.getNumIndexes(); for (index=0; index<numIndex; index++) vertexToRemap.insert (indexPtr[index]); } else { const uint16 *indexPtr=(const uint16 *)iba.getPtr(); uint32 numIndex=primitiveBlock.getNumIndexes(); for (index=0; index<numIndex; index++) vertexToRemap.insert (indexPtr[index]); } // Remap the vertex std::set<uint>::iterator iteRemap=vertexToRemap.begin(); while (iteRemap!=vertexToRemap.end()) { // Remap the vertex verticesNeedRemap[*iteRemap] = true; // Next vertex iteRemap++; } } } } }