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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#pragma once
#include <set>
#include "ofMain.h"
#include "tesselator.h"
#include "ofxOpenCv.h"
#include "ofxRay.h"
#include "ofxXmlSettings.h"
#include "ofxBlobsManager.h"
#include "trapdoor.h"
#include "bird.h"
#include "player.h"
#include "outsidePolygon.h"
//#define _USE_LIVE_VIDEO // uncomment this to use a live camera
// otherwise, we'll use a movie file
#define PLAY 0
#define CALIBRATE 1
#define TITLES 0
#define CREDIT 1
#define EXPLAIN 2
#define PLAYING 3
#define GOTCHA 4
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
int windowWidth, windowHeight;
int mode;
//utility functions
ofVec2f screen2plane(ofVec2f screenpos);
ofVec3f plane2world(ofVec2f planepos);
void updatePlane();
bool rectsCross(ofRectangle rect1,ofRectangle rect2);
ofxXmlSettings XML;
void loadSettings(string filename);
void saveSettings(string filename);
bool useCamera;
bool hasCamera;
ofVideoGrabber vidGrabber;
ofVideoPlayer vidPlayer;
ofxCvColorImage colorImg;
ofxCvFloatImage accumImg;
ofxCvGrayscaleImage bgImg;
ofxCvGrayscaleImage grayImage;
ofxCvGrayscaleImage grayBg;
ofxCvGrayscaleImage grayDiff;
ofxCvContourFinder contourFinder;
ofxBlobsManager blobsManager;
int threshold;
bool bLearnBakground;
float cam_angle;
ofCamera cam;
ofRay ray;
ofPlane plane;
ofProjector projector;
ofVec2f pos;
//vector<ofVec3f> players;
trapdoor trapDoor;
ofMesh ground;
vector<ofPolyline> groundlines;
ofTessellator tess;
void tessGround(int doornum);
void makeGround(int doornum);
vector<trapdoor> trapdoors;
float trapdoorSize;
float trapdoorSlotSize;
int numtrapdoorSlots;
int trapdoorCounter;
float trapdoorTime; //time per trap door
float trapdoorTimer;
ofSoundPlayer* doorsounds;
ofVec3f* testpts;
bird Bird;
map<int,player> players;
bool drawStats;
bool firstframe; //for background removal
float bgnum;
ofLight light;
ofPlane* bounds;
vector<ofPoint> border;
bool drawingborder;
ofSoundPlayer* sounds;
ofImage* billboards;
ofVec2f scaleFactor;
int gameState;
float gameStart;
float segTimes[5];
};
|