OpenGL



             

31. Milkshape 3D - 8


int materialIndex = m_pMeshes[i].m_materialIndex;

if ( materialIndex >= 0 )

{

glMaterialfv( GL_FRONT, GL_AMBIENT,

m_pMaterials[materialIndex].m_ambient );

glMaterialfv( GL_FRONT, GL_DIFFUSE,

m_pMaterials[materialIndex].m_diffuse );

glMaterialfv( GL_FRONT, GL_SPECULAR,

m_pMaterials[materialIndex].m_specular );

glMaterialfv( GL_FRONT, GL_EMISSION,

m_pMaterials[materialIndex].m_emissive );

glMaterialf( GL_FRONT, GL_SHININESS,

m_pMaterials[materialIndex].m_shininess );

 

if ( m_pMaterials[materialIndex].m_texture > 0 )

{

glBindTexture( GL_TEXTURE_2D,

m_pMaterials[materialIndex].m_texture );

glEnable( GL_TEXTURE_2D );

}

else

glDisable( GL_TEXTURE_2D );

}

else

{

glDisable( GL_TEXTURE_2D );

}

, . , , 0. 0, , . , .

glBegin( GL_TRIANGLES );

{

for ( int j = 0; j < m_pMeshes[i].m_numTriangles; j++ )

{

int triangleIndex = m_pMeshes[i].m_pTriangleIndices[j];

const Triangle* pTri = &m_pTriangles[triangleIndex];