void achangBirchMedium(bool printBB) { // The following variable must be declared static, so that it doesn't // get reset to NULL every time the function is called, since this is // how we avoid reloading the OBJ file every single time. static GLMmodel* modelObject = NULL; // the model object const char* modelFilename = "birchMedium.obj"; // lives in $TWHOMEDIR/objects if(NULL==modelObject) { modelObject = glmReadOBJ(twPathname(modelFilename,true)); if (!modelObject) { fprintf(stderr,"error reading OBJ file %s\n",modelFilename); return; } glmUnitize(modelObject); // It makes sense to delay printing the BB until after we've // rescaled the object. if(printBB) { GLfloat BoundingBox[6]; // [minx,maxx,miny,maxy,minz,maxz] glmBoundingBox(modelObject,BoundingBox); printf("Bounding Box is (%f,%f,%f,%f,%f,%f)\n", BoundingBox[0], BoundingBox[1], BoundingBox[2], BoundingBox[3], BoundingBox[4], BoundingBox[5]); } // Finish initialization glmFacetNormals(modelObject); glmVertexNormals(modelObject, 90.0); } // Now the actual drawing code, which is always executed glPushMatrix(); glTranslatef(0,1,0); // up to the middle of the object glmDraw(modelObject, GLM_SMOOTH | GLM_MATERIAL); glPopMatrix(); }