[403] | 1 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer |
---|
| 2 | * |
---|
| 3 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 7 | * |
---|
| 8 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 9 | * You have to aquire licenses for all used proprietary modules. |
---|
| 10 | * |
---|
| 11 | * This library is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * OpenSceneGraph Public License for more details. |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #include "PlaceboManipulator.h" |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | using namespace osg; |
---|
| 22 | using namespace osgGA; |
---|
| 23 | |
---|
| 24 | PlaceboManipulator::PlaceboManipulator() |
---|
| 25 | { |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | PlaceboManipulator::~PlaceboManipulator() |
---|
| 29 | { |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | void PlaceboManipulator::init(const GUIEventAdapter& ,GUIActionAdapter& ) |
---|
| 33 | { |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | void PlaceboManipulator::getUsage(osg::ApplicationUsage& usage) const |
---|
| 37 | { |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | bool PlaceboManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv) |
---|
| 41 | { |
---|
| 42 | osg::observer_ptr< osgViewer::Viewer > viewer = dynamic_cast<osgViewer::Viewer*>( &aa ); |
---|
| 43 | if( viewer.valid() && ea.getEventType()==osgGA::GUIEventAdapter::FRAME) |
---|
| 44 | modelViewMatrix = viewer->getCamera()->getViewMatrix(); |
---|
| 45 | else |
---|
| 46 | OSG_ALWAYS << "PlaceboManipulator::handle() : Unable to cast osgGA::GUIActionAdapter to osgViewer." << std::endl; |
---|
| 47 | |
---|
| 48 | return false; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void PlaceboManipulator::setByMatrix(const osg::Matrixd& matrix) |
---|
| 52 | { |
---|
| 53 | modelViewMatrix = osg::Matrixd::inverse(matrix); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | osg::Matrixd PlaceboManipulator::getMatrix() const |
---|
| 57 | { |
---|
| 58 | return osg::Matrixd::inverse(modelViewMatrix); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | osg::Matrixd PlaceboManipulator::getInverseMatrix() const |
---|
| 62 | { |
---|
| 63 | return modelViewMatrix; |
---|
| 64 | } |
---|