From 66619e5251040d4d20e5d6c5c54d96ac8f99edf5 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 17 Jan 2009 12:43:18 +0000 Subject: [PATCH] Remove jitter --- panda/src/grutil/arToolKit.cxx | 21 +++++++++++---------- panda/src/grutil/arToolKit.h | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/panda/src/grutil/arToolKit.cxx b/panda/src/grutil/arToolKit.cxx index c8ffa2ecd3..c31f494acc 100644 --- a/panda/src/grutil/arToolKit.cxx +++ b/panda/src/grutil/arToolKit.cxx @@ -165,6 +165,7 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) { result->_camera_param = new ARParam; result->_threshold = 0.5; result->_marker_size = marker_size; + result->_have_prev_conv = false; memcpy(result->_camera_param, &wparam, sizeof(wparam)); return result; } @@ -404,26 +405,26 @@ analyze(Texture *tex, bool do_flip_texture) { double center[2]; center[0] = 0.0; center[1] = 0.0; - double patt_trans[3][4]; - arGetTransMat(inf, center, _marker_size, patt_trans); + if (_have_prev_conv) { + arGetTransMatCont(inf, _prev_conv, center, _marker_size, _prev_conv); + } else { + arGetTransMat(inf, center, _marker_size, _prev_conv); + } LMatrix4f mat; for (int i=0; i<4; i++) { - mat(i,0) = patt_trans[0][i]; - mat(i,1) = patt_trans[2][i]; - mat(i,2) = -patt_trans[1][i]; + mat(i,0) = _prev_conv[0][i]; + mat(i,1) = _prev_conv[2][i]; + mat(i,2) = -_prev_conv[1][i]; mat(i,3) = 0.0; } mat(3,3) = 1.0; LVecBase3f scale, shear, hpr, pos; decompose_matrix(mat, scale, shear, hpr, pos); - NodePath parent = np.get_parent(); - if (parent.is_empty()) { + if (np.get_parent().is_empty()) { grutil_cat.error() << "NodePath must have a parent.\n"; } else { - np.reparent_to(_camera); - np.set_pos_hpr(pos,hpr); - np.wrt_reparent_to(parent); + np.set_pos_hpr(_camera, pos, hpr); } np.show(); diff --git a/panda/src/grutil/arToolKit.h b/panda/src/grutil/arToolKit.h index 051cca5634..f12b289191 100644 --- a/panda/src/grutil/arToolKit.h +++ b/panda/src/grutil/arToolKit.h @@ -66,6 +66,8 @@ private: void *_camera_param; double _threshold; double _marker_size; + double _prev_conv[3][4]; + bool _have_prev_conv; }; #include "arToolKit.I"