]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
Position and orientation fixes for the sound code, thanks to Tim Moore
[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
29 #include <simgear/compiler.h>
30 #include <simgear/structure/subsystem_mgr.hxx>
31 #include <simgear/math/SGMath.hxx>
32
33 // forward decls
34 class FGViewer;
35 class SGSoundMgr;
36 typedef SGSharedPtr<FGViewer> FGViewerPtr;
37
38 // Define a structure containing view information
39 class FGViewMgr : public SGSubsystem
40 {
41
42 public:
43
44     // Constructor
45     FGViewMgr( void );
46
47     // Destructor
48     ~FGViewMgr( void );
49
50     virtual void init ();
51     virtual void bind ();
52     virtual void unbind ();
53     virtual void update (double dt);
54     virtual void reinit ();
55
56     // getters
57     inline int size() const { return views.size(); }
58     inline int get_current() const { return current; }
59     
60     FGViewer *get_current_view();
61     const FGViewer *get_current_view() const;
62     
63     FGViewer *get_view( int i ); 
64     const FGViewer *get_view( int i ) const;
65       
66     FGViewer *next_view();
67     FGViewer *prev_view();
68       
69     // setters
70     void clear();
71     inline void set_view( const int v ) { current = v; }
72     void add_view( FGViewer * v );
73     
74     // copies current offset settings to current-view path...
75     void copyToCurrent ();
76
77 private:
78
79     double axis_long;
80     double axis_lat;
81
82     void do_axes ();
83
84     //  callbacks in manager to access viewer methods
85     double getViewHeadingOffset_deg () const;
86     void setViewHeadingOffset_deg (double offset);
87     double getViewGoalHeadingOffset_deg () const;
88     void setViewGoalHeadingOffset_deg (double offset);
89     double getViewPitchOffset_deg () const;
90     void setViewPitchOffset_deg (double tilt);
91     double getGoalViewPitchOffset_deg () const;
92     void setGoalViewRollOffset_deg (double tilt);
93     double getViewRollOffset_deg () const;
94     void setViewRollOffset_deg (double tilt);
95     double getGoalViewRollOffset_deg () const;
96     void setGoalViewPitchOffset_deg (double tilt);
97     double getViewXOffset_m () const;
98     void setViewXOffset_m (double x);
99     double getViewYOffset_m () const;
100     void setViewYOffset_m (double y);
101     double getViewZOffset_m () const;
102     void setViewZOffset_m (double z);
103     double getViewTargetXOffset_m () const;
104     void setViewTargetXOffset_m (double x);
105     double getViewTargetYOffset_m () const;
106     void setViewTargetYOffset_m (double y);
107     double getViewTargetZOffset_m () const;
108     void setViewTargetZOffset_m (double z);
109     double getFOV_deg () const;
110     void setFOV_deg (double fov);
111     double getARM_deg () const; // Aspect Ratio Multiplier
112     void setARM_deg (double fov);
113     double getNear_m () const;
114     void setNear_m (double near_m);
115     void setViewAxisLong (double axis);
116     void setViewAxisLat (double axis);
117     int getView () const;
118     void setView (int newview);
119     bool stationary () const;
120
121     SGPropertyNode_ptr view_number;
122     vector<SGPropertyNode_ptr> config_list;
123     typedef std::vector<FGViewerPtr> viewer_list;
124     viewer_list views;
125     SGVec3d abs_viewer_position;
126
127     int current;
128
129     SGSoundMgr *smgr;
130
131 };
132
133
134 #endif // _VIEWMGR_HXX