1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
3 * This library is 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.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
13//osgDragger - Copyright (C) 2007 Fugro-Jason B.V.
15#ifndef _OSG_ANTISQUISH_
16#define _OSG_ANTISQUISH_ 1
18#include <osgManipulator/Export>
20#include <osg/Transform>
21#include <OpenThreads/Mutex>
23namespace osgManipulator {
26 * Class that performs the Anti Squish by making the scaling uniform along all axes.
28class OSGMANIPULATOR_EXPORT AntiSquish: public osg::Transform
32 AntiSquish(const osg::Vec3d& pivot);
33 AntiSquish(const osg::Vec3d& pivot, const osg::Vec3d& position);
34 AntiSquish(const AntiSquish& pat, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
36 virtual osg::Object* cloneType() const { return new AntiSquish(); }
38 virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AntiSquish (*this,copyop); }
40 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const AntiSquish *>(obj)!=NULL; }
42 virtual const char* libraryName() const { return "osgManipulator"; }
44 virtual const char* className() const { return "AntiSquish"; }
47 void setPivot(const osg::Vec3d& pvt)
54 const osg::Vec3d& getPivot() const { return _pivot; }
56 void setPosition(const osg::Vec3d& pos)
63 const osg::Vec3d& getPosition() const { return _position; }
65 bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const;
66 bool computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor*) const;
70 virtual ~AntiSquish();
72 bool computeUnSquishedMatrix(osg::Matrix&) const;
80 mutable OpenThreads::Mutex _cacheLock;
81 mutable bool _cacheDirty;
82 mutable osg::Matrix _cacheLocalToWorld;
83 mutable osg::Matrix _cache;