31 restoreStateFromFile();
34 setKeyDescription(Qt::Key_R,
"Renders the scene with a ray-tracer (low resolution)");
35 setKeyDescription(Qt::SHIFT+Qt::Key_R,
"Renders the scene with a ray-tracer (medium resolution)");
36 setKeyDescription(Qt::CTRL+Qt::Key_R,
"Renders the scene with a ray-tracer (high resolution)");
37 setKeyDescription(Qt::Key_D,
"Augments the max depth of ray-tracing algorithm");
38 setKeyDescription(Qt::SHIFT+Qt::Key_D,
"Decreases the max depth of ray-tracing algorithm");
44 setMouseTracking(
true);
48 ptrScene->init( *
this );
51 camera()->setSceneBoundingBox( qglviewer::Vec( -12, -12, -2 ),qglviewer::Vec( 12, 12, 22 ) );
59 const Qt::KeyboardModifiers modifiers = e->modifiers();
61 if ((e->key()==Qt::Key_R) && ptrScene != 0 )
63 int w = camera()->screenWidth();
64 int h = camera()->screenHeight();
66 qglviewer::Vec orig, dir;
67 camera()->convertClickToLine( QPoint( 0,0 ), orig, dir );
70 camera()->convertClickToLine( QPoint( w,0 ), orig, dir );
72 camera()->convertClickToLine( QPoint( 0, h ), orig, dir );
74 camera()->convertClickToLine( QPoint( w, h ), orig, dir );
76 renderer.setViewBox( origin, dirUL, dirUR, dirLL, dirLR );
77 if ( modifiers == Qt::ShiftModifier ) { w /= 2; h /= 2; }
78 else if ( modifiers == Qt::NoModifier ) { w /= 8; h /= 8; }
80 renderer.setResolution( image.
w(), image.
h() );
81 renderer.
render( image, maxDepth );
82 ofstream output(
"output.ppm" );
87 if (e->key()==Qt::Key_D)
89 if ( modifiers == Qt::ShiftModifier )
90 { maxDepth = std::max( 1, maxDepth - 1 ); handled =
true; }
91 if ( modifiers == Qt::NoModifier )
92 { maxDepth = std::min( 20, maxDepth + 1 ); handled =
true; }
93 std::cout <<
"Max depth is " << maxDepth << std::endl;
96 if (!handled) QGLViewer::keyPressEvent(e);