|
发表于 2009-12-10 01:30:00
|
显示全部楼层
Re:3ds max 导出插件的一些总结
Point3 CMaxMesh::__get_smgrp_normal(const MaxNormal& max_normal)
{
int vertexId = max_normal.iVertex;
int faceId = max_normal.iFace;
// get the "rendered" vertex
RVertex *pRVertex;
pRVertex = m_pMesh->getRVertPtr(vertexId);
// get the face
Face *pFace;
pFace = &m_pMesh->faces[faceId];
// get the smoothing group of the face
DWORD smGroup;
smGroup = pFace->smGroup;
// get the number of normals
int normalCount;
normalCount = pRVertex->rFlags & NORCT_MASK;
// check if the normal is specified ...
if(pRVertex->rFlags & SPECIFIED_NORMAL)
{
return pRVertex->rn.getNormal();
}
// ... otherwise, check for a smoothing group
else if((normalCount > 0) && (smGroup != 0))
{
// If there is only one vertex is found in the rn member.
if(normalCount == 1)
{
return pRVertex->rn.getNormal();
}
else
{
int normalId;
for(normalId = 0; normalId < normalCount; normalId++)
{
if(pRVertex->ern[normalId].getSmGroup() & smGroup)
{
return pRVertex->ern[normalId].getNormal();
}
}
}
}
// if all fails, return the face normal
return m_pMesh->getFaceNormal(faceId);
} |
|