]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placementtrans.hxx
Modified Files:
[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   virtual ~SGPlacementTransform(void);
42
43 public:
44
45   void setTransform(const SGVec3d& off)
46   { _placement_offset = off; dirtyBound(); }
47   void setTransform(const SGVec3d& off, const SGMatrixd& rot)
48   { _placement_offset = off; _rotation = rot; dirtyBound(); }
49   void setSceneryCenter(const SGVec3d& center)
50   { _scenery_center = center; dirtyBound(); }
51
52   virtual bool computeLocalToWorldMatrix(osg::Matrix&,osg::NodeVisitor*) const;
53   virtual bool computeWorldToLocalMatrix(osg::Matrix&,osg::NodeVisitor*) const;
54
55 private:
56
57   //////////////////////////////////////////////////////////////////
58   // private data                                                 //
59   //////////////////////////////////////////////////////////////////
60   
61   SGVec3d _placement_offset;
62   SGVec3d _scenery_center;
63   SGMatrixd _rotation;
64 };
65
66 #endif // _SG_LOCATION_HXX