-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrackballhandler.cpp
More file actions
91 lines (66 loc) · 1.71 KB
/
trackballhandler.cpp
File metadata and controls
91 lines (66 loc) · 1.71 KB
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
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/freeglut.h>
#include <iostream>
#include <cstdlib>
#include <mesh.h>
#include <trackballhandler.h>
#include <program.h>
#include <buffer.h>
#include <glutwrapper.h>
using namespace std;
using namespace glm;
namespace EZGraphics {
/* -------------------------------------- */
TrackballHandler::TrackballHandler ( int argc, char **argv, unsigned int mode, int width, int height ) :
EventHandlerBase(argc,argv,mode,width,height), t(width,height), zoom(3.0f)
{
}
/* -------------------------------------- */
void TrackballHandler::motionWithMiddleButtonDown ( int mx, int my )
{
int dy = my-lasty;
zoom += dy/100.0;
if (zoom<=0.01) zoom = 0.01;
if (zoom>=179) zoom = 179;
lasty = my;
}
/* -------------------------------------- */
void TrackballHandler::motionWithLeftButtonDown ( int mx, int my )
{
t.mouseMove(mx,my);
}
/* -------------------------------------- */
void TrackballHandler::leftMouseButtonDown ( int mx, int my )
{
t.mouseDown(mx,my);
}
/* -------------------------------------- */
void TrackballHandler::leftMouseButtonUp ( int mx, int my )
{
t.mouseUp(mx,my);
}
/* -------------------------------------- */
void TrackballHandler::middleMouseButtonDown ( int mx, int my )
{
lasty = my;
}
/* -------------------------------------- */
void TrackballHandler::resize ( int sizex, int sizey )
{
EventHandlerBase::resize(sizex,sizey);
t.resize(sizex,sizey);
}
/* -------------------------------------- */
glm::mat3 TrackballHandler::getRotation()
{
return t.rotation();
}
/* -------------------------------------- */
float TrackballHandler::getZoom()
{
return zoom;
}
/* -------------------------------------- */
};