]> git.mxchange.org Git - simgear.git/blob - simgear/scene/model/placement.hxx
Mathias:
[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 <plib/sg.h>
15 #include <plib/ssg.h>
16
17 #include <simgear/math/point3d.hxx>
18 #include <simgear/props/props.hxx>
19
20
21 // Don't pull in the headers, since we don't need them here.
22 class SGLocation;
23 class ssgPlacementTransform;
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 SGModelPlacement::init( ssgBranch * model );
50   /* virtual void init( const string &fg_root,
51                      const string &path,
52                      SGPropertyNode *prop_root,
53                      double sim_time_sec, int dummy ); */
54   virtual void update( const Point3D scenery_center );
55
56   virtual ssgEntity * getSceneGraph () { return (ssgEntity *)_selector; }
57
58   virtual SGLocation * getSGLocation () { return _location; }
59
60   virtual bool getVisible () const;
61   virtual void setVisible (bool visible);
62
63   virtual double getLongitudeDeg () const { return _lon_deg; }
64   virtual double getLatitudeDeg () const { return _lat_deg; }
65   virtual double getElevationFt () const { return _elev_ft; }
66
67   virtual void setLongitudeDeg (double lon_deg);
68   virtual void setLatitudeDeg (double lat_deg);
69   virtual void setElevationFt (double elev_ft);
70   virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
71
72   virtual double getRollDeg () const { return _roll_deg; }
73   virtual double getPitchDeg () const { return _pitch_deg; }
74   virtual double getHeadingDeg () const { return _heading_deg; }
75
76   virtual void setRollDeg (double roll_deg);
77   virtual void setPitchDeg (double pitch_deg);
78   virtual void setHeadingDeg (double heading_deg);
79   virtual void setOrientation (double roll_deg, double pitch_deg,
80                                double heading_deg);
81   
82   // Addition by Diarmuid Tyson for Multiplayer Support
83   // Allows multiplayer to get players position transform
84   virtual const sgVec4 *get_POS() { return POS; }
85
86   ssgPlacementTransform * getTransform(void)
87   { return _position; }
88
89 private:
90
91                                 // Geodetic position
92   double _lon_deg;
93   double _lat_deg;
94   double _elev_ft;
95
96                                 // Orientation
97   double _roll_deg;
98   double _pitch_deg;
99   double _heading_deg;
100
101   ssgSelector * _selector;
102 //   ssgTransform * _position;
103   ssgPlacementTransform * _position;
104
105                                 // Location
106   SGLocation * _location;
107
108
109   // Addition by Diarmuid Tyson for Multiplayer Support
110   // Moved from update method
111   // POS for transformation Matrix
112   sgMat4 POS;
113
114 };
115
116 #endif // _SG_PLACEMENT_HXX