本文整理汇总了C++中ogre::SubMesh::_compileBoneAssignments方法的典型用法代码示例。如果您正苦于以下问题:C++ SubMesh::_compileBoneAssignments方法的具体用法?C++ SubMesh::_compileBoneAssignments怎么用?C++ SubMesh::_compileBoneAssignments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SubMesh
的用法示例。
在下文中一共展示了SubMesh::_compileBoneAssignments方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createOgreSubmesh
//.........这里部分代码省略.........
bool use32BitIndexes = false;
if (m_vertices.size() > 65536 || params.useSharedGeom)
{
use32BitIndexes = true;
}
// Create a new index buffer
pSubmesh->indexData->indexBuffer =
Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
use32BitIndexes ? Ogre::HardwareIndexBuffer::IT_32BIT : Ogre::HardwareIndexBuffer::IT_16BIT,
pSubmesh->indexData->indexCount,
Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
// Fill the index buffer with faces data
if (use32BitIndexes)
{
Ogre::uint32* pIdx = static_cast<Ogre::uint32*>(
pSubmesh->indexData->indexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));
for (i=0; i<m_faces.size(); i++)
{
*pIdx++ = static_cast<Ogre::uint32>(m_faces[i].v[0]);
*pIdx++ = static_cast<Ogre::uint32>(m_faces[i].v[1]);
*pIdx++ = static_cast<Ogre::uint32>(m_faces[i].v[2]);
}
pSubmesh->indexData->indexBuffer->unlock();
}
else
{
Ogre::uint16* pIdx = static_cast<Ogre::uint16*>(
pSubmesh->indexData->indexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));
for (i=0; i<m_faces.size(); i++)
{
*pIdx++ = static_cast<Ogre::uint16>(m_faces[i].v[0]);
*pIdx++ = static_cast<Ogre::uint16>(m_faces[i].v[1]);
*pIdx++ = static_cast<Ogre::uint16>(m_faces[i].v[2]);
}
pSubmesh->indexData->indexBuffer->unlock();
}
// Define vertex declaration (only if we're not using shared geometry)
if(!params.useSharedGeom)
{
Ogre::VertexDeclaration* pDecl = pSubmesh->vertexData->vertexDeclaration;
unsigned buf = 0;
size_t offset = 0;
// Add vertex position
pDecl->addElement(buf, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
// Add vertex normal
if (params.exportVertNorm)
{
pDecl->addElement(buf, offset, Ogre::VET_FLOAT3, Ogre::VES_NORMAL);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
}
// Add vertex colour
if(params.exportVertCol)
{
pDecl->addElement(buf, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
offset += Ogre::VertexElement::getTypeSize(Ogre::VET_COLOUR);
}
// Add texture coordinates
for (i=0; i<m_vertices[0].texcoords.size(); i++)
{
Ogre::VertexElementType uvType = Ogre::VertexElement::multiplyTypeCount(Ogre::VET_FLOAT1, 2);
pDecl->addElement(buf, offset, uvType, Ogre::VES_TEXTURE_COORDINATES, static_cast<unsigned short>(i));
offset += Ogre::VertexElement::getTypeSize(uvType);
}
Ogre::VertexDeclaration* pOptimalDecl = pDecl->getAutoOrganisedDeclaration(
params.exportVBA, params.exportBlendShapes || params.exportVertAnims, false);
// Fill the vertex buffer using the newly created vertex declaration
stat = createOgreVertexBuffer(pSubmesh,pDecl,m_vertices);
// Write vertex bone assignements list
if (params.exportVBA)
{
// Create a new vertex bone assignements list
Ogre::SubMesh::VertexBoneAssignmentList vbas;
// Scan list of shared geometry vertices
for (i=0; i<m_vertices.size(); i++)
{
vertex v = m_vertices[i];
// Add all bone assignemnts for every vertex to the bone assignements list
for (j=0; j<v.vbas.size(); j++)
{
Ogre::VertexBoneAssignment vba;
vba.vertexIndex = static_cast<unsigned int>(i);
vba.boneIndex = v.vbas[j].jointIdx;
vba.weight = v.vbas[j].weight;
vbas.insert(Ogre::SubMesh::VertexBoneAssignmentList::value_type(i, vba));
}
}
// Rationalise the bone assignements list
pSubmesh->parent->_rationaliseBoneAssignments(pSubmesh->vertexData->vertexCount,vbas);
// Add bone assignements to the submesh
for (Ogre::SubMesh::VertexBoneAssignmentList::iterator bi = vbas.begin(); bi != vbas.end(); bi++)
{
pSubmesh->addBoneAssignment(bi->second);
}
pSubmesh->_compileBoneAssignments();
}
pSubmesh->vertexData->reorganiseBuffers(pOptimalDecl);
}
return true;
}