summaryrefslogtreecommitdiff
path: root/src/GLView.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-02-24 00:50:20 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-02-24 00:50:20 (GMT)
commit0f977609b40d5a6b6b5237060198e6dd97df06c5 (patch)
tree43c93a204f677ceef9c5b02b3ee28643c2acee12 /src/GLView.cc
parent5389107aa684ab99701e238a7297f07b35f7d521 (diff)
put qglview.h into mainwin for deps. unify camera functions into glview.
remove duplicate code.
Diffstat (limited to 'src/GLView.cc')
-rw-r--r--src/GLView.cc71
1 files changed, 63 insertions, 8 deletions
diff --git a/src/GLView.cc b/src/GLView.cc
index 36aa6b3..0c23f97 100644
--- a/src/GLView.cc
+++ b/src/GLView.cc
@@ -1,21 +1,76 @@
#include "GLView.h"
-void GLView::setRenderer(class Renderer* r)
+#include "printutils.h"
+#include <iostream>
+
+GLView::GLView()
+{
+ std::cout << "glview();" << std::endl;
+ this->renderer = NULL;
+}
+
+void GLView::setRenderer(Renderer* r)
{
+ std::cout << "setr " << r << "\n" << std::endl;
this->renderer = r;
}
+void GLView::setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance)
+{
+ PRINT("set gimbal camera not implemented");
+}
+
+void GLView::setupGimbalPerspective()
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-w_h_ratio, +w_h_ratio, -(1/w_h_ratio), +(1/w_h_ratio), +10.0, +FAR_FAR_AWAY);
+ gluLookAt(0.0, -viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
+}
+
+void GLView::setupGimbalOrtho(double distance, bool offset)
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ if(offset)
+ glTranslated(-0.8, -0.8, 0);
+ double l = distance/10;
+ glOrtho(-w_h_ratio*l, +w_h_ratio*l,
+ -(1/w_h_ratio)*l, +(1/w_h_ratio)*l,
+ -FAR_FAR_AWAY, +FAR_FAR_AWAY);
+ gluLookAt(0.0, -viewer_distance, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0);
+}
+
+void GLView::setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &center)
+{
+ this->camera_eye = pos;
+ this->camera_center = center;
+}
+
+void GLView::setupPerspective()
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ double dist = (this->camera_center - this->camera_eye).norm();
+ gluPerspective(45, w_h_ratio, 0.1*dist, 100*dist);
+}
+
+void GLView::setupOrtho(bool offset)
+{
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ if (offset) glTranslated(-0.8, -0.8, 0);
+ double l = (this->camera_center - this->camera_eye).norm() / 10;
+ glOrtho(-w_h_ratio*l, +w_h_ratio*l,
+ -(1/w_h_ratio)*l, +(1/w_h_ratio)*l,
+ -FAR_FAR_AWAY, +FAR_FAR_AWAY);
+}
+
+
/*
void initializeGL(); //
void resizeGL(int w, int h); //
- void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance); //
- void setupGimbalPerspective(); //
- void setupGimbalOrtho(double distance, bool offset=false); //
-
- void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &center); //
- void setupPerspective(); //
- void setupOrtho(bool offset=false); //
void paintGL(); //
bool save(const char *filename); //
contact: Jan Huwald // Impressum