Subversion Repositories gelsvn

Rev

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

Rev 87 Rev 119
1
#include <fstream>
1
#include <fstream>
2
#include "QuatTrackBall.h"
2
#include "QuatTrackBall.h"
3
 
3
 
4
namespace Graphics
4
namespace Graphics
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
		CGLA::Vec3f centre;
14
		CGLA::Vec3f centre;
15
		float rad;
15
		float rad;
16
		bool button_down;
16
		bool button_down;
17
		TrackBallAction last_action;
17
		TrackBallAction last_action;
18
		CGLA::Vec2i old_pos;
18
		CGLA::Vec2i old_pos;
19
		bool spin;
19
		bool spin;
20
 
20
 
21
		QuatTrackBall *ball;
21
		QuatTrackBall *ball;
22
	public:
22
	public:
23
 
23
 
24
		GLViewController(int _WINX, int _WINY,
24
		GLViewController(int _WINX, int _WINY,
25
										 const CGLA::Vec3f& _centre, float _rad);
25
										 const CGLA::Vec3f& _centre, float _rad);
26
		void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
26
		void grab_ball(TrackBallAction action, const CGLA::Vec2i& pos);
27
		void roll_ball(const CGLA::Vec2i& pos);
27
		void roll_ball(const CGLA::Vec2i& pos);
28
		void release_ball();
28
		void release_ball();
29
		bool try_spin();
29
		bool try_spin();
30
		void reset_projection();
30
		void reset_projection();
31
		void set_gl_modelview();
31
		void set_gl_modelview();
32
		void reshape(int W, int H);
32
		void reshape(int W, int H);
33
		void set_near_and_far();
33
		void set_near_and_far();
34
 
34
 
35
		float get_fovy_rad() const {return FOV_RAD;}
35
		float get_fovy_rad() const {return FOV_RAD;}
36
 
36
 
37
		float get_eye_dist() const
37
		float get_eye_dist() const
38
		{
38
		{
39
			return ball->get_eye_dist();
39
			return ball->get_eye_dist();
40
		}
40
		}
41
 
41
 
42
		void get_view_param(CGLA::Vec3f& e, 
42
		void get_view_param(CGLA::Vec3f& e, 
43
												CGLA::Vec3f& c, CGLA::Vec3f& u) const
43
												CGLA::Vec3f& c, CGLA::Vec3f& u) const
44
		{
44
		{
45
			ball->get_view_param(e,c,u);
45
			ball->get_view_param(e,c,u);
46
		}
46
		}
47
 
47
 
48
		bool load(std::ifstream&);
48
		bool load(std::ifstream&);
49
		bool save(std::ofstream&) const;
49
		bool save(std::ofstream&) const;
50
	};
50
	};
51
	
51
	
52
}
52
}
53
namespace GFX = Graphics;
53
namespace GFX = Graphics;
54
 
54