root/OpenSceneGraph/trunk/include/osgManipulator/AntiSquish @ 13041

Revision 13041, 2.4 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
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.
7 *
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.
12*/
13//osgDragger - Copyright (C) 2007 Fugro-Jason B.V.
14
15#ifndef _OSG_ANTISQUISH_
16#define _OSG_ANTISQUISH_ 1
17
18#include <osgManipulator/Export>
19
20#include <osg/Matrix>
21#include <osg/CopyOp>
22#include <osg/NodeVisitor>
23#include <osg/NodeCallback>
24#include <osg/MatrixTransform>
25#include <osg/Quat>
26#include <osg/Vec3>
27
28namespace osgManipulator {
29
30/**
31 * Class that performs the Anti Squish by making the scaling uniform along all axes.
32 */
33class OSGMANIPULATOR_EXPORT AntiSquish: public osg::MatrixTransform
34{
35    public :
36        AntiSquish();
37        AntiSquish(const osg::Vec3d& pivot);
38        AntiSquish(const osg::Vec3d& pivot, const osg::Vec3d& position);
39        AntiSquish(const AntiSquish& pat, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
40
41        virtual osg::Object* cloneType() const { return new AntiSquish(); }
42
43        virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AntiSquish (*this,copyop); }
44
45        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const AntiSquish *>(obj)!=NULL; }
46
47        void setPivot(const osg::Vec3d& pvt)
48        {
49            _pivot = pvt;
50            _usePivot = true;
51            _dirty = true;
52        }
53
54        const osg::Vec3d& getPivot() const { return _pivot; }
55
56        void setPosition(const osg::Vec3d& pos)
57        {
58            _position = pos;
59            _usePosition = true;
60            _dirty = true;
61        }
62
63        const osg::Vec3d& getPosition() const { return _position; }
64
65        virtual ~AntiSquish();
66
67        osg::Matrix computeUnSquishedMatrix(const osg::Matrix&, bool& flag);
68
69    protected:
70
71        osg::NodeCallback* _asqCallback;
72
73        osg::Vec3d _pivot;
74        bool _usePivot;
75
76        osg::Vec3d _position;
77        bool _usePosition;
78
79        bool _dirty;
80        osg::Matrix _cachedLocalToWorld;
81};
82
83}
84#endif
Note: See TracBrowser for help on using the browser.