1 // viewmgr.hxx -- class for managing all the views in the flightgear world.
3 // Written by Curtis Olson, started October 2000.
5 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
29 #include <simgear/compiler.h>
30 #include <simgear/structure/subsystem_mgr.hxx>
31 #include <simgear/props/props.hxx>
32 #include <simgear/props/tiedpropertylist.hxx>
33 #include <simgear/math/SGMath.hxx>
39 typedef SGSharedPtr<flightgear::View> ViewPtr;
42 // Define a structure containing view information
43 class FGViewMgr : public SGSubsystem
55 virtual void postinit();
57 virtual void unbind ();
58 virtual void update (double dt);
59 virtual void reinit ();
60 virtual void shutdown();
63 inline int size() const { return views.size(); }
64 inline int get_current() const { return current; }
66 flightgear::View* get_current_view();
67 const flightgear::View* get_current_view() const;
69 flightgear::View* get_view( int i );
70 const flightgear::View* get_view( int i ) const;
72 flightgear::View* next_view();
73 flightgear::View* prev_view();
78 void add_view( flightgear::View * v );
80 static const char* subsystemName() { return "view-manager"; }
84 simgear::TiedPropertyList _tiedProperties;
91 // callbacks in manager to access viewer methods
92 double getViewHeadingOffset_deg () const;
93 void setViewHeadingOffset_deg (double offset);
94 double getViewGoalHeadingOffset_deg () const;
95 void setViewGoalHeadingOffset_deg (double offset);
96 double getViewPitchOffset_deg () const;
97 void setViewPitchOffset_deg (double tilt);
98 double getGoalViewPitchOffset_deg () const;
99 void setGoalViewRollOffset_deg (double tilt);
100 double getViewRollOffset_deg () const;
101 void setViewRollOffset_deg (double tilt);
102 double getGoalViewRollOffset_deg () const;
103 void setGoalViewPitchOffset_deg (double tilt);
104 double getViewXOffset_m () const;
105 void setViewXOffset_m (double x);
106 double getViewYOffset_m () const;
107 void setViewYOffset_m (double y);
108 double getViewZOffset_m () const;
109 void setViewZOffset_m (double z);
110 double getViewTargetXOffset_m () const;
111 void setViewTargetXOffset_m (double x);
112 double getViewTargetYOffset_m () const;
113 void setViewTargetYOffset_m (double y);
114 double getViewTargetZOffset_m () const;
115 void setViewTargetZOffset_m (double z);
116 double getFOV_deg () const;
117 void setFOV_deg (double fov);
118 double getARM_deg () const; // Aspect Ratio Multiplier
119 void setARM_deg (double fov);
120 double getNear_m () const;
121 void setNear_m (double near_m);
122 void setViewAxisLong (double axis);
123 void setViewAxisLat (double axis);
124 int getView () const;
125 void setView (int newview);
127 double getViewLon_deg() const;
128 double getViewLat_deg() const;
129 double getViewElev_ft() const;
131 // quaternion accessors, for debugging:
132 double getCurrentViewOrientation_w() const;
133 double getCurrentViewOrientation_x() const;
134 double getCurrentViewOrientation_y() const;
135 double getCurrentViewOrientation_z() const;
136 double getCurrentViewOrOffset_w() const;
137 double getCurrentViewOrOffset_x() const;
138 double getCurrentViewOrOffset_y() const;
139 double getCurrentViewOrOffset_z() const;
140 double getCurrentViewFrame_w() const;
141 double getCurrentViewFrame_x() const;
142 double getCurrentViewFrame_y() const;
143 double getCurrentViewFrame_z() const;
145 // copies current offset settings to current-view path...
146 void copyToCurrent ();
149 SGPropertyNode_ptr view_number;
150 std::vector<SGPropertyNode_ptr> config_list;
151 typedef std::vector<flightgear::ViewPtr> viewer_list;
153 SGVec3d abs_viewer_position;
156 SGQuatd current_view_orientation, current_view_or_offset;
158 SGPropertyNode_ptr current_x_offs, current_y_offs, current_z_offs;
159 SGPropertyNode_ptr target_x_offs, target_y_offs, target_z_offs;
162 // This takes the conventional aviation XYZ body system
163 // i.e. x=forward, y=starboard, z=bottom
164 // which is widely used in FGFS
165 // and rotates it into the OpenGL camera system
166 // i.e. Xprime=starboard, Yprime=top, Zprime=aft.
167 inline const SGQuatd fsb2sta()
169 return SGQuatd(-0.5, -0.5, 0.5, 0.5);
172 #endif // _VIEWMGR_HXX