# HG changeset patch # User John Tsiombikas # Date 1334368754 -10800 # Node ID f4cc61b5a3eb1e777556b373e549d1b95e74e66f # Parent 63bc059778d0c80adeee8b61e3536ef6ce3dc2af foo diff -r 63bc059778d0 -r f4cc61b5a3eb sdr/volray.p.glsl --- a/sdr/volray.p.glsl Sat Apr 14 01:13:43 2012 +0300 +++ b/sdr/volray.p.glsl Sat Apr 14 04:59:14 2012 +0300 @@ -21,7 +21,7 @@ vec3 sky(Ray ray); vec3 ray_march(Ray ray, float t0, float t1); -vec3 shade(Ray ray, vec3 pos, vec3 norm); +vec3 shade(Ray ray, vec3 pos, vec3 norm, vec3 ldir); Ray get_primary_ray(); ISect intersect_aabb(Ray ray, AABBox aabb); ISect intersect_sphere(Ray ray, float rad); @@ -78,6 +78,7 @@ float energy = 1.0; float t = t0; vec3 col = vec3(0.0, 0.0, 0.0); + const vec3 ldir = normalize(vec3(-1, 1, -4)); while(t < t1) { @@ -90,7 +91,7 @@ float energy_drop = exp(val * -ray_step); // * scatter_coeff ? energy *= energy_drop; - vec3 irrad = shade(ray, pos, normalize(norm)); + vec3 irrad = shade(ray, pos, normalize(norm), ldir); col += (1.0 - energy_drop) * energy * irrad; if(energy < 0.001) { @@ -101,11 +102,10 @@ return col; } -vec3 shade(Ray ray, vec3 pos, vec3 norm) +vec3 shade(Ray ray, vec3 pos, vec3 norm, vec3 ldir) { - vec3 ldir = -normalize(ray.dir); - vec3 vdir = ldir; - vec3 hdir = ldir;//normalize(ldir + vdir); + vec3 vdir = -normalize(ray.dir); + vec3 hdir = normalize(ldir + vdir); float ndotl = abs(dot(ldir, norm)); float ndoth = abs(dot(hdir, norm)); diff -r 63bc059778d0 -r f4cc61b5a3eb src/ui.cc --- a/src/ui.cc Sat Apr 14 01:13:43 2012 +0300 +++ b/src/ui.cc Sat Apr 14 04:59:14 2012 +0300 @@ -1,18 +1,22 @@ #include #include +#include #include #include "ui.h" -static GLView *glview; static Volume *volume; +static GLView *maingl; +static std::vector glviews; + MainWindow::MainWindow() { setWindowTitle("Volume Renderer"); // OpenGL view - glview = new GLView; - setCentralWidget(glview); + maingl = new GLView; + glviews.push_back(maingl); + setCentralWidget(maingl); // side-window sidewin = new SideWindow; @@ -64,6 +68,9 @@ { QGroupBox *groupbox = new QGroupBox("Volume slice"); { + GLView *slice_view = new GLView; + glviews.push_back(slice_view); + QCheckBox *chk_clip = new QCheckBox("clip"); chk_clip->setChecked(false); connect(chk_clip, SIGNAL(stateChanged(int)), this, SLOT(clip_change(int))); @@ -74,6 +81,7 @@ connect(zslider, SIGNAL(valueChanged(int)), this, SLOT(zslider_change(int))); QVBoxLayout *vbox = new QVBoxLayout; + vbox->addWidget(slice_view); vbox->addWidget(chk_clip); vbox->addWidget(zslider); @@ -102,7 +110,7 @@ void post_redisplay() { - glview->updateGL(); + maingl->updateGL(); } diff -r 63bc059778d0 -r f4cc61b5a3eb src/ui.h --- a/src/ui.h Sat Apr 14 01:13:43 2012 +0300 +++ b/src/ui.h Sat Apr 14 04:59:14 2012 +0300 @@ -3,15 +3,16 @@ #include #include -#include #include "volray.h" -class GLView; class SideWindow; +// This is the main application window (duh) class MainWindow : public QMainWindow { +private: Q_OBJECT -private: + + MainGLView *maingl; SideWindow *sidewin; private slots: @@ -21,8 +22,15 @@ MainWindow(); }; +/* This is the detachable window with the volume slice view + * transfer function, etc + */ class SideWindow : public QDockWidget { +private: Q_OBJECT + + SliceGLView *slice_view; + private slots: void zslider_change(int val); void clip_change(int checked); @@ -31,25 +39,7 @@ SideWindow(); }; -class GLView : public QGLWidget { - Q_OBJECT - -protected: - void initializeGL(); - void resizeGL(int xsz, int ysz); - void paintGL(); - - void mousePressEvent(QMouseEvent *ev); - void mouseReleaseEvent(QMouseEvent *ev); - void mouseMoveEvent(QMouseEvent *ev); - -public: - GLView(QWidget *parent = 0); - - QSize minimumSizeHint() const; - QSize sizeHint() const; -}; - +// call to force a redisplay on all GL views void post_redisplay(); diff -r 63bc059778d0 -r f4cc61b5a3eb src/ui_maingl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui_maingl.h Sat Apr 14 04:59:14 2012 +0300 @@ -0,0 +1,20 @@ +#include + +class MainGLView : public QGLWidget { + Q_OBJECT + +protected: + void initializeGL(); + void resizeGL(int xsz, int ysz); + void paintGL(); + + void mousePressEvent(QMouseEvent *ev); + void mouseReleaseEvent(QMouseEvent *ev); + void mouseMoveEvent(QMouseEvent *ev); + +public: + MainGLView(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; +};