本文整理汇总了C++中ogre::MeshPtr::getBoneAssignments方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::getBoneAssignments方法的具体用法?C++ MeshPtr::getBoneAssignments怎么用?C++ MeshPtr::getBoneAssignments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::getBoneAssignments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unshareVertices
//-----------------------------------------------------------------------
void InstanceManager::unshareVertices(const Ogre::MeshPtr &mesh)
{
// Retrieve data to copy bone assignments
const Mesh::VertexBoneAssignmentList& boneAssignments = mesh->getBoneAssignments();
Mesh::VertexBoneAssignmentList::const_iterator it = boneAssignments.begin();
Mesh::VertexBoneAssignmentList::const_iterator end = boneAssignments.end();
size_t curVertexOffset = 0;
// Access shared vertices
VertexData* sharedVertexData = mesh->sharedVertexData;
for (size_t subMeshIdx = 0; subMeshIdx < mesh->getNumSubMeshes(); subMeshIdx++)
{
SubMesh *subMesh = mesh->getSubMesh(subMeshIdx);
IndexData *indexData = subMesh->indexData;
HardwareIndexBuffer::IndexType idxType = indexData->indexBuffer->getType();
IndicesMap indicesMap = (idxType == HardwareIndexBuffer::IT_16BIT) ? getUsedIndices<uint16>(indexData) :
getUsedIndices<uint32>(indexData);
VertexData *newVertexData = new VertexData();
newVertexData->vertexCount = indicesMap.size();
newVertexData->vertexDeclaration = sharedVertexData->vertexDeclaration->clone();
for (size_t bufIdx = 0; bufIdx < sharedVertexData->vertexBufferBinding->getBufferCount(); bufIdx++)
{
HardwareVertexBufferSharedPtr sharedVertexBuffer = sharedVertexData->vertexBufferBinding->getBuffer(bufIdx);
size_t vertexSize = sharedVertexBuffer->getVertexSize();
HardwareVertexBufferSharedPtr newVertexBuffer = HardwareBufferManager::getSingleton().createVertexBuffer
(vertexSize, newVertexData->vertexCount, sharedVertexBuffer->getUsage(), sharedVertexBuffer->hasShadowBuffer());
uint8 *oldLock = (uint8*)sharedVertexBuffer->lock(0, sharedVertexData->vertexCount * vertexSize, HardwareBuffer::HBL_READ_ONLY);
uint8 *newLock = (uint8*)newVertexBuffer->lock(0, newVertexData->vertexCount * vertexSize, HardwareBuffer::HBL_NORMAL);
IndicesMap::iterator indIt = indicesMap.begin();
IndicesMap::iterator endIndIt = indicesMap.end();
for (; indIt != endIndIt; ++indIt)
{
memcpy(newLock + vertexSize * indIt->second, oldLock + vertexSize * indIt->first, vertexSize);
}
sharedVertexBuffer->unlock();
newVertexBuffer->unlock();
newVertexData->vertexBufferBinding->setBinding(bufIdx, newVertexBuffer);
}
if (idxType == HardwareIndexBuffer::IT_16BIT)
{
copyIndexBuffer<uint16>(indexData, indicesMap);
}
else
{
copyIndexBuffer<uint32>(indexData, indicesMap);
}
// Store new attributes
subMesh->useSharedVertices = false;
subMesh->vertexData = newVertexData;
// Transfer bone assignments to the submesh
size_t offset = curVertexOffset + newVertexData->vertexCount;
for (; it != end; ++it)
{
size_t vertexIdx = (*it).first;
if (vertexIdx > offset)
break;
VertexBoneAssignment boneAssignment = (*it).second;
boneAssignment.vertexIndex = static_cast<unsigned int>(boneAssignment.vertexIndex - curVertexOffset);
subMesh->addBoneAssignment(boneAssignment);
}
curVertexOffset = newVertexData->vertexCount + 1;
}
// Release shared vertex data
delete mesh->sharedVertexData;
mesh->sharedVertexData = NULL;
mesh->clearBoneAssignments();
}