|
|
发表于 2007-4-18 13:41:00
|
显示全部楼层
Re:3dmax官方导出插件(3ds,ASE等)导出的文件中,顶点法线有
自定义的法线导不出来,smooth group的法线可以导出来。
参考nmaxtoolbox,在nebula2/code/contrib/nmax
//-----------------------------------------------------------------------------
/**
Get vertex normal.
*/
Point3 nMaxMesh::GetVertexNormal(Mesh* mesh, int faceNo, RVertex* rv)
{
Face* f = &mesh->faces[faceNo];
DWORD smGroup = f->smGroup;
int numNormals;
Point3 vertexNormal;
// Is normal specified
// SPECIFIED_NORMAL is not currently used, but may be used in future versions.
if (rv->rFlags & SPECIFIED_NORMAL) //*** 看注释 ***
{
vertexNormal = rv->rn.getNormal();
}
// If normal is not specified it's only available if the face belongs
// to a smoothing group
else
if ((numNormals = rv->rFlags & NORCT_MASK) && smGroup)
{
// If there is only one vertex is found in the rn member.
if (numNormals == 1)
{
vertexNormal = rv->rn.getNormal();
}
else
{
// If two or more vertices are there you need to step through them
// and find the vertex with the same smoothing group as the current face.
// You will find multiple normals in the ern member.
for (int i = 0; i < numNormals; i++)
{
if (rv->ern.getSmGroup() & smGroup)
{
vertexNormal = rv->ern.getNormal();
}
}
}
}
else
{
// Get the normal from the Face if no smoothing groups are there
vertexNormal = mesh->getFaceNormal(faceNo);
}
return vertexNormal;
} |
|