mat3[0][1] = tmp * axis3[1] + s * axis3[2] ;
mat3[0][2] = tmp * axis3[2] - s * axis3[1] ;
- tmp = t * axis2[1];
+ tmp = t * axis3[1];
mat3[1][0] = tmp * axis3[0] - s * axis3[2] ;
mat3[1][1] = tmp * axis3[1] + c ;
mat3[1][2] = tmp * axis3[2] + s * axis3[0] ;
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;
return _relative_view_pos;
}
-float *
-FGViewer::getZeroElevViewPos ()
-{
- if (_dirty)
- recalc();
- return _zero_elev_view_pos;
-}
-
void
FGViewer::updateFromModelLocation (SGLocation * location)
{
- sgCopyMat4(LOCAL, location->getCachedTransformMatrix());
+ sgCopyMat4(LOCAL, location->getTransformMatrix());
}
void
FGViewer::updateAtModelLocation (SGLocation * location)
{
- sgCopyMat4(ATLOCAL,
- location->getCachedTransformMatrix());
+ sgCopyMat4(ATLOCAL, location->getTransformMatrix());
}
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()));
+ sgCopyMat4(LOCAL, location->getTransformMatrix());
}
// 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]);
- sgdSubVec3(dVec3,
- _target_location->get_absolute_view_pos(globals->get_scenery()->get_center()),
- dVec3 );
+ sgdSetVec3(dVec3, center[0], center[1], center[2]);
+ sgdSubVec3(dVec3, _target_location->get_absolute_view_pos(), dVec3 );
sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]);
// Update location data for eye...
_roll_deg, _pitch_deg, _heading_deg );
}
// save the eye positon...
- sgCopyVec3(eye_pos, _location->get_view_pos());
+ sgCopyVec3(eye_pos, _location->get_view_pos(center));
// copy data from location class to local items...
copyLocationData();
void
FGViewer::copyLocationData()
{
+ Point3D center = globals->get_scenery()->get_center();
// Get our friendly vectors from the eye location...
- 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()));
+ sgdCopyVec3(_absolute_view_pos, _location->get_absolute_view_pos());
+ sgCopyVec3(_relative_view_pos, _location->get_view_pos(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...
}
// copy coordinates to outputs for viewer...
- sgCopyVec3(_zero_elev, _zero_elev_view_pos);
+ sgCopyVec3(_zero_elev, _relative_view_pos);
+ sgAddScaledVec3(_zero_elev, _world_up, -_alt_ft*SG_FEET_TO_METER);
sgCopyVec3(_view_pos, _relative_view_pos);
}
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;