1 // placementtrans.hxx -- class for carrying transforms for placing models in the world
3 // Written by Mathias Froehlich, started April 2005.
5 // Copyright (C) 2005 Mathias Froehlich
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef _SG_PLACEMENTTRANS_HXX
24 #define _SG_PLACEMENTTRANS_HXX
27 # error This library requires C++
30 #include <simgear/compiler.h>
31 #include <simgear/constants.h>
32 #include <simgear/math/SGMath.hxx>
34 #include <osg/Transform>
36 class SGPlacementTransform : public osg::Transform
40 SGPlacementTransform(void);
41 SGPlacementTransform(const SGPlacementTransform&,
42 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
44 META_Node(simgear, SGPlacementTransform);
46 void setTransform(const SGVec3d& off)
47 { _placement_offset = off; dirtyBound(); }
48 void setTransform(const SGVec3d& off, const SGMatrixd& rot)
49 { _placement_offset = off; _rotation = rot; dirtyBound(); }
50 void setSceneryCenter(const SGVec3d& center)
51 { _scenery_center = center; dirtyBound(); }
53 const SGVec3d& getGlobalPos() const
54 { return _placement_offset; }
55 const SGMatrixd& getRotation() const { return _rotation; }
56 const SGVec3d& getSceneryCenter() const { return _scenery_center; }
58 virtual bool computeLocalToWorldMatrix(osg::Matrix&,osg::NodeVisitor*) const;
59 virtual bool computeWorldToLocalMatrix(osg::Matrix&,osg::NodeVisitor*) const;
62 virtual ~SGPlacementTransform(void);
68 //////////////////////////////////////////////////////////////////
70 //////////////////////////////////////////////////////////////////
72 SGVec3d _placement_offset;
73 SGVec3d _scenery_center;
77 #endif // _SG_LOCATION_HXX