006
18.08.2007, 22:51 Uhr
mmc20
puss in boots
|
naja, das lighting is on
C++: |
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[]= { 0.0f, 0.0f, 2.0f, 1.0f };
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1);
|
und GL_TEXTURES_2D wird in der draw() der modelclass gesetzt
C++: |
void ModelMS3D::draw() { GLboolean texEnabled = glIsEnabled( GL_TEXTURE_2D );
// Draw by group for ( int i = 0; i < m_numMeshes; i++ ) { 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 { // Material properties? glDisable( GL_TEXTURE_2D ); }
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];
for ( int k = 0; k < 3; k++ ) { int index = pTri->m_vertexIndices[k]; glNormal3fv( pTri->m_vertexNormals[k] ); glTexCoord2f( pTri->m_s[k], pTri->m_t[k] ); glVertex3fv( m_pVertices[index].m_location ); } } } glEnd(); }
if ( texEnabled ) glEnable( GL_TEXTURE_2D ); else glDisable( GL_TEXTURE_2D ); }
|
|