本文整理汇总了C++中TriMesh::faceAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TriMesh::faceAt方法的具体用法?C++ TriMesh::faceAt怎么用?C++ TriMesh::faceAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriMesh
的用法示例。
在下文中一共展示了TriMesh::faceAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepare
void TriBaseSurface::prepare(TangentSpaceMode tangentSpaceMode)
{
if (tangentSpaceMode == TangentSpaceMode_MeshMender)
{
std::vector<MeshMender::Vertex> vertices;
const uint vertexCount = m_mesh->vertexCount();
vertices.resize(vertexCount);
for (uint i = 0; i < vertexCount; i++)
{
const TriMesh::Vertex & vertex = m_mesh->vertexAt(i);
vertices[i].pos = vertex.pos;
vertices[i].normal = vertex.nor;
vertices[i].s = vertex.tex.x();
vertices[i].t = vertex.tex.y();
vertices[i].tangent = Vector3(zero);
vertices[i].binormal = Vector3(zero);
}
std::vector<unsigned int> indices;
const uint faceCount = m_mesh->faceCount();
indices.resize(3 * faceCount);
for (uint i = 0; i < faceCount; i++)
{
const TriMesh::Face & face = m_mesh->faceAt(i);
indices[3 * i + 0] = face.v[0];
indices[3 * i + 1] = face.v[1];
indices[3 * i + 2] = face.v[2];
}
std::vector<unsigned int> xrefs;
// Default options.
float minNormalsCreaseCosAngle = 0.0f;
float minTangentsCreaseCosAngle = 0.0f;
float minBinormalsCreaseCosAngle = 0.0f;
float weightNormalsByArea = 1.0f;
MeshMender::NormalCalcOption computeNormals = MeshMender::CALCULATE_NORMALS;
MeshMender::ExistingSplitOption respectExistingSplits = MeshMender::DONT_RESPECT_SPLITS;
MeshMender::CylindricalFixOption fixCylindricalWrapping = MeshMender::DONT_FIX_CYLINDRICAL;
MeshMender mender;
mender.Mend(vertices, indices, xrefs,
minNormalsCreaseCosAngle,
minTangentsCreaseCosAngle,
minBinormalsCreaseCosAngle,
weightNormalsByArea,
computeNormals,
respectExistingSplits,
fixCylindricalWrapping);
// Create new triMesh.
const uint newFaceCount = indices.size() / 3;
const uint newVertexCount = vertices.size();
TriMesh * triMesh = new TriMesh(newFaceCount, newVertexCount);
triMesh->faces().resize(newFaceCount);
triMesh->vertices().resize(newVertexCount);
m_basisArray.resize(newVertexCount);
for (uint i = 0; i < newVertexCount; i++)
{
TriMesh::Vertex & vertex = triMesh->vertexAt(i);
vertex.pos = vertices[i].pos;
vertex.nor = vertices[i].normal;
vertex.tex = Vector2(vertices[i].s, vertices[i].t);
m_basisArray[i].normal = vertices[i].normal;
m_basisArray[i].tangent = vertices[i].tangent;
m_basisArray[i].bitangent = vertices[i].binormal;
}
for (uint i = 0; i < newFaceCount; i++)
{
TriMesh::Face & face = triMesh->faceAt(i);
face.v[0] = indices[3 * i + 0];
face.v[1] = indices[3 * i + 1];
face.v[2] = indices[3 * i + 2];
}
}
else if (tangentSpaceMode == TangentSpaceMode_Lengyel)
{
if (!MeshNormals::hasNormals(m_mesh.ptr()))
{
MeshNormals::computeNormals(m_mesh.ptr(), WeightFaceArea);
}
geometry::computeMeshTangents(m_mesh.ptr(), m_basisArray);
foreach(i, m_basisArray)
{
Basis & basis = m_basisArray[i];
//.........这里部分代码省略.........