void drawRigidBody( const RigidBody& rb, int npoints, Vec3d* points ){ glColor3f(0.0f,0.0f,0.0f); glPushMatrix(); float glMat[16]; Mat3d rotT; rotT.setT(rb.rotMat); Draw3D::toGLMat( rb.pos, rotT, glMat ); glMultMatrixf( glMat ); if( points ) for(int i=0; i<npoints; i++) Draw3D::drawPointCross(points[i],0.3); glPopMatrix(); glColor3f(1.0f,0.0f,1.0f); Draw3D::drawVecInPos( rb.L, {0.0,0.0,0.0} ); glColor3f(0.0f,0.0f,1.0f); Draw3D::drawVecInPos( rb.omega, {0.0,0.0,0.0} ); if( points ){ for(int i=0; i<npoints; i++){ Vec3d p,v; //rb.rotMat.dot_to_T(points[i], p); //v.set_cross( p, rb.omega ); // omega is in global coordinates rb.velOfPoint( points[i], v, p ); p.add(rb.pos); Draw3D::drawVecInPos ( v, p ); Draw3D::drawPointCross( p, 0.2 ); } }; };
void AeroCraftGUI:: camera (){ glMatrixMode( GL_PROJECTION ); glLoadIdentity(); float fov = VIEW_ZOOM_DEFAULT/zoom; glFrustum( -ASPECT_RATIO, ASPECT_RATIO, -1, 1, 1*fov, VIEW_DEPTH*fov ); Mat3d camMat; Vec3f camPos; convert(world->myCraft->pos, camPos ); float camDist = 10.0; if(first_person){ // third person camera attached to aero-craft camMat.setT( world->myCraft->rotMat ); //glTranslatef ( -camPos.x, -camPos.y, -camPos.z ); }else{ // third person camera attached to aero-craft qCamera.toMatrix( camMat ); camMat.T(); } float glMat[16]; Draw3D::toGLMatCam( { 0.0f, 0.0f, 0.0f}, camMat, glMat ); glMultMatrixf( glMat ); glTranslatef ( -camPos.x+camMat.cx*camDist, -camPos.y+camMat.cy*camDist, -camPos.z+camMat.cz*camDist ); glMatrixMode (GL_MODELVIEW); glLoadIdentity(); }