Subversion Repositories gelsvn

Rev

Rev 392 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
147 jab 1
#include <fstream>
2
#include "QuatTrackBall.h"
3
 
152 jab 4
namespace GLGraphics
147 jab 5
{
6
 
7
	class GLViewController
8
	{
9
		float FOV_DEG;
10
		float FOV_RAD;
11
		int WINX, WINY;
12
		float znear, zfar;
13
		float aspect;
14
		bool button_down;
15
		TrackBallAction last_action;
16
		bool spin;
17
 
392 jab 18
		QuatTrackBall ball;
147 jab 19
	public:
20
 
21
		GLViewController(int _WINX, int _WINY,
22
										 const CGLA::Vec3f& _centre, float _rad);
23
		void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
24
		void roll_ball(const CGLA::Vec2i& pos);
25
		void release_ball();
26
		bool try_spin();
27
		void reset_projection();
28
		void set_gl_modelview();
29
		void reshape(int W, int H);
30
		void set_near_and_far();
392 jab 31
 
32
		void set_centre(const CGLA::Vec3f& c)
33
		{
34
			ball.set_centre(c);
35
		}
36
 
37
		void set_eye_dist(float rad)
38
		{
39
			ball.set_eye_dist(rad);
40
			set_near_and_far();
41
		}
147 jab 42
 
43
		float get_fovy_rad() const {return FOV_RAD;}
44
 
45
		float get_eye_dist() const
46
		{
392 jab 47
			return ball.get_eye_dist();
147 jab 48
		}
49
 
392 jab 50
		void get_view_param(CGLA::Vec3f& e, CGLA::Vec3f& c, CGLA::Vec3f& u) const
147 jab 51
		{
392 jab 52
			ball.get_view_param(e,c,u);
147 jab 53
		}
54
 
55
		bool load(std::ifstream&);
56
		bool save(std::ofstream&) const;
57
	};
58
 
59
}