Game Development Reference
In-Depth Information
The MESH_NORMAL section contains MESH_NUMFACES mini-sec-
tions. Each mini-section contains a MESH_FACENORMAL line and three
MESH_VERTEXNORMAL lines. The face normal defines the normal for
the face and the vertex normals the normals for the face vertices. Each
line follows the familiar pattern of tag, index, vector. When parsing the
function reads the index and applies the data to the normal stored in the
POLYGON and POINT3D structures.
*MESH_NORMALS {
*MESH_FACENORMAL 0 -0.0388 0.1949 0.9800
*MESH_VERTEXNORMAL 0 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 1 -0.0225 0.4185 0.9079
*MESH_VERTEXNORMAL 2 -0.1809 0.3781 0.9079
*MESH_FACENORMAL 1 -0.1104 0.1653 0.9800
*MESH_VERTEXNORMAL 0 0.0000 0.0000 1.0000
*MESH_VERTEXNORMAL 2 -0.1809 0.3781 0.9079
*MESH_VERTEXNORMAL 3 -0.3118 0.2801 0.9079
...
}
BOOL C3DSAscii::ReadNormals(CStdioFile &file, CToon3DObject *obj)
{
CString line, tmp;
int i, j, start, end, index, plyindex;
TOKEN tokens[5];
start = file.GetPosition();
end = GetSectionEnd(file);
//Set default value
for (i=0;i<obj->numpoints;i++){
obj->pts[i].weight = 1;
obj->pts[i].nx = 0.0;
obj->pts[i].ny = 1.0;
obj->pts[i].nz = 0.0;
}
while (file.GetPosition()<(UINT)end){
if (!FindToken(file, line, "MESH_FACENORMAL", -1, end))
return FALSE;
if (ParseTokens(line,tokens,5)<5) return FALSE;
plyindex = atoi(tokens[1].name);
Search Nedrilad ::




Custom Search