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.
14#ifndef OSG_MATRIXTRANSFORM
15#define OSG_MATRIXTRANSFORM 1
17#include <osg/Transform>
21/** MatrixTransform - is a subclass of Transform which has an osg::Matrix
22 * which represents a 4x4 transformation of its children from local coordinates
23 * into the Transform's parent coordinates.
25class OSG_EXPORT MatrixTransform : public Transform
32 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
33 MatrixTransform(const MatrixTransform&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
35 MatrixTransform(const Matrix& matix);
37 META_Node(osg, MatrixTransform);
39 virtual MatrixTransform* asMatrixTransform() { return this; }
40 virtual const MatrixTransform* asMatrixTransform() const { return this; }
43 /** Set the transform's matrix.*/
44 void setMatrix(const Matrix& mat) { _matrix = mat; _inverseDirty=true; dirtyBound(); }
46 /** Get the matrix. */
47 inline const Matrix& getMatrix() const { return _matrix; }
49 /** pre multiply the transform's matrix.*/
50 void preMult(const Matrix& mat) { _matrix.preMult(mat); _inverseDirty=true; dirtyBound(); }
52 /** post multiply the transform's matrix.*/
53 void postMult(const Matrix& mat) { _matrix.postMult(mat); _inverseDirty=true; dirtyBound(); }
55 /** Get the inverse matrix. */
56 inline const Matrix& getInverseMatrix() const
60 _inverse.invert(_matrix);
61 _inverseDirty = false;
66 virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor*) const;
68 virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
73 virtual ~MatrixTransform();
76 mutable Matrix _inverse;
77 mutable bool _inverseDirty;