# HG changeset patch # User John Tsiombikas # Date 1399555504 -10800 # Node ID 53ea5b25426eb662077cd0598873f520eb509631 # Parent 4b653386a1543d666a8fe704110eab6ddd195856 progress diff -r 4b653386a154 -r 53ea5b25426e goatview/Makefile --- a/goatview/Makefile Thu May 08 13:55:13 2014 +0300 +++ b/goatview/Makefile Thu May 08 16:25:04 2014 +0300 @@ -10,7 +10,7 @@ goat_root = .. CXXFLAGS = -std=c++11 -pedantic -Wall -g $(pic) -I$(goat_root)/src $(qtinc) -LDFLAGS = $(libgoat) $(libgl) $(qtlib) +LDFLAGS = $(libgoat) $(libgl) $(qtlib) -lvmath MOC = moc qtinc = `pkg-config --cflags Qt5Gui Qt5Core Qt5OpenGL` diff -r 4b653386a154 -r 53ea5b25426e goatview/src/goatview.cc --- a/goatview/src/goatview.cc Thu May 08 13:55:13 2014 +0300 +++ b/goatview/src/goatview.cc Thu May 08 16:25:04 2014 +0300 @@ -1,9 +1,12 @@ +#include #include #include #include #include "goatview.h" #include "goat3d.h" +static void draw_node(goat3d_node *node); + goat3d *scene; QSettings *settings; @@ -151,6 +154,9 @@ void GoatViewport::initializeGL() { glClearColor(0.1, 0.1, 0.1, 1); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); } void GoatViewport::resizeGL(int xsz, int ysz) @@ -161,8 +167,6 @@ gluPerspective(60.0, (float)xsz / (float)ysz, 0.5, 5000.0); } -static void draw_node(goat3d_node *node); - void GoatViewport::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -177,7 +181,9 @@ int node_count = goat3d_get_node_count(scene); for(int i=0; ix(); + prev_y = ev->y(); +} + +void GoatViewport::mouseMoveEvent(QMouseEvent *ev) +{ + int dx = ev->x() - prev_x; + int dy = ev->y() - prev_y; + + if(!dx && !dy) return; + + if(ev->buttons() & Qt::LeftButton) { + cam_theta += dx * 0.5; + cam_phi += dy * 0.5; + + if(cam_phi < -90) cam_phi = -90; + if(cam_phi > 90) cam_phi = 90; + } + if(ev->buttons() & Qt::RightButton) { + cam_dist += dy * 0.1; + + if(cam_dist < 0.0) cam_dist = 0.0; + } + updateGL(); +} diff -r 4b653386a154 -r 53ea5b25426e goatview/src/goatview.h --- a/goatview/src/goatview.h Thu May 08 13:55:13 2014 +0300 +++ b/goatview/src/goatview.h Thu May 08 16:25:04 2014 +0300 @@ -39,6 +39,9 @@ void initializeGL(); void resizeGL(int xsz, int ysz); void paintGL(); + + void mousePressEvent(QMouseEvent *ev); + void mouseMoveEvent(QMouseEvent *ev); }; #endif // GOATVIEW_H_