本文整理汇总了C++中poly::NrFaces方法的典型用法代码示例。如果您正苦于以下问题:C++ poly::NrFaces方法的具体用法?C++ poly::NrFaces怎么用?C++ poly::NrFaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poly
的用法示例。
在下文中一共展示了poly::NrFaces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void MeshData::GenerateNormals(
const bool& InvertNormals)
{
// Sources
const AttribData<vec3> & Vertices = m_VertexArray;
const AttribData<poly> & Faces = m_Polygons;
vec3* pNormals = new vec3[Vertices.Size()];
memset(pNormals, 0, Vertices.Size() * sizeof(vec3));
// Go through the polylists
const uint NrPolyLists = Faces.Size();
for(uint p=0; p<NrPolyLists; p++) {
const poly Polylist = Faces.GetElem(p);
const uint NrFaces = Polylist.NrFaces();
for(uint f=0; f<NrFaces; f++)
{
// Get vertices
const uint i1 = Polylist.GetFaces().GetElem(f).v1;
const uint i2 = Polylist.GetFaces().GetElem(f).v2;
const uint i3 = Polylist.GetFaces().GetElem(f).v3;
const vec3 v1 = Vertices.GetElem(i1);
const vec3 v2 = Vertices.GetElem(i2);
const vec3 v3 = Vertices.GetElem(i3);
// Get edges
const vec3 edge1 = v2-v1; const vec3 edge2 = v3-v1;
// Set Crossproduct
vec3 facenormal;
if(InvertNormals) {
facenormal=normalize(glm::cross(edge1, edge2));
facenormal = facenormal * -1.0f;
} else
facenormal=normalize(glm::cross(edge1, edge2));
// Add vertexnormals
pNormals[i1]+=facenormal;
pNormals[i2]+=facenormal;
pNormals[i3]+=facenormal;
}
}
// Normalize
vec3* pN = pNormals;
for(uint n=0; n<Vertices.Size(); n++, pN++)
*pN = normalize(*pN);
MeshData::SetNormalArray().Load(pNormals, Vertices.Size());
delete [] pNormals;
}