Closed ZhengzhongSun closed 6 years ago
This code is from the solutions section of cyCodeBase: http://www.cemyuksel.com/cyCodeBase/soln/using_hair_files.html You will need to setup OpenGL accordingly before you can use it. I'd recommend rewriting it using modern OpenGL.
I'm following your instruction of your rendering code. void DrawHairModel( const cyHairFile &hairfile, float dirs ) { // Set point array glVertexPointer( 3, GL_FLOAT, 0, hairfile.GetPointsArray() ); glEnableClientState( GL_VERTEX_ARRAY ); // Set normal array glNormalPointer( GL_FLOAT, 0, dirs ); glEnableClientState( GL_NORMAL_ARRAY ); // Set color array (if exists) float colors = hairfile.GetColorsArray(); if ( colors ) { glColorPointer( 3, GL_FLOAT, 0, colors ); glEnableClientState( GL_COLOR_ARRAY ); } // Draw arrays int pointIndex = 0; int hairCount = hairfile.GetHeader().hair_count; const unsigned short *segments = hairfile.GetSegmentsArray(); if ( segments ) { // If segments array exists for ( int hairIndex=0; hairIndex < hairCount; hairIndex++ ) { glDrawArrays( GL_LINE_STRIP, pointIndex, segments[ hairIndex ]+1 ); pointIndex += segments[ hairIndex ]+1; } } else { // If segments array does not exist, use default segment count int dsegs = hairfile.GetHeader().d_segments; for ( int hairIndex=0; hairIndex < hairCount; hairIndex++ ) { glDrawArrays( GL_LINE_STRIP, pointIndex, dsegs+1 ); pointIndex += dsegs+1; } } // Disable arrays glDisableClientState( GL_VERTEX_ARRAY ); glDisableClientState( GL_NORMAL_ARRAY ); glDisableClientState( GL_COLOR_ARRAY ); } I can load the hair data correctly, but I can't see nothing with the rendering codes. Do you have any idea about this?