void key(unsigned char key, int x, int y) { switch ( key ) { case 27: osgExit(); exit(0); case 'a': glDisable( GL_LIGHTING ); std::cerr << "Lighting disabled." << std::endl; break; case 's': glEnable( GL_LIGHTING ); std::cerr << "Lighting enabled." << std::endl; break; case 'z': glPolygonMode( GL_FRONT_AND_BACK, GL_POINT); std::cerr << "PolygonMode: Point." << std::endl; break; case 'x': glPolygonMode( GL_FRONT_AND_BACK, GL_LINE); std::cerr << "PolygonMode: Line." << std::endl; break; case 'c': glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); std::cerr << "PolygonMode: Fill." << std::endl; break; case 'r': { std::cerr << "Sending ray through " << x << "," << y << std::endl; Line l; cam->calcViewRay( l, x, y, *vp ); std::cerr << "From " << l.getPosition() << ", dir " << l.getDirection() << std::endl; } break; case 'S': std::cerr << "Saving Image" << std::endl; image->write("test.ppm"); break; } }
void key(unsigned char key, int x, int y) { switch ( key ) { case 27: osgExit(); exit(0); case 'a': glDisable( GL_LIGHTING ); std::cerr << "Lighting disabled." << std::endl; break; case 's': glEnable( GL_LIGHTING ); std::cerr << "Lighting enabled." << std::endl; break; case 'z': glPolygonMode( GL_FRONT_AND_BACK, GL_POINT); std::cerr << "PolygonMode: Point." << std::endl; break; case 'x': glPolygonMode( GL_FRONT_AND_BACK, GL_LINE); std::cerr << "PolygonMode: Line." << std::endl; break; case 'c': glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); std::cerr << "PolygonMode: Fill." << std::endl; break; case 'r': { std::cerr << "Sending ray through " << x << "," << y << std::endl; Line l; cam->calcViewRay( l, x, y, *vp ); std::cerr << "From " << l.getPosition() << ", dir " << l.getDirection() << std::endl; } break; case ' ': { Matrix m; Quaternion q; Vec3f v; q = oldq; v = oldv; oldq = tball.getRotation(); oldv = tball.getPosition(); move_obj = ! move_obj; if ( move_obj ) { puts("moving object"); // m = scene_trans->getSFMatrix()->getValue(); tball.setMode( OSG::Trackball::OSGCamera ); } else { puts("moving camera"); // m = cam_trans->getSFMatrix()->getValue(); tball.setMode( OSG::Trackball::OSGObject ); } // q.setValue(m); tball.setStartPosition( v, true ); tball.setStartRotation( q, true ); // std::cout << q << std::endl; // std::cout << v << std::endl; // std::cout << " " << m[3][0] << " " << m[3][1] << " " << m[3][2] << std::endl; } break; } }