AutoTransform
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is 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.
*
* 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.
*/
#ifndef OSG_AUTOTRANSFORM
#define OSG_AUTOTRANSFORM 1
#include <osg/Group>
#include <osg/Transform>
#include <osg/Quat>
#include <osg/Viewport>
namespace osg {
class OSG_EXPORT AutoTransform : public Transform
{
public :
AutoTransform();
AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual osg::Object* cloneType() const { return new AutoTransform (); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AutoTransform (*this,copyop); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const AutoTransform *>(obj)!=NULL; }
virtual const char* className() const { return "AutoTransform"; }
virtual const char* libraryName() const { return "osg"; }
virtual AutoTransform* asAutoTransform() { return this; }
virtual const AutoTransform* asAutoTransform() const { return this; }
inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); }
inline const Vec3d& getPosition() const { return _position; }
inline void setRotation(const Quat& quat) { _rotation = quat; dirtyBound(); }
inline const Quat& getRotation() const { return _rotation; }
inline void setScale(double scale) { setScale(osg::Vec3(scale,scale,scale)); }
void setScale(const Vec3d& scale);
inline const Vec3d& getScale() const { return _scale; }
void setMinimumScale(double minimumScale) { _minimumScale = minimumScale; }
double getMinimumScale() const { return _minimumScale; }
void setMaximumScale(double maximumScale) { _maximumScale = maximumScale; }
double getMaximumScale() const { return _maximumScale; }
inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; dirtyBound(); }
inline const Vec3d& getPivotPoint() const { return _pivotPoint; }
void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
enum AutoRotateMode
{
NO_ROTATION,
ROTATE_TO_SCREEN,
ROTATE_TO_CAMERA,
ROTATE_TO_AXIS
};
void setAutoRotateMode(AutoRotateMode mode);
AutoRotateMode getAutoRotateMode() const { return _autoRotateMode; }
void setAxis(const Vec3& axis);
inline const Vec3& getAxis() const { return _axis; }
void setNormal(const Vec3& normal);
inline const Vec3& getNormal() const { return _normal; }
void setAutoScaleToScreen(bool autoScaleToScreen);
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
void setAutoScaleTransitionWidthRatio(float ratio) { _autoScaleTransitionWidthRatio = ratio; }
float getAutoScaleTransitionWidthRatio() const { return _autoScaleTransitionWidthRatio; }
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
protected :
virtual ~AutoTransform() {}
Vec3d _position;
Vec3d _pivotPoint;
double _autoUpdateEyeMovementTolerance;
AutoRotateMode _autoRotateMode;
bool _autoScaleToScreen;
mutable Quat _rotation;
mutable Vec3d _scale;
double _minimumScale;
double _maximumScale;
double _autoScaleTransitionWidthRatio;
osg::Matrixd computeMatrix(const osg::NodeVisitor* nv) const;
enum AxisAligned
{
AXIAL_ROT_X_AXIS=ROTATE_TO_AXIS+1,
AXIAL_ROT_Y_AXIS,
AXIAL_ROT_Z_AXIS,
CACHE_DIRTY
};
Vec3 _axis;
Vec3 _normal;
// used internally as cache of which what _axis is aligned to help
// decide which method of rotation to use.
int _cachedMode;
Vec3 _side;
void updateCache();
};
}
#endif
Group
Quat
Transform
Viewport
osg::AutoTransform::getAutoScaleToScreen
bool getAutoScaleToScreen() const
Definition AutoTransform:93
osg::AutoTransform::getMinimumScale
double getMinimumScale() const
Definition AutoTransform:56
osg::AutoTransform::_axis
Vec3 _axis
Definition AutoTransform:132
osg::AutoTransform::_rotation
Quat _rotation
Definition AutoTransform:115
osg::AutoTransform::setAutoRotateMode
void setAutoRotateMode(AutoRotateMode mode)
osg::AutoTransform::getAutoScaleTransitionWidthRatio
float getAutoScaleTransitionWidthRatio() const
Definition AutoTransform:96
osg::AutoTransform::updateCache
void updateCache()
osg::AutoTransform::AxisAligned
AxisAligned
Definition AutoTransform:125
osg::AutoTransform::AXIAL_ROT_Y_AXIS
@ AXIAL_ROT_Y_AXIS
Definition AutoTransform:127
osg::AutoTransform::AXIAL_ROT_X_AXIS
@ AXIAL_ROT_X_AXIS
Definition AutoTransform:126
osg::AutoTransform::CACHE_DIRTY
@ CACHE_DIRTY
Definition AutoTransform:129
osg::AutoTransform::AXIAL_ROT_Z_AXIS
@ AXIAL_ROT_Z_AXIS
Definition AutoTransform:128
osg::AutoTransform::_cachedMode
int _cachedMode
Definition AutoTransform:137
osg::AutoTransform::_autoScaleToScreen
bool _autoScaleToScreen
Definition AutoTransform:113
osg::AutoTransform::_maximumScale
double _maximumScale
Definition AutoTransform:119
osg::AutoTransform::getScale
const Vec3d & getScale() const
Definition AutoTransform:53
osg::AutoTransform::setPivotPoint
void setPivotPoint(const Vec3d &pivot)
Definition AutoTransform:61
osg::AutoTransform::_minimumScale
double _minimumScale
Definition AutoTransform:118
osg::AutoTransform::getPosition
const Vec3d & getPosition() const
Definition AutoTransform:44
osg::AutoTransform::_side
Vec3 _side
Definition AutoTransform:138
osg::AutoTransform::getPivotPoint
const Vec3d & getPivotPoint() const
Definition AutoTransform:62
osg::AutoTransform::setAutoScaleToScreen
void setAutoScaleToScreen(bool autoScaleToScreen)
osg::AutoTransform::AutoTransform
AutoTransform()
osg::AutoTransform::~AutoTransform
virtual ~AutoTransform()
Definition AutoTransform:105
osg::AutoTransform::_autoRotateMode
AutoRotateMode _autoRotateMode
Definition AutoTransform:111
osg::AutoTransform::getMaximumScale
double getMaximumScale() const
Definition AutoTransform:59
osg::AutoTransform::getAutoRotateMode
AutoRotateMode getAutoRotateMode() const
Definition AutoTransform:79
osg::AutoTransform::setAxis
void setAxis(const Vec3 &axis)
osg::AutoTransform::_pivotPoint
Vec3d _pivotPoint
Definition AutoTransform:108
osg::AutoTransform::cloneType
virtual osg::Object * cloneType() const
Definition AutoTransform:34
osg::AutoTransform::_normal
Vec3 _normal
Definition AutoTransform:133
osg::AutoTransform::setAutoScaleTransitionWidthRatio
void setAutoScaleTransitionWidthRatio(float ratio)
Definition AutoTransform:95
osg::AutoTransform::AutoRotateMode
AutoRotateMode
Definition AutoTransform:70
osg::AutoTransform::ROTATE_TO_CAMERA
@ ROTATE_TO_CAMERA
Definition AutoTransform:73
osg::AutoTransform::ROTATE_TO_SCREEN
@ ROTATE_TO_SCREEN
Definition AutoTransform:72
osg::AutoTransform::NO_ROTATION
@ NO_ROTATION
Definition AutoTransform:71
osg::AutoTransform::ROTATE_TO_AXIS
@ ROTATE_TO_AXIS
Definition AutoTransform:74
osg::AutoTransform::libraryName
virtual const char * libraryName() const
Definition AutoTransform:38
osg::AutoTransform::_autoScaleTransitionWidthRatio
double _autoScaleTransitionWidthRatio
Definition AutoTransform:120
osg::AutoTransform::getRotation
const Quat & getRotation() const
Definition AutoTransform:48
osg::AutoTransform::computeWorldToLocalMatrix
virtual bool computeWorldToLocalMatrix(Matrix &matrix, NodeVisitor *nv) const
osg::AutoTransform::computeLocalToWorldMatrix
virtual bool computeLocalToWorldMatrix(Matrix &matrix, NodeVisitor *nv) const
osg::AutoTransform::_position
Vec3d _position
Definition AutoTransform:107
osg::AutoTransform::_scale
Vec3d _scale
Definition AutoTransform:116
osg::AutoTransform::className
virtual const char * className() const
Definition AutoTransform:37
osg::AutoTransform::AutoTransform
AutoTransform(const AutoTransform &pat, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::AutoTransform::asAutoTransform
virtual const AutoTransform * asAutoTransform() const
Definition AutoTransform:41
osg::AutoTransform::setScale
void setScale(const Vec3d &scale)
osg::AutoTransform::setMinimumScale
void setMinimumScale(double minimumScale)
Definition AutoTransform:55
osg::AutoTransform::computeMatrix
osg::Matrixd computeMatrix(const osg::NodeVisitor *nv) const
osg::AutoTransform::getAutoUpdateEyeMovementTolerance
float getAutoUpdateEyeMovementTolerance() const
Definition AutoTransform:66
osg::AutoTransform::_autoUpdateEyeMovementTolerance
double _autoUpdateEyeMovementTolerance
Definition AutoTransform:109
osg::AutoTransform::clone
virtual osg::Object * clone(const osg::CopyOp &copyop) const
Definition AutoTransform:35
osg::AutoTransform::getNormal
const Vec3 & getNormal() const
Definition AutoTransform:90
osg::AutoTransform::asAutoTransform
virtual AutoTransform * asAutoTransform()
Definition AutoTransform:40
osg::AutoTransform::setRotation
void setRotation(const Quat &quat)
Definition AutoTransform:47
osg::AutoTransform::setMaximumScale
void setMaximumScale(double maximumScale)
Definition AutoTransform:58
osg::AutoTransform::setPosition
void setPosition(const Vec3d &pos)
Definition AutoTransform:43
osg::AutoTransform::setAutoUpdateEyeMovementTolerance
void setAutoUpdateEyeMovementTolerance(float tolerance)
Definition AutoTransform:65
osg::AutoTransform::setNormal
void setNormal(const Vec3 &normal)
osg::AutoTransform::getAxis
const Vec3 & getAxis() const
Definition AutoTransform:85
osg::AutoTransform::setScale
void setScale(double scale)
Definition AutoTransform:50
osg::AutoTransform::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition AutoTransform:36
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Matrixd
Definition Matrixd:27
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node::dirtyBound
void dirtyBound()
osg::Object
Definition Object:61
osg::Quat
Definition Quat:30
osg::Transform::Transform
Transform()
osg::Vec3d
Definition Vec3d:30
osg
Definition AlphaFunc:19
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::Matrix
Matrixd Matrix
Definition Matrix:27
NULL
#define NULL
Definition osg/Export:55
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39