OpenGL



             

31. Milkshape 3D - 4


 

if ( pHeader->m_version < 3 || pHeader->m_version > 4 )

return false; // " .

// Milkshape3D 1.3 1.4."

pPtr . pPtr . , , MS3D, . MilkshapeModel.cpp . , , .

int nVertices = *( word* )pPtr;

m_numVertices = nVertices;

m_pVertices = new Vertex[nVertices];

pPtr += sizeof( word );

 

int i;

for ( i = 0; i < nVertices; i++ )

{

MS3DVertex *pVertex = ( MS3DVertex* )pPtr;

m_pVertices[i].m_boneID = pVertex->m_boneID;

memcpy( m_pVertices[i].m_location, pVertex->m_vertex, sizeof( float )*3 );

pPtr += sizeof( MS3DVertex );

}

. , , . memcpy . m_boneID - - !

int nTriangles = *( word* )pPtr;

m_numTriangles = nTriangles;

m_pTriangles = new Triangle[nTriangles];

pPtr += sizeof( word );

 

for ( i = 0; i < nTriangles; i++ )

{

MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr;

int vertexIndices[3] = { pTriangle->m_vertexIndices[0],

pTriangle->m_vertexIndices[1], pTriangle->m_vertexIndices[2] };

float t[3] = { 1.0f-pTriangle->m_t[0], 1.0f-pTriangle->m_t[1],