// partially rewritten by Jim Wilson jim@kelcomaine.com using interface
// by David Megginson March 2002
//
-// Copyright (C) 1997 - 2000 Curtis L. Olson - curt@flightgear.org
+// Copyright (C) 1997 - 2000 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
double damp_roll, double damp_pitch, double damp_heading,
double x_offset_m, double y_offset_m, double z_offset_m,
double heading_offset_deg, double pitch_offset_deg,
- double roll_offset_deg, double fov_deg,
+ double roll_offset_deg,
+ double fov_deg, double aspect_ratio_multiplier,
double target_x_offset_m, double target_y_offset_m,
double target_z_offset_m, double near_m, bool internal ):
_dirty(true),
} else {
_fov_deg = 55;
}
+ _aspect_ratio_multiplier = aspect_ratio_multiplier;
_target_x_offset_m = target_x_offset_m;
_target_y_offset_m = target_y_offset_m;
_target_z_offset_m = target_z_offset_m;
void
FGViewer::updateFromModelLocation (SGLocation * location)
{
- sgCopyMat4(LOCAL, location->getCachedTransformMatrix());
+ Point3D center = globals->get_scenery()->get_next_center();
+ sgCopyMat4(LOCAL, location->getTransformMatrix(center));
}
void
FGViewer::updateAtModelLocation (SGLocation * location)
{
- sgCopyMat4(ATLOCAL,
- location->getCachedTransformMatrix());
+ Point3D center = globals->get_scenery()->get_next_center();
+ sgCopyMat4(ATLOCAL, location->getTransformMatrix(center));
}
void
dampEyeData(roll_deg, pitch_deg, heading_deg);
location->setPosition( lon_deg, lat_deg, alt_ft );
location->setOrientation( roll_deg, pitch_deg, heading_deg );
- sgCopyMat4(LOCAL,
- location->getTransformMatrix(globals->get_scenery()->get_center()));
+ Point3D center = globals->get_scenery()->get_next_center();
+ sgCopyMat4(LOCAL, location->getTransformMatrix(center));
+}
+
+void
+FGViewer::set_scenery_center(const Point3D& center)
+{
+ _location->set_tile_center(center);
+ _location->getTransformMatrix(center);
+ if (_type == FG_LOOKAT) {
+ _target_location->set_tile_center(center);
+ _target_location->getTransformMatrix(center);
+ }
+ set_dirty();
}
// recalc() is done every time one of the setters is called (making the
_target_roll_deg, _target_pitch_deg, _target_heading_deg );
}
// calculate the "at" target object positon relative to eye or view's tile center...
+ Point3D center = globals->get_scenery()->get_next_center();
sgdVec3 dVec3;
- sgdSetVec3(dVec3, _location->get_tile_center()[0], _location->get_tile_center()[1], _location->get_tile_center()[2]);
+ sgdSetVec3(dVec3, center[0], center[1], center[2]);
sgdSubVec3(dVec3,
- _target_location->get_absolute_view_pos(globals->get_scenery()->get_center()),
+ _target_location->get_absolute_view_pos(center),
dVec3 );
sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]);
FGViewer::copyLocationData()
{
// Get our friendly vectors from the eye location...
+ sgdCopyVec3(_absolute_view_pos,
+ _location->get_absolute_view_pos(globals->get_scenery()->get_next_center()));
sgCopyVec3(_zero_elev_view_pos, _location->get_zero_elev());
sgCopyVec3(_relative_view_pos, _location->get_view_pos());
- sgdCopyVec3(_absolute_view_pos,
- _location->get_absolute_view_pos(globals->get_scenery()->get_center()));
sgCopyMat4(UP, _location->getCachedUpMatrix());
sgCopyVec3(_world_up, _location->get_world_up());
// these are the vectors that the sun and moon code like to get...
return _fov_deg;
} else {
// v_fov == fov
- return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) / _aspect_ratio) *
- SG_RADIANS_TO_DEGREES * 2;
+ return
+ atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+ / (_aspect_ratio*_aspect_ratio_multiplier))
+ * SG_RADIANS_TO_DEGREES * 2;
}
default:
assert(false);
{
switch (_scaling_type) {
case FG_SCALING_WIDTH: // h_fov == fov
- return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) * _aspect_ratio) *
- SG_RADIANS_TO_DEGREES * 2;
+ return
+ atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+ * (_aspect_ratio*_aspect_ratio_multiplier))
+ * SG_RADIANS_TO_DEGREES * 2;
case FG_SCALING_MAX:
if (_aspect_ratio < 1.0) {
// h_fov == fov
- return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) * _aspect_ratio) *
- SG_RADIANS_TO_DEGREES * 2;
+ return
+ atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+ * (_aspect_ratio*_aspect_ratio_multiplier))
+ * SG_RADIANS_TO_DEGREES * 2;
} else {
// v_fov == fov
return _fov_deg;