Posted on 2009-03-19 01:47
Husman 阅读(1465)
评论(0) 编辑 收藏 引用
渲染到视口的Mesh是LOD版本。LOD版本的Mesh三角形个数受视距的影响,三角形个数要少一些。
怎样得到LOD版本的三角形个数呢?
下面给出一段代码
RenderOperation ro;
size_t faceCount;
size_t val = 0;
for (unsigned int
i = 0; i < pEntity->getNumSubEntities(); ++i)
{
SubEntity* subEntity = pEntity->getSubEntity(i);
subEntity->getRenderOperation(ro);
if (ro.useIndexes)
{
val += ro.indexData->indexCount;
}
else
{
val += ro.vertexData->vertexCount;
}
}
faceCount
= val/3;
下面再给出实际的三角形个数的代码:
size_t faceCount;
size_t val = 0;
for (unsigned int i = 0; i < pEntity->getNumSubEntities(); ++i)
{
SubEntity* subEntity = pEntity->getSubEntity(i);
SubMesh* subMesh = subEntity->getSubMesh();
if (subMesh.useSharedVertices)
{
val += subMesh.indexData->indexCount;
}
else
{
val += subMesh.vertexData->vertexCount;
}
}
faceCount
= val/3;