]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
Merge commit 'refs/merge-requests/1552' of git@gitorious.org:fg/flightgear into next
[flightgear.git] / src / Main / viewmgr.hxx
1 // viewmgr.hxx -- class for managing all the views in the flightgear world.
2 //
3 // Written by Curtis Olson, started October 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
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 // $Id$
22
23
24 #ifndef _VIEWMGR_HXX
25 #define _VIEWMGR_HXX
26
27 #include <vector>
28 #include <list>
29
30 #include <simgear/compiler.h>
31 #include <simgear/structure/subsystem_mgr.hxx>
32 #include <simgear/math/SGMath.hxx>
33
34 // forward decls
35 class FGViewer;
36 class SGSoundMgr;
37 typedef SGSharedPtr<FGViewer> FGViewerPtr;
38
39 // Define a structure containing view information
40 class FGViewMgr : public SGSubsystem
41 {
42
43 public:
44
45     // Constructor
46     FGViewMgr( void );
47
48     // Destructor
49     ~FGViewMgr( void );
50
51     virtual void init ();
52     virtual void bind ();
53     virtual void unbind ();
54     virtual void update (double dt);
55     virtual void reinit ();
56
57     // getters
58     inline int size() const { return views.size(); }
59     inline int get_current() const { return current; }
60     
61     FGViewer *get_current_view();
62     const FGViewer *get_current_view() const;
63     
64     FGViewer *get_view( int i ); 
65     const FGViewer *get_view( int i ) const;
66       
67     FGViewer *next_view();
68     FGViewer *prev_view();
69       
70     // setters
71     void clear();
72     inline void set_view( const int v ) { current = v; }
73     void add_view( FGViewer * v );
74     
75     // copies current offset settings to current-view path...
76     void copyToCurrent ();
77
78 private:
79
80     list<const char*> tied_props;
81
82     double axis_long;
83     double axis_lat;
84
85     void do_axes ();
86
87     //  callbacks in manager to access viewer methods
88     double getViewHeadingOffset_deg () const;
89     void setViewHeadingOffset_deg (double offset);
90     double getViewGoalHeadingOffset_deg () const;
91     void setViewGoalHeadingOffset_deg (double offset);
92     double getViewPitchOffset_deg () const;
93     void setViewPitchOffset_deg (double tilt);
94     double getGoalViewPitchOffset_deg () const;
95     void setGoalViewRollOffset_deg (double tilt);
96     double getViewRollOffset_deg () const;
97     void setViewRollOffset_deg (double tilt);
98     double getGoalViewRollOffset_deg () const;
99     void setGoalViewPitchOffset_deg (double tilt);
100     double getViewXOffset_m () const;
101     void setViewXOffset_m (double x);
102     double getViewYOffset_m () const;
103     void setViewYOffset_m (double y);
104     double getViewZOffset_m () const;
105     void setViewZOffset_m (double z);
106     double getViewTargetXOffset_m () const;
107     void setViewTargetXOffset_m (double x);
108     double getViewTargetYOffset_m () const;
109     void setViewTargetYOffset_m (double y);
110     double getViewTargetZOffset_m () const;
111     void setViewTargetZOffset_m (double z);
112     double getFOV_deg () const;
113     void setFOV_deg (double fov);
114     double getARM_deg () const; // Aspect Ratio Multiplier
115     void setARM_deg (double fov);
116     double getNear_m () const;
117     void setNear_m (double near_m);
118     void setViewAxisLong (double axis);
119     void setViewAxisLat (double axis);
120     int getView () const;
121     void setView (int newview);
122
123 // quaternion accessors, for debugging:
124     double getCurrentViewOrientation_w() const;
125     double getCurrentViewOrientation_x() const;
126     double getCurrentViewOrientation_y() const;
127     double getCurrentViewOrientation_z() const;
128     double getCurrentViewOrOffset_w() const;
129     double getCurrentViewOrOffset_x() const;
130     double getCurrentViewOrOffset_y() const;
131     double getCurrentViewOrOffset_z() const;
132     double getCurrentViewFrame_w() const;
133     double getCurrentViewFrame_x() const;
134     double getCurrentViewFrame_y() const;
135     double getCurrentViewFrame_z() const;
136
137     bool stationary () const;
138
139     SGPropertyNode_ptr view_number;
140     vector<SGPropertyNode_ptr> config_list;
141     typedef std::vector<FGViewerPtr> viewer_list;
142     viewer_list views;
143     SGVec3d abs_viewer_position;
144
145     int current;
146     SGQuatd current_view_orientation, current_view_or_offset;
147
148     SGSoundMgr *smgr;
149
150 };
151
152 // This takes the conventional aviation XYZ body system 
153 // i.e.  x=forward, y=starboard, z=bottom
154 // which is widely used in FGFS
155 // and rotates it into the OpenGL camera system 
156 // i.e. Xprime=starboard, Yprime=top, Zprime=aft.
157 inline const SGQuatd fsb2sta()
158 {
159     return SGQuatd(-0.5, -0.5, 0.5, 0.5);
160 }
161
162 #endif // _VIEWMGR_HXX