1 // viewmgr.cxx -- class for managing all the views in the flightgear world.
3 // Written by Curtis Olson, started October 2000.
4 // partially rewritten by Jim Wilson March 2002
6 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include "viewmgr.hxx"
30 #include <string.h> // strcmp
32 #include <simgear/compiler.h>
33 #include <simgear/sound/soundmgr_openal.hxx>
34 #include <Model/acmodel.hxx>
35 #include <Main/viewer.hxx>
36 #include <Main/fg_props.hxx>
39 FGViewMgr::FGViewMgr( void ) :
42 view_number(fgGetNode("/sim/current-view/view-number", true)),
43 config_list(fgGetNode("/sim", true)->getChildren("view")),
46 smgr = globals->get_soundmgr();
50 FGViewMgr::~FGViewMgr( void ) {
56 double aspect_ratio_multiplier
57 = fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
59 for (unsigned int i = 0; i < config_list.size(); i++) {
60 SGPropertyNode *n = config_list[i];
62 // find out if this is an internal view (e.g. in cockpit, low near plane)
63 bool internal = n->getBoolValue("internal", false);
66 // this is assumed to be an aircraft model...we will need to read
67 // model-from-type as well.
69 // find out if this is a model we are looking from...
70 bool from_model = n->getBoolValue("config/from-model");
71 int from_model_index = n->getIntValue("config/from-model-idx");
73 double x_offset_m = n->getDoubleValue("config/x-offset-m");
74 double y_offset_m = n->getDoubleValue("config/y-offset-m");
75 double z_offset_m = n->getDoubleValue("config/z-offset-m");
77 double heading_offset_deg = n->getDoubleValue("config/heading-offset-deg");
78 n->setDoubleValue("config/heading-offset-deg", heading_offset_deg);
79 double pitch_offset_deg = n->getDoubleValue("config/pitch-offset-deg");
80 n->setDoubleValue("config/pitch-offset-deg", pitch_offset_deg);
81 double roll_offset_deg = n->getDoubleValue("config/roll-offset-deg");
82 n->setDoubleValue("config/roll-offset-deg", roll_offset_deg);
84 double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
85 double near_m = n->getDoubleValue("config/ground-level-nearplane-m");
87 // supporting two types "lookat" = 1 and "lookfrom" = 0
88 const char *type = n->getStringValue("type");
89 if (!strcmp(type, "lookat")) {
91 bool at_model = n->getBoolValue("config/at-model");
92 int at_model_index = n->getIntValue("config/at-model-idx");
94 double damp_roll = n->getDoubleValue("config/at-model-roll-damping");
95 double damp_pitch = n->getDoubleValue("config/at-model-pitch-damping");
96 double damp_heading = n->getDoubleValue("config/at-model-heading-damping");
98 double target_x_offset_m = n->getDoubleValue("config/target-x-offset-m");
99 double target_y_offset_m = n->getDoubleValue("config/target-y-offset-m");
100 double target_z_offset_m = n->getDoubleValue("config/target-z-offset-m");
102 add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
103 at_model, at_model_index,
104 damp_roll, damp_pitch, damp_heading,
105 x_offset_m, y_offset_m,z_offset_m,
106 heading_offset_deg, pitch_offset_deg,
107 roll_offset_deg, fov_deg, aspect_ratio_multiplier,
108 target_x_offset_m, target_y_offset_m,
109 target_z_offset_m, near_m, internal ));
111 add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
112 false, 0, 0.0, 0.0, 0.0,
113 x_offset_m, y_offset_m, z_offset_m,
114 heading_offset_deg, pitch_offset_deg,
115 roll_offset_deg, fov_deg, aspect_ratio_multiplier,
116 0, 0, 0, near_m, internal ));
126 // reset offsets and fov to configuration defaults
127 for (unsigned int i = 0; i < config_list.size(); i++) {
128 SGPropertyNode *n = config_list[i];
131 fgSetDouble("/sim/current-view/x-offset-m",
132 n->getDoubleValue("config/x-offset-m"));
133 fgSetDouble("/sim/current-view/y-offset-m",
134 n->getDoubleValue("config/y-offset-m"));
135 fgSetDouble("/sim/current-view/z-offset-m",
136 n->getDoubleValue("config/z-offset-m"));
137 fgSetDouble("/sim/current-view/pitch-offset-deg",
138 n->getDoubleValue("config/pitch-offset-deg"));
139 fgSetDouble("/sim/current-view/heading-offset-deg",
140 n->getDoubleValue("config/heading-offset-deg"));
141 fgSetDouble("/sim/current-view/roll-offset-deg",
142 n->getDoubleValue("config/roll-offset-deg"));
144 double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
147 fgSetDouble("/sim/current-view/field-of-view", fov_deg);
149 // target offsets for lookat mode only...
150 fgSetDouble("/sim/current-view/target-x-offset-m",
151 n->getDoubleValue("config/target-x-offset-m"));
152 fgSetDouble("/sim/current-view/target-y-offset-m",
153 n->getDoubleValue("config/target-y-offset-m"));
154 fgSetDouble("/sim/current-view/target-z-offset-m",
155 n->getDoubleValue("config/target-z-offset-m"));
160 typedef double (FGViewMgr::*double_getter)() const;
165 // these are bound to the current view properties
166 fgTie("/sim/current-view/heading-offset-deg", this,
167 &FGViewMgr::getViewHeadingOffset_deg,
168 &FGViewMgr::setViewHeadingOffset_deg);
169 fgSetArchivable("/sim/current-view/heading-offset-deg");
170 fgTie("/sim/current-view/goal-heading-offset-deg", this,
171 &FGViewMgr::getViewGoalHeadingOffset_deg,
172 &FGViewMgr::setViewGoalHeadingOffset_deg);
173 fgSetArchivable("/sim/current-view/goal-heading-offset-deg");
174 fgTie("/sim/current-view/pitch-offset-deg", this,
175 &FGViewMgr::getViewPitchOffset_deg,
176 &FGViewMgr::setViewPitchOffset_deg);
177 fgSetArchivable("/sim/current-view/pitch-offset-deg");
178 fgTie("/sim/current-view/goal-pitch-offset-deg", this,
179 &FGViewMgr::getGoalViewPitchOffset_deg,
180 &FGViewMgr::setGoalViewPitchOffset_deg);
181 fgSetArchivable("/sim/current-view/goal-pitch-offset-deg");
182 fgTie("/sim/current-view/roll-offset-deg", this,
183 &FGViewMgr::getViewRollOffset_deg,
184 &FGViewMgr::setViewRollOffset_deg);
185 fgSetArchivable("/sim/current-view/roll-offset-deg");
186 fgTie("/sim/current-view/goal-roll-offset-deg", this,
187 &FGViewMgr::getGoalViewRollOffset_deg,
188 &FGViewMgr::setGoalViewRollOffset_deg);
189 fgSetArchivable("/sim/current-view/goal-roll-offset-deg");
191 fgTie("/sim/current-view/view-number", this,
192 &FGViewMgr::getView, &FGViewMgr::setView);
193 fgSetArchivable("/sim/current-view/view-number", FALSE);
195 fgTie("/sim/current-view/axes/long", this,
196 (double_getter)0, &FGViewMgr::setViewAxisLong);
197 fgSetArchivable("/sim/current-view/axes/long");
199 fgTie("/sim/current-view/axes/lat", this,
200 (double_getter)0, &FGViewMgr::setViewAxisLat);
201 fgSetArchivable("/sim/current-view/axes/lat");
203 fgTie("/sim/current-view/field-of-view", this,
204 &FGViewMgr::getFOV_deg, &FGViewMgr::setFOV_deg);
205 fgSetArchivable("/sim/current-view/field-of-view");
207 fgTie("/sim/current-view/aspect-ratio-multiplier", this,
208 &FGViewMgr::getARM_deg, &FGViewMgr::setARM_deg);
209 fgSetArchivable("/sim/current-view/field-of-view");
211 fgTie("/sim/current-view/ground-level-nearplane-m", this,
212 &FGViewMgr::getNear_m, &FGViewMgr::setNear_m);
213 fgSetArchivable("/sim/current-view/ground-level-nearplane-m");
215 SGPropertyNode *n = fgGetNode("/sim/current-view", true);
216 n->tie("viewer-x-m", SGRawValuePointer<double>(&abs_viewer_position[0]));
217 n->tie("viewer-y-m", SGRawValuePointer<double>(&abs_viewer_position[1]));
218 n->tie("viewer-z-m", SGRawValuePointer<double>(&abs_viewer_position[2]));
225 // need to redo these bindings to the new locations (move to viewer?)
226 fgUntie("/sim/current-view/heading-offset-deg");
227 fgUntie("/sim/current-view/goal-heading-offset-deg");
228 fgUntie("/sim/current-view/pitch-offset-deg");
229 fgUntie("/sim/current-view/goal-pitch-offset-deg");
230 fgUntie("/sim/current-view/field-of-view");
231 fgUntie("/sim/current-view/aspect-ratio-multiplier");
232 fgUntie("/sim/current-view/view-number");
233 fgUntie("/sim/current-view/axes/long");
234 fgUntie("/sim/current-view/axes/lat");
235 fgUntie("/sim/current-view/ground-level-nearplane-m");
236 fgUntie("/sim/current-view/viewer-x-m");
237 fgUntie("/sim/current-view/viewer-y-m");
238 fgUntie("/sim/current-view/viewer-z-m");
242 FGViewMgr::update (double dt)
244 FGViewer * view = get_current_view();
248 FGViewer *loop_view = (FGViewer *)get_view(current);
249 SGPropertyNode *n = config_list[current];
250 double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
252 // Set up view location and orientation
254 if (!n->getBoolValue("config/from-model")) {
255 lon_deg = fgGetDouble(n->getStringValue("config/eye-lon-deg-path"));
256 lat_deg = fgGetDouble(n->getStringValue("config/eye-lat-deg-path"));
257 alt_ft = fgGetDouble(n->getStringValue("config/eye-alt-ft-path"));
258 roll_deg = fgGetDouble(n->getStringValue("config/eye-roll-deg-path"));
259 pitch_deg = fgGetDouble(n->getStringValue("config/eye-pitch-deg-path"));
260 heading_deg = fgGetDouble(n->getStringValue("config/eye-heading-deg-path"));
262 loop_view->setPosition(lon_deg, lat_deg, alt_ft);
263 loop_view->setOrientation(roll_deg, pitch_deg, heading_deg);
265 // force recalc in viewer
266 loop_view->set_dirty();
269 // if lookat (type 1) then get target data...
270 if (loop_view->getType() == FG_LOOKAT) {
271 if (!n->getBoolValue("config/from-model")) {
272 lon_deg = fgGetDouble(n->getStringValue("config/target-lon-deg-path"));
273 lat_deg = fgGetDouble(n->getStringValue("config/target-lat-deg-path"));
274 alt_ft = fgGetDouble(n->getStringValue("config/target-alt-ft-path"));
275 roll_deg = fgGetDouble(n->getStringValue("config/target-roll-deg-path"));
276 pitch_deg = fgGetDouble(n->getStringValue("config/target-pitch-deg-path"));
277 heading_deg = fgGetDouble(n->getStringValue("config/target-heading-deg-path"));
279 loop_view->setTargetPosition(lon_deg, lat_deg, alt_ft);
280 loop_view->setTargetOrientation(roll_deg, pitch_deg, heading_deg);
282 loop_view->set_dirty();
286 setViewXOffset_m(fgGetDouble("/sim/current-view/x-offset-m"));
287 setViewYOffset_m(fgGetDouble("/sim/current-view/y-offset-m"));
288 setViewZOffset_m(fgGetDouble("/sim/current-view/z-offset-m"));
290 setViewTargetXOffset_m(fgGetDouble("/sim/current-view/target-x-offset-m"));
291 setViewTargetYOffset_m(fgGetDouble("/sim/current-view/target-y-offset-m"));
292 setViewTargetZOffset_m(fgGetDouble("/sim/current-view/target-z-offset-m"));
294 // Update the current view
297 abs_viewer_position = loop_view->getViewPosition();
299 // update audio listener values
300 // set the viewer posotion in Cartesian coordinates in meters
301 SGVec3d offs = SGVec3d( loop_view->getXOffset_m(),
302 loop_view->getYOffset_m(),
303 loop_view->getZOffset_m());
304 smgr->set_position_offset( offs );
305 smgr->set_position_geod( loop_view->getPosition() );
307 SGQuatd orient = SGQuatd::fromYawPitchRollDeg( loop_view->getHeading_deg(),
308 loop_view->getPitch_deg(),
309 loop_view->getRoll_deg() );
310 smgr->set_orientation( orient, loop_view->getViewOrientationOffset() );
312 // get the model velocity
313 SGVec3f velocity = SGVec3f::zeros();
314 if ( !stationary() ) {
315 velocity = globals->get_aircraft_model()->getVelocity();
317 smgr->set_velocity(velocity);
321 FGViewMgr::copyToCurrent()
323 SGPropertyNode *n = config_list[current];
324 fgSetString("/sim/current-view/name", n->getStringValue("name"));
325 fgSetString("/sim/current-view/type", n->getStringValue("type"));
327 // copy certain view config data for default values
328 fgSetDouble("/sim/current-view/config/heading-offset-deg",
329 n->getDoubleValue("config/default-heading-offset-deg"));
330 fgSetDouble("/sim/current-view/config/pitch-offset-deg",
331 n->getDoubleValue("config/pitch-offset-deg"));
332 fgSetDouble("/sim/current-view/config/roll-offset-deg",
333 n->getDoubleValue("config/roll-offset-deg"));
334 fgSetDouble("/sim/current-view/config/default-field-of-view-deg",
335 n->getDoubleValue("config/default-field-of-view-deg"));
336 fgSetBool("/sim/current-view/config/from-model",
337 n->getBoolValue("config/from-model"));
340 fgSetDouble("/sim/current-view/x-offset-m", getViewXOffset_m());
341 fgSetDouble("/sim/current-view/y-offset-m", getViewYOffset_m());
342 fgSetDouble("/sim/current-view/z-offset-m", getViewZOffset_m());
344 fgSetDouble("/sim/current-view/goal-heading-offset-deg",
345 get_current_view()->getGoalHeadingOffset_deg());
346 fgSetDouble("/sim/current-view/goal-pitch-offset-deg",
347 get_current_view()->getGoalPitchOffset_deg());
348 fgSetDouble("/sim/current-view/goal-roll-offset-deg",
349 get_current_view()->getRollOffset_deg());
350 fgSetDouble("/sim/current-view/heading-offset-deg",
351 get_current_view()->getHeadingOffset_deg());
352 fgSetDouble("/sim/current-view/pitch-offset-deg",
353 get_current_view()->getPitchOffset_deg());
354 fgSetDouble("/sim/current-view/roll-offset-deg",
355 get_current_view()->getRollOffset_deg());
356 fgSetDouble("/sim/current-view/target-x-offset-m",
357 get_current_view()->getTargetXOffset_m());
358 fgSetDouble("/sim/current-view/target-y-offset-m",
359 get_current_view()->getTargetYOffset_m());
360 fgSetDouble("/sim/current-view/target-z-offset-m",
361 get_current_view()->getTargetZOffset_m());
362 fgSetBool("/sim/current-view/internal",
363 get_current_view()->getInternal());
366 void FGViewMgr::clear()
372 FGViewMgr::get_current_view()
374 if ( current < (int)views.size() ) {
375 return views[current];
382 FGViewMgr::get_current_view() const
384 if ( current < (int)views.size() ) {
385 return views[current];
393 FGViewMgr::get_view( int i )
395 if ( i < 0 ) { i = 0; }
396 if ( i >= (int)views.size() ) { i = views.size() - 1; }
401 FGViewMgr::get_view( int i ) const
403 if ( i < 0 ) { i = 0; }
404 if ( i >= (int)views.size() ) { i = views.size() - 1; }
409 FGViewMgr::next_view()
411 setView((current+1 < (int)views.size()) ? (current + 1) : 0);
412 view_number->fireValueChanged();
413 return views[current];
417 FGViewMgr::prev_view()
419 setView((0 < current) ? (current - 1) : (views.size() - 1));
420 view_number->fireValueChanged();
421 return views[current];
425 FGViewMgr::add_view( FGViewer * v )
432 FGViewMgr::getViewHeadingOffset_deg () const
434 const FGViewer * view = get_current_view();
435 return (view == 0 ? 0 : view->getHeadingOffset_deg());
439 FGViewMgr::setViewHeadingOffset_deg (double offset)
441 FGViewer * view = get_current_view();
443 view->setGoalHeadingOffset_deg(offset);
444 view->setHeadingOffset_deg(offset);
449 FGViewMgr::getViewGoalHeadingOffset_deg () const
451 const FGViewer * view = get_current_view();
452 return (view == 0 ? 0 : view->getGoalHeadingOffset_deg());
456 FGViewMgr::setViewGoalHeadingOffset_deg (double offset)
458 FGViewer * view = get_current_view();
460 view->setGoalHeadingOffset_deg(offset);
464 FGViewMgr::getViewPitchOffset_deg () const
466 const FGViewer * view = get_current_view();
467 return (view == 0 ? 0 : view->getPitchOffset_deg());
471 FGViewMgr::setViewPitchOffset_deg (double tilt)
473 FGViewer * view = get_current_view();
475 view->setGoalPitchOffset_deg(tilt);
476 view->setPitchOffset_deg(tilt);
481 FGViewMgr::getGoalViewPitchOffset_deg () const
483 const FGViewer * view = get_current_view();
484 return (view == 0 ? 0 : view->getGoalPitchOffset_deg());
488 FGViewMgr::setGoalViewPitchOffset_deg (double tilt)
490 FGViewer * view = get_current_view();
492 view->setGoalPitchOffset_deg(tilt);
496 FGViewMgr::getViewRollOffset_deg () const
498 const FGViewer * view = get_current_view();
499 return (view == 0 ? 0 : view->getRollOffset_deg());
503 FGViewMgr::setViewRollOffset_deg (double tilt)
505 FGViewer * view = get_current_view();
507 view->setGoalRollOffset_deg(tilt);
508 view->setRollOffset_deg(tilt);
513 FGViewMgr::getGoalViewRollOffset_deg () const
515 const FGViewer * view = get_current_view();
516 return (view == 0 ? 0 : view->getGoalRollOffset_deg());
520 FGViewMgr::setGoalViewRollOffset_deg (double tilt)
522 FGViewer * view = get_current_view();
524 view->setGoalRollOffset_deg(tilt);
528 FGViewMgr::getViewXOffset_m () const
530 const FGViewer * view = get_current_view();
532 return ((FGViewer *)view)->getXOffset_m();
539 FGViewMgr::setViewXOffset_m (double x)
541 FGViewer * view = get_current_view();
543 view->setXOffset_m(x);
548 FGViewMgr::getViewYOffset_m () const
550 const FGViewer * view = get_current_view();
552 return ((FGViewer *)view)->getYOffset_m();
559 FGViewMgr::setViewYOffset_m (double y)
561 FGViewer * view = get_current_view();
563 view->setYOffset_m(y);
568 FGViewMgr::getViewZOffset_m () const
570 const FGViewer * view = get_current_view();
572 return ((FGViewer *)view)->getZOffset_m();
579 FGViewMgr::setViewZOffset_m (double z)
581 FGViewer * view = get_current_view();
583 view->setZOffset_m(z);
588 FGViewMgr::stationary () const
590 const FGViewer * view = get_current_view();
592 if (((FGViewer *)view)->getXOffset_m() == 0.0 &&
593 ((FGViewer *)view)->getYOffset_m() == 0.0 &&
594 ((FGViewer *)view)->getZOffset_m() == 0.0)
602 FGViewMgr::getViewTargetXOffset_m () const
604 const FGViewer * view = get_current_view();
606 return ((FGViewer *)view)->getTargetXOffset_m();
613 FGViewMgr::setViewTargetXOffset_m (double x)
615 FGViewer * view = get_current_view();
617 view->setTargetXOffset_m(x);
622 FGViewMgr::getViewTargetYOffset_m () const
624 const FGViewer * view = get_current_view();
626 return ((FGViewer *)view)->getTargetYOffset_m();
633 FGViewMgr::setViewTargetYOffset_m (double y)
635 FGViewer * view = get_current_view();
637 view->setTargetYOffset_m(y);
642 FGViewMgr::getViewTargetZOffset_m () const
644 const FGViewer * view = get_current_view();
646 return ((FGViewer *)view)->getTargetZOffset_m();
653 FGViewMgr::setViewTargetZOffset_m (double z)
655 FGViewer * view = get_current_view();
657 view->setTargetZOffset_m(z);
662 FGViewMgr::getView () const
668 FGViewMgr::setView (int newview)
670 // negative numbers -> set view with node index -newview
672 for (int i = 0; i < (int)config_list.size(); i++) {
673 int index = -config_list[i]->getIndex();
674 if (index == newview)
681 // if newview number too low wrap to last view...
683 newview = (int)views.size() - 1;
685 // if newview number to high wrap to zero...
686 if (newview >= (int)views.size())
694 // Copy the fdm's position into the SGLocation which is shared with
696 globals->get_aircraft_model()->update(0);
703 FGViewMgr::getFOV_deg () const
705 const FGViewer * view = get_current_view();
706 return (view == 0 ? 0 : view->get_fov());
710 FGViewMgr::setFOV_deg (double fov)
712 FGViewer * view = get_current_view();
718 FGViewMgr::getARM_deg () const
720 const FGViewer * view = get_current_view();
721 return (view == 0 ? 0 : view->get_aspect_ratio_multiplier());
725 FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
727 FGViewer * view = get_current_view();
729 view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);
733 FGViewMgr::getNear_m () const
735 const FGViewer * view = get_current_view();
736 return (view == 0 ? 0.5f : view->getNear_m());
740 FGViewMgr::setNear_m (double near_m)
742 FGViewer * view = get_current_view();
744 view->setNear_m(near_m);
748 FGViewMgr::setViewAxisLong (double axis)
754 FGViewMgr::setViewAxisLat (double axis)
760 FGViewMgr::do_axes ()
762 // Take no action when hat is centered
763 if ( ( axis_long < 0.01 ) &&
764 ( axis_long > -0.01 ) &&
765 ( axis_lat < 0.01 ) &&
770 double viewDir = 999;
772 /* Do all the quick and easy cases */
773 if (axis_long < 0) { // Longitudinal axis forward
774 if (axis_lat == axis_long)
775 viewDir = fgGetDouble("/sim/view/config/front-left-direction-deg");
776 else if (axis_lat == - axis_long)
777 viewDir = fgGetDouble("/sim/view/config/front-right-direction-deg");
778 else if (axis_lat == 0)
779 viewDir = fgGetDouble("/sim/view/config/front-direction-deg");
780 } else if (axis_long > 0) { // Longitudinal axis backward
781 if (axis_lat == - axis_long)
782 viewDir = fgGetDouble("/sim/view/config/back-left-direction-deg");
783 else if (axis_lat == axis_long)
784 viewDir = fgGetDouble("/sim/view/config/back-right-direction-deg");
785 else if (axis_lat == 0)
786 viewDir = fgGetDouble("/sim/view/config/back-direction-deg");
787 } else if (axis_long == 0) { // Longitudinal axis neutral
789 viewDir = fgGetDouble("/sim/view/config/left-direction-deg");
790 else if (axis_lat > 0)
791 viewDir = fgGetDouble("/sim/view/config/right-direction-deg");
792 else return; /* And assertion failure maybe? */
795 // Do all the difficult cases
797 viewDir = SGD_RADIANS_TO_DEGREES * atan2 ( -axis_lat, -axis_long );
798 if ( viewDir < -1 ) viewDir += 360;
800 get_current_view()->setGoalHeadingOffset_deg(viewDir);