From 9466244a852d6620edf671a89e1a7188248d5482 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 25 Feb 2010 23:31:04 +0100 Subject: Seperated Application and Pattern classes. --- pattern.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 pattern.cpp (limited to 'pattern.cpp') 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 +#include +#include +#include + +#include +#include + +#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(); +} -- cgit v1.2.3