本文整理汇总了C++中ogre::MeshPtr::buildEdgeList方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshPtr::buildEdgeList方法的具体用法?C++ MeshPtr::buildEdgeList怎么用?C++ MeshPtr::buildEdgeList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::MeshPtr
的用法示例。
在下文中一共展示了MeshPtr::buildEdgeList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toMesh
Ogre::MeshPtr STLLoader::toMesh(const std::string& name)
{
Ogre::ManualObject* object = new Ogre::ManualObject( "the one and only" );
object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );
unsigned int vertexCount = 0;
V_Triangle::const_iterator it = triangles_.begin();
V_Triangle::const_iterator end = triangles_.end();
for (; it != end; ++it )
{
if( vertexCount >= 2004 )
{
// Subdivide large meshes into submeshes with at most 2004
// vertices to prevent problems on some graphics cards.
object->end();
object->begin( "BaseWhiteNoLighting", Ogre::RenderOperation::OT_TRIANGLE_LIST );
vertexCount = 0;
}
const STLLoader::Triangle& tri = *it;
float u, v;
u = v = 0.0f;
object->position( tri.vertices_[0] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[0], u, v );
object->textureCoord( u, v );
object->position( tri.vertices_[1] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[1], u, v );
object->textureCoord( u, v );
object->position( tri.vertices_[2] );
object->normal( tri.normal_);
calculateUV( tri.vertices_[2], u, v );
object->textureCoord( u, v );
object->triangle( vertexCount + 0, vertexCount + 1, vertexCount + 2 );
vertexCount += 3;
}
object->end();
Ogre::MeshPtr mesh = object->convertToMesh( name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
mesh->buildEdgeList();
delete object;
return mesh;
}
示例2: doExportMesh
//.........这里部分代码省略.........
// Vertex normals
// For the moment, ignore any discrepancies per vertex
msTriangleEx_GetNormal(pTriangleEx, k, &Normal[0]);
msTriangleEx_GetTexCoord(pTriangleEx, k, &uv[0]);
pTex[(vertIdx*2)]=uv[0];
pTex[(vertIdx*2)+1]=uv[1];
pNorm[(vertIdx*3)] = Normal[0];
pNorm[(vertIdx*3)+1] = Normal[1];
pNorm[(vertIdx*3)+2] = Normal[2];
}
} // Faces
nbuf->unlock();
ibuf->unlock();
tbuf->unlock();
// Now use Ogre's ability to reorganise the vertex buffers the best way
Ogre::VertexDeclaration* newDecl =
ogreSubMesh->vertexData->vertexDeclaration->getAutoOrganisedDeclaration(
foundBoneAssignment, false);
Ogre::BufferUsageList bufferUsages;
for (size_t u = 0; u <= newDecl->getMaxSource(); ++u)
bufferUsages.push_back(Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
ogreSubMesh->vertexData->reorganiseBuffers(newDecl, bufferUsages);
logMgr.logMessage("Geometry done.");
} // SubMesh
// Set bounds
ogreMesh->_setBoundingSphereRadius(Ogre::Math::Sqrt(maxSquaredRadius));
ogreMesh->_setBounds(Ogre::AxisAlignedBox(min, max), false);
// Keep hold of a Skeleton pointer for deletion later
// Mesh uses Skeleton pointer for skeleton name
Ogre::SkeletonPtr pSkel;
if (exportSkeleton && foundBoneAssignment)
{
// export skeleton, also update mesh to point to it
pSkel = doExportSkeleton(pModel, ogreMesh);
}
else if (!exportSkeleton && foundBoneAssignment)
{
// We've found bone assignments, but skeleton is not to be exported
// Prompt the user to find the skeleton
if (!locateSkeleton(ogreMesh))
return;
}
// Export
logMgr.logMessage("Creating MeshSerializer..");
Ogre::MeshSerializer serializer;
logMgr.logMessage("MeshSerializer created.");
// Generate LODs if required
if (generateLods)
{
// Build LOD depth list
Ogre::Mesh::LodDistanceList distList;
float depth = 0;
for (unsigned short depthidx = 0; depthidx < numLods; ++depthidx)
{
depth += lodDepthIncrement;
distList.push_back(depth);
}
ogreMesh->generateLodLevels(distList, lodReductionMethod, lodReductionAmount);
}
if (generateEdgeLists)
{
ogreMesh->buildEdgeList();
}
if (generateTangents)
{
unsigned short src, dest;
ogreMesh->suggestTangentVectorBuildParams(tangentSemantic, src, dest);
ogreMesh->buildTangentVectors(tangentSemantic, src, dest, tangentsSplitMirrored, tangentsSplitRotated, tangentsUseParity);
}
// Export
Ogre::String msg;
msg = "Exporting mesh data to file '" + Ogre::String(szFile) + "'";
logMgr.logMessage(msg);
serializer.exportMesh(ogreMesh.getPointer(), szFile);
logMgr.logMessage("Export successful");
Ogre::MeshManager::getSingleton().remove(ogreMesh->getHandle());
if (!pSkel.isNull())
Ogre::SkeletonManager::getSingleton().remove(pSkel->getHandle());
if (exportMaterials && msModel_GetMaterialCount(pModel) > 0)
{
doExportMaterials(pModel);
}
}
示例3: processMesh
//---------------------------------------------------------------------
void OptimiseTool::processMesh(Ogre::MeshPtr mesh)
{
bool rebuildEdgeList = false;
// Shared geometry
if (mesh->sharedVertexData)
{
print("Optimising mesh shared vertex data...");
setTargetVertexData(mesh->sharedVertexData);
for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
{
SubMesh* sm = mesh->getSubMesh(i);
if (sm->useSharedVertices)
{
addIndexData(sm->indexData);
}
}
if (optimiseGeometry())
{
if (mesh->getSkeletonName() != StringUtil::BLANK)
{
print(" fixing bone assignments...");
Mesh::BoneAssignmentIterator currentIt = mesh->getBoneAssignmentIterator();
Mesh::VertexBoneAssignmentList newList =
getAdjustedBoneAssignments(currentIt);
mesh->clearBoneAssignments();
for (Mesh::VertexBoneAssignmentList::iterator bi = newList.begin();
bi != newList.end(); ++bi)
{
mesh->addBoneAssignment(bi->second);
}
}
for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
{
SubMesh* sm = mesh->getSubMesh(i);
if (mesh->getSkeletonName() != StringUtil::BLANK)
{
print(" fixing bone assignments...");
Mesh::BoneAssignmentIterator currentIt = sm->getBoneAssignmentIterator();
Mesh::VertexBoneAssignmentList newList =
getAdjustedBoneAssignments(currentIt);
sm->clearBoneAssignments();
for (Mesh::VertexBoneAssignmentList::iterator bi = newList.begin();
bi != newList.end(); ++bi)
{
sm->addBoneAssignment(bi->second);
}
}
if (sm->useSharedVertices)
{
fixLOD(sm->mLodFaceList);
}
}
rebuildEdgeList = true;
}
}
// Dedicated geometry
for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
{
SubMesh* sm = mesh->getSubMesh(i);
if (!sm->useSharedVertices)
{
print("Optimising submesh " +
StringConverter::toString(i) + " dedicated vertex data ");
setTargetVertexData(sm->vertexData);
addIndexData(sm->indexData);
if (optimiseGeometry())
{
if (mesh->getSkeletonName() != StringUtil::BLANK)
{
print(" fixing bone assignments...");
Mesh::BoneAssignmentIterator currentIt = sm->getBoneAssignmentIterator();
Mesh::VertexBoneAssignmentList newList =
getAdjustedBoneAssignments(currentIt);
sm->clearBoneAssignments();
for (Mesh::VertexBoneAssignmentList::iterator bi = newList.begin();
bi != newList.end(); ++bi)
{
sm->addBoneAssignment(bi->second);
}
}
fixLOD(sm->mLodFaceList);
rebuildEdgeList = true;
}
}
}
if (rebuildEdgeList && mesh->isEdgeListBuilt())
{
// force rebuild of edge list
mesh->freeEdgeList();
//.........这里部分代码省略.........