]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placementtrans.hxx
Make the debug geometry stuff work with a time argument.
[simgear.git] / simgear / scene / model / placementtrans.hxx
1 // placementtrans.hxx -- class for carrying transforms for placing models in the world
2 //
3 // Written by Mathias Froehlich, started April 2005.
4 //
5 // Copyright (C) 2005 Mathias Froehlich
6 //
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.
11 //
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.
16 //
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.
20 //
21
22
23 #ifndef _SG_PLACEMENTTRANS_HXX
24 #define _SG_PLACEMENTTRANS_HXX
25
26 #ifndef __cplusplus
27 # error This library requires C++
28 #endif
29
30 #include <simgear/compiler.h>
31 #include <simgear/constants.h>
32 #include <simgear/math/SGMath.hxx>
33
34 #include <osg/Transform>
35
36 class SGPlacementTransform : public osg::Transform
37 {
38 public:
39   
40   SGPlacementTransform(void);
41   SGPlacementTransform(const SGPlacementTransform&,
42                        const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
43
44   META_Node(simgear, SGPlacementTransform);
45   
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   
51   const SGVec3d& getGlobalPos() const
52   { return _placement_offset; }
53   const SGMatrixd& getRotation() const { return _rotation; }
54   
55   virtual bool computeLocalToWorldMatrix(osg::Matrix&,osg::NodeVisitor*) const;
56   virtual bool computeWorldToLocalMatrix(osg::Matrix&,osg::NodeVisitor*) const;
57
58 protected:
59   virtual ~SGPlacementTransform(void);
60
61 private:
62
63   class UpdateCallback;
64
65   //////////////////////////////////////////////////////////////////
66   // private data                                                 //
67   //////////////////////////////////////////////////////////////////
68   
69   SGVec3d _placement_offset;
70   SGMatrixd _rotation;
71 };
72
73 #endif // _SG_LOCATION_HXX