summaryrefslogtreecommitdiff
path: root/pattern.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-02-25 23:31:04 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-02-25 23:31:04 +0100
commit9466244a852d6620edf671a89e1a7188248d5482 (patch)
treebe430891aab9d34e0949397100cba8e7e428e621 /pattern.cpp
parent640407faa55a6cc1e071d5a09424c8a6ab4d6507 (diff)
Seperated Application and Pattern classes.
Diffstat (limited to 'pattern.cpp')
-rw-r--r--pattern.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/pattern.cpp b/pattern.cpp
new file mode 100644
index 0000000..87d39f3
--- /dev/null
+++ b/pattern.cpp
@@ -0,0 +1,57 @@
+#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 "texturepng.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;
+ }
+ }
+}
+
+KakePattern::KakePattern() : Pattern("patt.hiro") {
+
+ tex = new TexturePNG("foo.png");
+}
+
+void KakePattern::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();
+}