/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer * * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. * You have to aquire licenses for all used proprietary modules. * * This library 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 * OpenSceneGraph Public License for more details. */ #include "PlaceboManipulator.h" using namespace osg; using namespace osgGA; PlaceboManipulator::PlaceboManipulator() { } PlaceboManipulator::~PlaceboManipulator() { } void PlaceboManipulator::init(const GUIEventAdapter& ,GUIActionAdapter& ) { } void PlaceboManipulator::getUsage(osg::ApplicationUsage& usage) const { } bool PlaceboManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv) { osg::observer_ptr< osgViewer::Viewer > viewer = dynamic_cast( &aa ); if( viewer.valid() && ea.getEventType()==osgGA::GUIEventAdapter::FRAME) modelViewMatrix = viewer->getCamera()->getViewMatrix(); else OSG_ALWAYS << "PlaceboManipulator::handle() : Unable to cast osgGA::GUIActionAdapter to osgViewer." << std::endl; return false; } void PlaceboManipulator::setByMatrix(const osg::Matrixd& matrix) { modelViewMatrix = osg::Matrixd::inverse(matrix); } osg::Matrixd PlaceboManipulator::getMatrix() const { return osg::Matrixd::inverse(modelViewMatrix); } osg::Matrixd PlaceboManipulator::getInverseMatrix() const { return modelViewMatrix; }