Subversion Repositories gelsvn

Rev

Rev 392 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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