]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placement.hxx
Add preliminary spot light animation
[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 #include <osg/PositionAttitudeTransform>
18
19 #include <simgear/math/SGMath.hxx>
20
21 // Has anyone done anything *really* stupid, like making min and max macros?
22 #ifdef min
23 #undef min
24 #endif
25 #ifdef max
26 #undef max
27 #endif
28
29
30 ////////////////////////////////////////////////////////////////////////
31 // Model placement.
32 ////////////////////////////////////////////////////////////////////////
33
34 /**
35  * A wrapper for a model with a definite placement.
36  */
37 class SGModelPlacement
38 {
39 public:
40
41   SGModelPlacement ();
42   virtual ~SGModelPlacement ();
43
44   virtual void init( osg::Node* model );
45
46   virtual void update();
47
48   virtual osg::Node* getSceneGraph () { return _selector.get(); }
49
50   virtual bool getVisible () const;
51   virtual void setVisible (bool visible);
52
53   virtual double getLongitudeDeg () const { return _position.getLongitudeDeg(); }
54   virtual double getLatitudeDeg () const { return _position.getLatitudeDeg(); }
55   virtual double getElevationFt () const { return _position.getElevationFt(); }
56
57   virtual void setLongitudeDeg (double lon_deg);
58   virtual void setLatitudeDeg (double lat_deg);
59   virtual void setElevationFt (double elev_ft);
60   virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
61   void setPosition(const SGGeod& position);
62   const SGGeod& getPosition() const { return _position; }
63
64   virtual double getRollDeg () const { return _roll_deg; }
65   virtual double getPitchDeg () const { return _pitch_deg; }
66   virtual double getHeadingDeg () const { return _heading_deg; }
67
68   virtual void setRollDeg (double roll_deg);
69   virtual void setPitchDeg (double pitch_deg);
70   virtual void setHeadingDeg (double heading_deg);
71   virtual void setOrientation (double roll_deg, double pitch_deg,
72                                double heading_deg);
73   void setOrientation(const SGQuatd& orientation);
74
75   void setReferenceTime(const double& referenceTime);
76   void setBodyLinearVelocity(const SGVec3d& velocity);
77   void setBodyAngularVelocity(const SGVec3d& velocity);
78   
79 private:
80                                 // Geodetic position
81   SGGeod _position;
82
83                                 // Orientation
84   double _roll_deg;
85   double _pitch_deg;
86   double _heading_deg;
87
88   osg::ref_ptr<osg::Switch> _selector;
89   osg::ref_ptr<osg::PositionAttitudeTransform> _transform;
90 };
91
92 #endif // _SG_PLACEMENT_HXX