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
|
#include "pattern.h"
#include <AR/gsub_lite.h>
#include <AR/video.h>
#include <AR/param.h>
#include <AR/ar.h>
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
#include "texturesdl.h"
Pattern::Pattern(std::string filename) {
patt_width = 25.0;
patt_center[0] = 0.0;
patt_center[1] = 0.0;
patt_id = arLoadPatt(filename.c_str());
}
void Pattern::update(ARMarkerInfo* marker_info, int marker_num) {
for(int j = 0; j < marker_num; j++) {
if( patt_id == marker_info[j].id ) {
arGetTransMat(&marker_info[j], patt_center, patt_width, patt_trans_kake);
draw();
//else if( marker_info[k].cf < marker_info[j].cf ) k = j;
}
}
}
SpritePattern::SpritePattern(Texture* _tex) : Pattern("patt.jon") {
tex = _tex;
}
void SpritePattern::draw() {
double gl_para[16];
arglCameraView(patt_trans_kake, gl_para, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(gl_para);
//glTranslatef(0.0, -8.0, 0.0);
glBindTexture(GL_TEXTURE_2D, tex->tex());
glBegin(GL_QUADS);
glTexCoord2f(0, 1);
glVertex3f(-30, -30, 0);
glTexCoord2f(0, 0);
glVertex3f(-30, 30, 0);
glTexCoord2f(1, 0);
glVertex3f(30, 30, 0);
glTexCoord2f(1, 1);
glVertex3f(30, -30, 0);
glEnd();
}
KakePattern::KakePattern() : SpritePattern(new TextureSDL("foo.png")) {
}
|