void myGlutDisplay(void) { ::glClearColor(0.2f, .7f, 0.7f, 1.0f); ::glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); ::glEnable(GL_DEPTH_TEST); ::glEnable(GL_POLYGON_OFFSET_FILL ); ::glPolygonOffset( 1.1f, 4.0f ); ::glMatrixMode(GL_MODELVIEW); ::glLoadIdentity(); Com::View::SetModelViewTransform(cameras); if( is_animation ){ StepTime3(); // solve rigid motion cur_time += dt; // caliculation of kinematic energy double eng = 0; for(unsigned int irb=0;irb<aRB.size();irb++){ double e = aRB[irb].GetKineticEnergy(); e -= Com::Dot(gravity,aRB[irb].GetDispCG())*aRB[irb].GetMass(); eng += e; } std::cout << "cur time " << cur_time << " " << eng << std::endl; } ShowBackGround(); { ::glLineWidth(1); ::glBegin(GL_LINES); ::glColor3d(1,0,0); ::glVertex3d(0,0,0); ::glVertex3d(1,0,0); ::glColor3d(0,1,0); ::glVertex3d(0,0,0); ::glVertex3d(0,1,0); ::glColor3d(0,0,1); ::glVertex3d(0,0,0); ::glVertex3d(0,0,1); ::glEnd(); } for(unsigned int irb=0;irb<aRB.size();irb++){ DrawRigidBody(aRB[irb]); // aRB[irb].Draw(); } for(unsigned int ifix=0;ifix<apFix.size();ifix++){ DrawConstraint(apFix[ifix],aRB); // apFix[ifix]->Draw(aRB); } ShowFPS(); glutSwapBuffers(); }
void myGlutDisplay(void) { // ::glClearColor(0.2, .7, 0.7, 1.0); ::glClearColor(1.0, 1.0, 1.0, 1.0); ::glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); ::glEnable(GL_DEPTH_TEST); ::glEnable(GL_POLYGON_OFFSET_FILL ); ::glPolygonOffset( 1.1f, 4.0f ); ::glMatrixMode(GL_MODELVIEW); ::glLoadIdentity(); Com::View::SetModelViewTransform(camera); ShowBackGround(); ShowFPS(); { ::glDisable(GL_LIGHTING); ::glLineWidth(2); /* std::vector<unsigned int> aIdL = cad_3d.GetAryElemID(Cad::LOOP); for(unsigned int iil=0;iil<aIdL.size();iil++){ unsigned int id_l = aIdL[iil]; const Cad::CLoop3D& l = cad_3d.GetLoop(id_l); const Com::CVector3D& o = l.org; const Com::CVector3D& n = l.normal; double r = 0.1; ::glBegin(GL_LINES); ::glColor3d(1,0,0); ::glVertex3d(o.x,o.y,o.z); ::glVertex3d(o.x+n.x*r,o.y+n.y*r,o.z+n.z*r); ::glEnd(); } */ if( imode == 1 ){ if( cad_3d.IsElemID(Cad::LOOP,id_loop_selected) ){ const Cad::CLoop3D& l = cad_3d.GetLoop(id_loop_selected); const Com::CVector3D& o0 = l.org; const Com::CVector3D& n0 = l.normal; Com::CVector3D x0 = l.dirx; Com::CVector3D y0 = Cross(n0,x0); x0 = Dot(mouse_pos-picked_pos,x0)*x0; y0 = Dot(mouse_pos-picked_pos,y0)*y0; const Com::CVector3D& p = picked_pos; const Com::CVector3D& px = picked_pos+x0; const Com::CVector3D& py = picked_pos+y0; const Com::CVector3D& pxy = picked_pos+x0+y0; ::glLineWidth(1); ::glColor3d(0,0,0); ::glBegin(GL_LINES); ::glVertex3d(p.x,p.y,p.z); ::glVertex3d(px.x,px.y,px.z); ::glVertex3d(p.x,p.y,p.z); ::glVertex3d(py.x,py.y,py.z); ::glVertex3d(pxy.x,pxy.y,pxy.z); ::glVertex3d(px.x,px.y,px.z); ::glVertex3d(pxy.x,pxy.y,pxy.z); ::glVertex3d(py.x,py.y,py.z); ::glEnd(); } /* ::glBegin(GL_POINTS); ::glColor3d(1,0,0); ::glVertex3d(picked_pos.x,picked_pos.y,picked_pos.z); ::glColor3d(1,0,1); ::glVertex3d(mouse_pos.x,mouse_pos.y,mouse_pos.z); ::glEnd(); */ } ::glEnable(GL_LIGHTING); } drawer_ary.Draw(); glutSwapBuffers(); }