-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhitTester.cpp
More file actions
executable file
·100 lines (80 loc) · 2.42 KB
/
hitTester.cpp
File metadata and controls
executable file
·100 lines (80 loc) · 2.42 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
92
93
94
95
96
97
98
99
100
/*
* hitTester.cpp
* Proton
*
* Created by Kenrick Kin on 8/12/12.
*
*/
#include <iostream>
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include "Pt/Gesture.h"
#include "Pt/TouchProcessor.h"
#include "Pt/TouchSymbol.h"
#include "Pt/TuioListener.h"
#include "Pt/TransitionTable.h"
#include "Pt/Utils.h"
#include "HitTestAttributeGenerator.h"
#include "LeftRightSplitStreamAttributeGenerator.h"
#include "Scene.h"
double pXLeft = -0.5;
double pYLeft = 0;
double pXRight = 0.5;
double pYRight = 0;
static bool _verbose = true;
static Scene _scene;
void connectCallback(const std::vector<PtTouchSymbols *> &touchStream)
{
if(_verbose)
printf("CONNECT CALLBACK!\n");
_scene.connect();
glutPostRedisplay();
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_scene.draw();
glutSwapBuffers();
}
void idle(void)
{
//glutPostRedisplay();
}
void reshape(GLint width, GLint height)
{
glViewport(0, 0, width, height);
}
int main (int argc, char** argv)
{
glutInit (&argc, argv);
glutInitWindowSize (512, 512);
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow ("HitTester");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
// creating a two-touch regular expression
// the first touch must hit a circle object and the second touch must hit a square object
// the second touch must lift up before the first touch lifts up
PtTouchSymbols regexp;
convertStringToTouchSymbolRegularExpression(std::string("D0:C_(M0:C_)*D1:S_(M0:C_|M1:S_)*U1:S_(M0:C_)*U0:C_"), std::string("_"), regexp);
addTriggerToIthTouchSymbol(®exp, 0, 7);
// creating the two-touch gesture with two callbacks that do nothing
PtGesture *gesture1 = new PtGesture(regexp);
gesture1->setName(std::string("TWO_TOUCH"));
gesture1->addCallback(connectCallback);
clearRegexp(®exp);
// create a PtTouchProcesser with two gesture matchers
PtTouchProcessor touchProcessor;
// first matcher gets gesture1 and gesture2
touchProcessor.addGesture(gesture1);
// assigns a HitTestAttributeGenerator to gesture matchers at indices 0 and 1
touchProcessor.addAttributeGenerator(new HitTestAttributeGenerator(&_scene));
// create TUIO listener on port 3333
PtTuioListener listener(3333, &touchProcessor);
glutMainLoop();
return 0;
}