]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placement.hxx
Merge branch 'maint' into next
[simgear.git] / simgear / scene / model / placement.hxx
1 // placement.hxx - manage the placment of a 3D model.
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6
7 #ifndef _SG_PLACEMENT_HXX
8 #define _SG_PLACEMENT_HXX 1
9
10 #ifndef __cplusplus
11 # error This library requires C++
12 #endif
13
14 #include <osg/ref_ptr>
15 #include <osg/Node>
16 #include <osg/Switch>
17
18 #include <simgear/props/props.hxx>
19
20 #include "placementtrans.hxx"
21
22 // Has anyone done anything *really* stupid, like making min and max macros?
23 #ifdef min
24 #undef min
25 #endif
26 #ifdef max
27 #undef max
28 #endif
29
30
31 ////////////////////////////////////////////////////////////////////////
32 // Model placement.
33 ////////////////////////////////////////////////////////////////////////
34
35 /**
36  * A wrapper for a model with a definite placement.
37  */
38 class SGModelPlacement
39 {
40 public:
41
42   SGModelPlacement ();
43   virtual ~SGModelPlacement ();
44
45   virtual void init( osg::Node* model );
46
47   virtual void update();
48
49   virtual osg::Node* getSceneGraph () { return _selector.get(); }
50
51   virtual bool getVisible () const;
52   virtual void setVisible (bool visible);
53
54   virtual double getLongitudeDeg () const { return _position.getLongitudeDeg(); }
55   virtual double getLatitudeDeg () const { return _position.getLatitudeDeg(); }
56   virtual double getElevationFt () const { return _position.getElevationFt(); }
57
58   virtual void setLongitudeDeg (double lon_deg);
59   virtual void setLatitudeDeg (double lat_deg);
60   virtual void setElevationFt (double elev_ft);
61   virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
62   void setPosition(const SGGeod& position);
63   const SGGeod& getPosition() const { return _position; }
64
65   virtual double getRollDeg () const { return _roll_deg; }
66   virtual double getPitchDeg () const { return _pitch_deg; }
67   virtual double getHeadingDeg () const { return _heading_deg; }
68
69   virtual void setRollDeg (double roll_deg);
70   virtual void setPitchDeg (double pitch_deg);
71   virtual void setHeadingDeg (double heading_deg);
72   virtual void setOrientation (double roll_deg, double pitch_deg,
73                                double heading_deg);
74   void setOrientation(const SGQuatd& orientation);
75
76   void setReferenceTime(const double& referenceTime);
77   void setBodyLinearVelocity(const SGVec3d& velocity);
78   void setBodyAngularVelocity(const SGVec3d& velocity);
79   
80 private:
81
82                                 // Geodetic position
83   SGGeod _position;
84
85                                 // Orientation
86   double _roll_deg;
87   double _pitch_deg;
88   double _heading_deg;
89
90   osg::ref_ptr<osg::Switch> _selector;
91   osg::ref_ptr<SGPlacementTransform> _transform;
92 };
93
94 #endif // _SG_PLACEMENT_HXX