//--------------------------------------------------------------------- TangentSpaceCalc::Result TangentSpaceCalc::build( VertexElementSemantic targetSemantic, unsigned short sourceTexCoordSet, unsigned short index) { Result res; // Pull out all the vertex components we'll need populateVertexArray(sourceTexCoordSet); // Now process the faces and calculate / add their contributions processFaces(res); // Now normalise & orthogonalise normaliseVertices(); // Create new final geometry // First extend existing buffers to cope with new vertices extendBuffers(res.vertexSplits); // Alter indexes remapIndexes(res); // Create / identify target & write tangents insertTangents(res, targetSemantic, sourceTexCoordSet, index); return res; }
//--------------------------------------------------------------------- void OptimiseTool::remapIndexDataList() { for (IndexDataList::iterator i = mIndexDataList.begin(); i != mIndexDataList.end(); ++i) { IndexData* idata = *i; remapIndexes(idata); } }
//--------------------------------------------------------------------- void OptimiseTool::fixLOD(SubMesh::LODFaceList lodFaces) { for (SubMesh::LODFaceList::iterator l = lodFaces.begin(); l != lodFaces.end(); ++l) { IndexData* idata = *l; print(" fixing LOD..."); remapIndexes(idata); } }
//--------------------------------------------------------------------- void TangentSpaceCalc::remapIndexes(Result& res) { for (size_t i = 0; i < mIDataList.size(); ++i) { IndexData* idata = mIDataList[i]; // Now do index data // no new buffer required, same size but some triangles remapped if (idata->indexBuffer->getType() == HardwareIndexBuffer::IT_32BIT) { uint32* p32 = static_cast<uint32*>(idata->indexBuffer->lock(HardwareBuffer::HBL_NORMAL)); remapIndexes(p32, i, res); } else { uint16* p16 = static_cast<uint16*>(idata->indexBuffer->lock(HardwareBuffer::HBL_NORMAL)); remapIndexes(p16, i, res); } idata->indexBuffer->unlock(); } }
//--------------------------------------------------------------------- TangentSpaceCalc::Result TangentSpaceCalc::build( VertexElementSemantic targetSemantic, unsigned short sourceTexCoordSet, unsigned short index) { if (index == 0 && targetSemantic == VES_TEXTURE_COORDINATES) { OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Destination texture coordinate set must be greater than 0", "TangentSpaceCalc::build"); } Result res; // Pull out all the vertex components we'll need populateVertexArray(sourceTexCoordSet); // Now process the faces and calculate / add their contributions processFaces(res); // Now normalise & orthogonalise normaliseVertices(); // Create new final geometry // First extend existing buffers to cope with new vertices extendBuffers(res.vertexSplits); // Alter indexes remapIndexes(res); // Create / identify target & write tangents insertTangents(res, targetSemantic, sourceTexCoordSet, index); return res; }