]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placement.hxx
Merge branch 'topic/cloudz' 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 // Don't pull in the headers, since we don't need them here.
23 class SGLocation;
24
25
26 // Has anyone done anything *really* stupid, like making min and max macros?
27 #ifdef min
28 #undef min
29 #endif
30 #ifdef max
31 #undef max
32 #endif
33
34
35 ////////////////////////////////////////////////////////////////////////
36 // Model placement.
37 ////////////////////////////////////////////////////////////////////////
38
39 /**
40  * A wrapper for a model with a definite placement.
41  */
42 class SGModelPlacement
43 {
44 public:
45
46   SGModelPlacement ();
47   virtual ~SGModelPlacement ();
48
49   virtual void init( osg::Node* model );
50
51   virtual void update();
52
53   virtual osg::Node* getSceneGraph () { return _selector.get(); }
54
55   virtual SGLocation * getSGLocation () { return _location; }
56
57   virtual bool getVisible () const;
58   virtual void setVisible (bool visible);
59
60   virtual double getLongitudeDeg () const { return _lon_deg; }
61   virtual double getLatitudeDeg () const { return _lat_deg; }
62   virtual double getElevationFt () const { return _elev_ft; }
63
64   virtual void setLongitudeDeg (double lon_deg);
65   virtual void setLatitudeDeg (double lat_deg);
66   virtual void setElevationFt (double elev_ft);
67   virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
68   void setPosition(const SGGeod& position);
69
70   virtual double getRollDeg () const { return _roll_deg; }
71   virtual double getPitchDeg () const { return _pitch_deg; }
72   virtual double getHeadingDeg () const { return _heading_deg; }
73
74   virtual void setRollDeg (double roll_deg);
75   virtual void setPitchDeg (double pitch_deg);
76   virtual void setHeadingDeg (double heading_deg);
77   virtual void setOrientation (double roll_deg, double pitch_deg,
78                                double heading_deg);
79   void setOrientation(const SGQuatd& orientation);
80   
81   SGPlacementTransform * getTransform(void)
82   { return _position.get(); }
83
84 private:
85
86                                 // Geodetic position
87   double _lon_deg;
88   double _lat_deg;
89   double _elev_ft;
90
91                                 // Orientation
92   double _roll_deg;
93   double _pitch_deg;
94   double _heading_deg;
95
96   osg::ref_ptr<osg::Switch> _selector;
97   osg::ref_ptr<SGPlacementTransform> _position;
98
99                                 // Location
100   SGLocation * _location;
101 };
102
103 #endif // _SG_PLACEMENT_HXX