/* * osgART/ARLocalTransformCallback * osgART: AR ToolKit for OpenSceneGraph * * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved. * * Rev Date Who Changes * 1.0 2006-12-08 --- Version 1.0 release. * */ /* * This file is part of osgART - AR Toolkit for OpenSceneGraph * * Copyright (c) 2005-2007 ARToolworks, Inc. All rights reserved. * * (See the AUTHORS file in the root of this distribution.) * * * OSGART is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * OSGART is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OSGART; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "osgART/ARLocalTransformCallback" #include "osgART/TrackerManager" #include namespace osgART { ARLocalTransformCallback::ARLocalTransformCallback(Marker* baseMarker, Marker* paddleMarker) : osg::NodeCallback(), mBaseMarker(baseMarker), mPaddleMarker(paddleMarker) { }; /* virtual */ void ARLocalTransformCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) { nv->setNodeMaskOverride(0xFFFFFFFF); osg::MatrixTransform* mt = dynamic_cast(node); if (mt && mBaseMarker.valid() && mPaddleMarker.valid()) { osg::Matrix baseMatrix, paddleMatrix; if (mBaseMarker->isValid() && mPaddleMarker->isValid()) { baseMatrix = mBaseMarker->getTransform(); paddleMatrix = mPaddleMarker->getTransform(); baseMatrix.invert(baseMatrix); mt->setMatrix(paddleMatrix * baseMatrix); // Visible mt->setNodeMask(0xFFFFFFFF); } else { // Hidden mt->setNodeMask(0x0); } } else { osg::notify(osg::WARN) << "osgART::ARLocalTransformCallback(): " << "Invalid references to markers" << std::endl; } // must traverse the Node's subgraph traverse(node,nv); } };