Subversion Repositories gelsvn

Rev

Rev 299 | Rev 594 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 299 Rev 392
Line 15... Line 15...
15
    QuatTrackBall::QuatTrackBall(const Vec3f& _centre, 
15
    QuatTrackBall::QuatTrackBall(const Vec3f& _centre, 
16
			 float _eye_dist,
16
			 float _eye_dist,
17
			 unsigned _width, 
17
			 unsigned _width, 
18
			 unsigned _height):
18
			 unsigned _height):
19
	centre(_centre), width(_width), height(_height), 
19
	centre(_centre), width(_width), height(_height), 
20
	scale(0.5*_eye_dist), eye_dist(_eye_dist)
20
	eye_dist(_eye_dist)
21
	{
21
	{
22
	// This size should really be based on the distance from the center of
22
	// This size should really be based on the distance from the center of
23
	// rotation to the point on the object underneath the mouse.  That
23
	// rotation to the point on the object underneath the mouse.  That
24
	// point would then track the mouse as closely as possible.  This is a
24
	// point would then track the mouse as closely as possible.  This is a
25
	// simple example, though, so that is left as an exercise.
25
	// simple example, though, so that is left as an exercise.
Line 93... Line 93...
93
	do_spin();	
93
	do_spin();	
94
    }
94
    }
95
    
95
    
96
    void QuatTrackBall::pan(const Vec2f& new_v) 
96
    void QuatTrackBall::pan(const Vec2f& new_v) 
97
    {
97
    {
98
	trans += (new_v - last_pos) * Vec2f(scale[0], scale[1]);
98
	trans += (new_v - last_pos) * Vec2f(eye_dist);
99
    }
99
    }
100
    
100
    
101
    void QuatTrackBall::zoom(const Vec2f& new_v) 
101
    void QuatTrackBall::zoom(const Vec2f& new_v) 
102
    {
102
    {
103
	eye_dist += (new_v[1] - last_pos[1]) * scale[2];
103
	eye_dist += (new_v[1] - last_pos[1]) * eye_dist;
104
	eye_dist = max(eye_dist, 0.01f);
104
	eye_dist = max(eye_dist, 0.01f);
105
    }
105
    }
106
    
106
    
107
    void QuatTrackBall::calcRotation(const Vec2f& new_pos) 
107
    void QuatTrackBall::calcRotation(const Vec2f& new_pos) 
108
    {
108
    {