From f281f316627b163489ecb39d837144142c9353f9 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 8 Apr 2010 15:27:31 +0200 Subject: Added HVector and HMatrix classes. --- assimp.cpp | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'assimp.cpp') diff --git a/assimp.cpp b/assimp.cpp index cccdc0e..e50532d 100755 --- a/assimp.cpp +++ b/assimp.cpp @@ -4,6 +4,8 @@ #include "pattern.h" #include "application.h" +#include "hcoord.h" + #include "texturesdl.h" #include @@ -20,9 +22,11 @@ class FiskPattern : public Pattern { int patt_id2; + HMatrix m1_mat; + bool m2_visible; - double m2_vec[3]; + HVector m2_vec; public: FiskPattern() : Pattern("patterns/m1.patt") { @@ -77,8 +81,6 @@ class FiskPattern : public Pattern { patt_width = 50.0; - patt_trans_kake[3][0] = patt_trans_kake[3][1] = patt_trans_kake[3][2] = 0; - patt_trans_kake[3][3] = 1.0; } protected: @@ -87,7 +89,7 @@ class FiskPattern : public Pattern { 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); + arGetTransMat(&marker_info[j], patt_center, patt_width, m1_mat.m); m1_visible = true; //else if( marker_info[k].cf < marker_info[j].cf ) k = j; } @@ -97,28 +99,13 @@ class FiskPattern : public Pattern { return; } - //patt_trans_kake[0][0] = patt_trans_kake[1][1] = patt_trans_kake[2][2] = 1; - //patt_trans_kake[0][1] = patt_trans_kake[0][2] = 0; - //patt_trans_kake[1][0] = patt_trans_kake[1][2] = 0; - //patt_trans_kake[2][0] = patt_trans_kake[2][1] = 0; - - double m2_matrix[3][4]; + HMatrix m2_mat; for(int j = 0; j < marker_num; j++) { if(patt_id2 == marker_info[j].id) { - arGetTransMat(&marker_info[j], patt_center, patt_width, m2_matrix); + arGetTransMat(&marker_info[j], patt_center, patt_width, m2_mat.m); m2_visible = true; - - double x = m2_matrix[0][3]; - double y = m2_matrix[1][3]; - double z = m2_matrix[2][3]; - - arUtilMatInv(patt_trans_kake, m2_matrix); - - m2_vec[0] = m2_matrix[0][0] * x + m2_matrix[0][1] * y + m2_matrix[0][2] * z + m2_matrix[0][3]; - m2_vec[2] = -(m2_matrix[1][0] * x + m2_matrix[1][1] * y + m2_matrix[1][2] * z + m2_matrix[1][3]); - m2_vec[1] = m2_matrix[2][0] * x + m2_matrix[2][1] * y + m2_matrix[2][2] * z + m2_matrix[2][3]; - + m2_vec = m1_mat.inverse() * m2_mat.getTranslation(); } } @@ -126,14 +113,10 @@ class FiskPattern : public Pattern { } virtual void draw() { - double gl_para[16]; - //arglCameraView(patt_trans_kake, gl_para, 1.0); - glMatrixMode(GL_MODELVIEW); - //glLoadMatrixd(gl_para); - glLoadTransposeMatrixd((double*)patt_trans_kake); + m1_mat.glLoad(); - //glTranslatef(0.0, -8.0, 0.0); + glPushMatrix(); glRotatef(90, 1, 0, 0); @@ -159,6 +142,8 @@ class FiskPattern : public Pattern { } } + glPopMatrix(); + if(m2_visible) { glLineWidth(5); glDisable(GL_TEXTURE_2D); @@ -166,19 +151,19 @@ class FiskPattern : public Pattern { glColor3f(1, 1, 1); glVertex3f(0, 0, 0); - glVertex3f(m2_vec[0], m2_vec[1], m2_vec[2]); + glVertex3f(m2_vec.x, m2_vec.y, m2_vec.z); glColor3f(1, 0, 0); glVertex3f(0, 0, 0); - glVertex3f(m2_vec[0], 0, 0); + glVertex3f(m2_vec.x, 0, 0); glColor3f(0, 1, 0); glVertex3f(0, 0, 0); - glVertex3f(0, m2_vec[1], 0); + glVertex3f(0, m2_vec.y, 0); glColor3f(0, 0, 1); glVertex3f(0, 0, 0); - glVertex3f(0, 0, m2_vec[2]); + glVertex3f(0, 0, m2_vec.z); glEnd(); glEnable(GL_TEXTURE_2D); -- cgit v1.2.3