2001-10-04 23:12:57 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
#ifndef OSG_TRANSFORM
|
|
|
|
#define OSG_TRANSFORM 1
|
|
|
|
|
|
|
|
#include <osg/Group>
|
|
|
|
#include <osg/Matrix>
|
|
|
|
|
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
/** Transform - is group which all children
|
2001-12-29 22:27:46 +08:00
|
|
|
* are transformed by the the Transform's osg::Matrix. Typical uses
|
|
|
|
* of the Transform is for positioning objects within a scene or
|
|
|
|
* producing trackball functionality or for animation.
|
|
|
|
* Note, if the transformation matrix scales the subgraph then the
|
|
|
|
* normals of the underlying geometry will need to be renormalized to
|
|
|
|
* be unit vectors once more. One can done transparently through OpenGL's
|
|
|
|
* use of either GL_NORMALIZE and GL_SCALE_NORMALIZE modes. Further
|
|
|
|
* background reading see the glNormalize documentation in the OpenGL Reference
|
|
|
|
* Guide (the blue book). To enable it in the OSG, you simple need to
|
|
|
|
* attach a local osg::StateSet to the osg::Transform, and set the appropriate
|
|
|
|
* mode to on via stateset->setMode(GL_NORMALIZE,osg::StateAttribute::ON);.
|
2001-09-20 05:19:47 +08:00
|
|
|
*/
|
|
|
|
class SG_EXPORT Transform : public Group
|
|
|
|
{
|
|
|
|
public :
|
|
|
|
Transform();
|
|
|
|
Transform(const Matrix& matix);
|
|
|
|
|
2001-09-22 10:42:08 +08:00
|
|
|
META_Node(Transform);
|
2001-09-20 05:19:47 +08:00
|
|
|
|
2001-10-11 04:20:14 +08:00
|
|
|
/** Range of type that the Transform can be.*/
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
DYNAMIC,
|
|
|
|
STATIC
|
|
|
|
};
|
|
|
|
|
2001-12-29 22:27:46 +08:00
|
|
|
/** Set the Transform Type, which can be DYNAMIC - the Matrix
|
|
|
|
* value is updated during the main loop, or STATIC - the Matrix
|
|
|
|
* is constant throughout the life of the main loop. STATIC
|
2001-10-11 04:20:14 +08:00
|
|
|
* Transforms can be optimized away is some instances, which
|
2001-12-29 22:27:46 +08:00
|
|
|
* can improve performance so unless you plan to modify the
|
|
|
|
* Matrix explicitly set the Matrix to STATIC. The default
|
2001-10-11 04:20:14 +08:00
|
|
|
* value is DYNAMIC.*/
|
|
|
|
inline void setType(Type type) { _type = type; }
|
2001-12-16 00:56:39 +08:00
|
|
|
|
2001-10-11 04:20:14 +08:00
|
|
|
/** Get the Transform Type.*/
|
|
|
|
inline const Type getType() const { return _type; }
|
|
|
|
|
2001-09-20 05:19:47 +08:00
|
|
|
inline const Matrix& getMatrix() const { return *_matrix; }
|
|
|
|
|
2001-11-14 22:09:07 +08:00
|
|
|
inline void setMatrix(const Matrix& mat )
|
|
|
|
{
|
|
|
|
(*_matrix) = mat;
|
|
|
|
dirtyBound();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** preMult trasforms relative to the childrens coordinate system.*/
|
|
|
|
inline void preMult( const Matrix& mat )
|
|
|
|
{
|
|
|
|
(*_matrix) = mat * (*_matrix);
|
|
|
|
dirtyBound();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** postMult trasforms relative to the parents coordinate system.*/
|
|
|
|
inline void postMult( const Matrix& mat )
|
|
|
|
{
|
|
|
|
(*_matrix) = (*_matrix) * mat;
|
|
|
|
dirtyBound();
|
|
|
|
}
|
2001-09-20 05:19:47 +08:00
|
|
|
|
|
|
|
protected :
|
|
|
|
|
|
|
|
virtual ~Transform();
|
|
|
|
|
|
|
|
virtual const bool computeBound() const;
|
|
|
|
|
2001-10-11 04:20:14 +08:00
|
|
|
Type _type;
|
2001-09-20 05:19:47 +08:00
|
|
|
ref_ptr<Matrix> _matrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|