void CBall::Draw(bool bWireFrame) { int nIndex = s_bOffscreenRender ? 1 : 0; if(!dispList_init_flag[nIndex]) { InitDisplayList(); } const dReal* pos = dGeomGetPosition(transBall); const dReal* gpos = dGeomGetPosition(gBall); const dReal* rot = dGeomGetRotation(transBall); position[ 0] = rot[0]; position[ 1] = rot[4]; position[ 2] = rot[8]; position[ 3] = rot[3]; position[ 4] = rot[1]; position[ 5] = rot[5]; position[ 6] = rot[9]; position[ 7] = rot[7]; position[ 8] = rot[2]; position[ 9] = rot[6]; position[10] = rot[10]; position[11] = rot[11]; position[12] = pos[0]; position[13] = pos[1]; position[14] = pos[2]; position[15] = 1; const int log_size = 300; static int max_log = 0; static int current_log = 0; static double pos_log[log_size][16]; if(bWireFrame) { glPushMatrix(); glMultMatrixd(position); glTranslatef(gpos[0], gpos[1], gpos[2]); material.setMaterial(); glCallList(dispList_wire[nIndex]); glPopMatrix(); max_log = current_log = 0; } else { if (!s_bOffscreenRender) { static float dif[4] = {0.75,0.4,0.2,0.0}; static float amb[4] = {0.5,0.2,0.1,0.0}; static float spec[4] = {1.0,1.0,1.0,0.0}; if (bDrawTail) { glDepthMask(0); glEnable(GL_BLEND); glDisable(GL_LIGHTING); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, dif); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, amb); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 300); glBlendFunc(GL_SRC_ALPHA, GL_ONE); for (int i = 0;i < max_log; i++) { int j; if (max_log == log_size) j = (current_log + i) % log_size; else j = i; glColor4f(0.75,0.4,0.2, 0.5*(double)i / log_size); glPushMatrix(); glMultMatrixd(pos_log[j]); glCallList(dispList_polygon[nIndex]); glPopMatrix(); } glDisable(GL_BLEND); glEnable(GL_LIGHTING); glDepthMask(1); for (int i = 0;i < 16; i++) pos_log[current_log][i] = position[i]; current_log++; current_log = current_log % log_size; if (max_log < log_size)max_log++; } else { max_log = 0; current_log = 0; } } glPushMatrix(); glMultMatrixd(position); material.setMaterial(); glTranslatef(gpos[0], gpos[1], gpos[2]); glCallList(dispList_polygon[nIndex]); glPopMatrix(); } glPushMatrix(); glMultMatrixd(position); if(bWireFrame) { matr_blue.setMaterial(); DrawSphere(0.005); } else { } glPopMatrix(); }