-
Notifications
You must be signed in to change notification settings - Fork 0
/
スタートとゴール管理(新しい).cpp
171 lines (142 loc) · 3.98 KB
/
スタートとゴール管理(新しい).cpp
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <AR/ar.h>
#include <AR/param.h>
#include <AR/video.h>
#include <AR/gsub.h>
#include "GLMetaseq.h"
const char* vconf_name = "E:/ARToolKit/bin/Data/WDM_camera_flipV.xml";
const char* cparam_name = "E:/ARToolKit/bin/Data/camera_para.dat";
const char* patt_name[] = { "E:/ARToolKit/bin/Data/patt.hiro" ,"E:/ARToolKit/bin/Data/patt.kanji" };//hiro=start穴奈市﹜kanji=end穴奈市
const char* mqo_name[] = { "E:/ARToolKit/bin/Data/ninja.mqo", "E:/ARToolKit/bin/Data/camera.mqo", "E:/ARToolKit/bin/Data/car.mqo" };
int patt_id[2];
double patt_trans[3][4];
double patt_center[2] = { 0.0, 0.0 };
double patt_width = 80.0;
int thresh = 100;
int modenum = 0;
int game_started = 0; // 必奈丞袨杅ㄩ1 必奈丞嶱宎毛桶尨
MQO_MODEL model;
void MainLoop(void);
void DrawObject(int markerIndex);
void MouseEvent(int button, int state, int x, int y);
void KeyEvent(unsigned char key, int x, int y);
void Cleanup(void);
void mySetLight(void);
int main(int argc, char** argv)
{
ARParam cparam;
ARParam wparam;
int xsize, ysize;
glutInit(&argc, argv);
if (arVideoOpen(const_cast<char*>(vconf_name)) < 0) {
printf("申犯左旦玄伉奈丞毛嶱仃引六氏\n");//申犯左旦玄伉奈丞互嶱五卅中
return -1;
}
if (arVideoInqSize(&xsize, &ysize) < 0) {
printf("申犯左扔奶朮毛腕匹五引六氏\n");//申犯左及扔奶朮互日木卅中
return -1;
}
if (arParamLoad(cparam_name, 1, &wparam) < 0) {
printf("市丟仿由仿丟奈正白央奶伙毛掂心煋戶引六氏\n");//市丟仿由仿丟奈正奈白央奶伙毛伕奈玉匹五卅中
return -1;
}
arParamChangeSize(&wparam, xsize, ysize, &cparam);
arInitCparam(&cparam);
if ((patt_id[0] = arLoadPatt(patt_name[0])) < 0) {
printf("HIRO穴奈市奈毛掂心煋戶引六氏\n");//hiro(start)穴奈市毛伕奈玉匹五卅中
return -1;
}
if ((patt_id[1] = arLoadPatt(patt_name[1])) < 0) {
printf("KANJI穴奈市奈毛掂心煋戶引六氏\n");//kanji(end)穴奈市毛伕奈玉匹五卅中
return -1;
}
argInit(&cparam, 1.0, 0, 0, 0, 0);
arVideoCapStart();
argMainLoop(MouseEvent, KeyEvent, MainLoop);
return 0;
}
void MainLoop(void)
{
ARUint8* image;
ARMarkerInfo* marker_info;
int marker_num;
int hiro_index = -1, kanji_index = -1;
// 鳳扜砉芛芞砉
if ((image = arVideoGetImage()) == NULL) {
arUtilSleep(2);
return;
}
// 珆尨扜砉芛芞砉
argDrawMode2D();
argDispImage(image, 0, 0);
// 潰聆梓祩
if (arDetectMarker(image, thresh, &marker_info, &marker_num) < 0) {
Cleanup();
exit(0);
}
// hiro午kanji及穴奈市毛�勾仃引仄凶
for (int i = 0; i < marker_num; i++) {
if (marker_info[i].id == patt_id[0]) {
if (hiro_index == -1 || marker_info[hiro_index].cf < marker_info[i].cf) {
hiro_index = i;
}
}
else if (marker_info[i].id == patt_id[1]) {
if (kanji_index == -1 || marker_info[kanji_index].cf < marker_info[i].cf) {
kanji_index = i;
}
}
}
// 載陔扜砉芛芞砉
arVideoCapNext();
// 蚔牁軀憮
if (hiro_index != -1 && kanji_index == -1) {
//hiro穴奈市分仃互堤今木引仄凶
if (!game_started) {
game_started = 1;
printf("必奈丞嶱宎ㄐ\n");//必奈丞旦正奈玄
}
}
else if (kanji_index != -1 && hiro_index == -1) {
// kanji穴奈市分仃互堤今木引仄凶
if (game_started) {
game_started = 0;
printf("必奈丞皺賸\n");//必奈丞巨件玉
}
}
argSwapBuffers();
}
void DrawObject(void)
{
double gl_para[16];
argDrawMode3D();
argDraw3dCamera(0, 0);
argConvGlpara(patt_trans, gl_para);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(gl_para);
glTranslatef(0.0, 0.0, 20.0);
glColor3f(0.0, 1.0, 0.0);
glLineWidth(3.0);
glutWireCube(40.0);
}
void MouseEvent(int button, int state, int x, int y)
{
printf("穴它旦奶矛件玄: 示正件:%d 袨:%d 釱:(x,y)=(%d,%d)\n", button, state, x, y);
}
void KeyEvent(unsigned char key, int x, int y)
{
if (key == 0x1b) {
Cleanup();
exit(0);
}
}
void Cleanup(void)
{
arVideoCapStop();
arVideoClose();
argCleanup();
}