summaryrefslogtreecommitdiff
path: root/src/GLView.cc
blob: 0c23f974f8d28c05f2ec4580e2b99f673cd70334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "GLView.h"

#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 paintGL(); //
	bool save(const char *filename); //
	//bool save(std::ostream &output); // not implemented in qgl?
	std::string getRendererInfo(); //

	GLint shaderinfo[11];  //

private:
	Renderer *renderer;//
	double w_h_ratio;//

	bool orthomode;//
	bool showaxes;//
	bool showfaces;//
	bool showedges;//

	Eigen::Vector3d object_rot;//
	Eigen::Vector3d camera_eye;//
	Eigen::Vector3d camera_center;//
};

*/
contact: Jan Huwald // Impressum