Added support for a pilot view offset vector from the center of gravity.
This commit is contained in:
parent
38999ec3e0
commit
038b68153e
2 changed files with 21 additions and 2 deletions
|
@ -66,6 +66,7 @@ void FGView::Init( void ) {
|
||||||
|
|
||||||
view_offset = 0.0;
|
view_offset = 0.0;
|
||||||
goal_view_offset = 0.0;
|
goal_view_offset = 0.0;
|
||||||
|
sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
|
||||||
|
|
||||||
winWidth = current_options.get_xsize();
|
winWidth = current_options.get_xsize();
|
||||||
winHeight = current_options.get_ysize();
|
winHeight = current_options.get_ysize();
|
||||||
|
@ -227,6 +228,12 @@ void FGView::UpdateViewMath( const FGInterface& f ) {
|
||||||
sgSetVec3( vec1, 1.0, 0.0, 0.0 );
|
sgSetVec3( vec1, 1.0, 0.0, 0.0 );
|
||||||
sgXformVec3( view_up, vec1, VIEWo );
|
sgXformVec3( view_up, vec1, VIEWo );
|
||||||
|
|
||||||
|
// generate the pilot offset vector in world coordinates
|
||||||
|
sgVec3 pilot_offset_world;
|
||||||
|
sgSetVec3( vec1,
|
||||||
|
pilot_offset[2], pilot_offset[1], -pilot_offset[0] );
|
||||||
|
sgXformVec3( pilot_offset_world, vec1, VIEWo );
|
||||||
|
|
||||||
// generate the view offset matrix
|
// generate the view offset matrix
|
||||||
sgMakeRotMat4( VIEW_OFFSET, view_offset * RAD_TO_DEG, view_up );
|
sgMakeRotMat4( VIEW_OFFSET, view_offset * RAD_TO_DEG, view_up );
|
||||||
// cout << "VIEW_OFFSET matrix" << endl;
|
// cout << "VIEW_OFFSET matrix" << endl;
|
||||||
|
@ -237,7 +244,10 @@ void FGView::UpdateViewMath( const FGInterface& f ) {
|
||||||
// cout << "VIEW_ROT matrix" << endl;
|
// cout << "VIEW_ROT matrix" << endl;
|
||||||
// print_sgMat4( VIEW_ROT );
|
// print_sgMat4( VIEW_ROT );
|
||||||
|
|
||||||
sgMakeTransMat4( TRANS, view_pos.x(), view_pos.y(), view_pos.z() );
|
sgMakeTransMat4( TRANS,
|
||||||
|
view_pos.x() + pilot_offset_world[0],
|
||||||
|
view_pos.y() + pilot_offset_world[1],
|
||||||
|
view_pos.z() + pilot_offset_world[2] );
|
||||||
|
|
||||||
sgMultMat4( VIEW, VIEW_ROT, TRANS );
|
sgMultMat4( VIEW, VIEW_ROT, TRANS );
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,11 @@ public:
|
||||||
// view position translated to scenery.center
|
// view position translated to scenery.center
|
||||||
Point3D view_pos;
|
Point3D view_pos;
|
||||||
|
|
||||||
|
// pilot offset from center of gravity. The X axis is positive
|
||||||
|
// out the tail, Y is out the right wing, and Z is positive up.
|
||||||
|
// Distances in meters of course.
|
||||||
|
sgVec3 pilot_offset;
|
||||||
|
|
||||||
// cartesion coordinates of current lon/lat if at sea level
|
// cartesion coordinates of current lon/lat if at sea level
|
||||||
// translated to scenery.center
|
// translated to scenery.center
|
||||||
Point3D cur_zero_elev;
|
Point3D cur_zero_elev;
|
||||||
|
@ -200,9 +205,13 @@ public:
|
||||||
inline void set_tris_culled( int tris) { tris_culled = tris; }
|
inline void set_tris_culled( int tris) { tris_culled = tris; }
|
||||||
inline Point3D get_abs_view_pos() const { return abs_view_pos; }
|
inline Point3D get_abs_view_pos() const { return abs_view_pos; }
|
||||||
inline Point3D get_view_pos() const { return view_pos; }
|
inline Point3D get_view_pos() const { return view_pos; }
|
||||||
|
inline float *get_pilot_offset() { return pilot_offset; }
|
||||||
|
inline void set_pilot_offset( float x, float y, float z ) {
|
||||||
|
sgSetVec3( pilot_offset, x, y, z );
|
||||||
|
}
|
||||||
inline Point3D get_cur_zero_elev() const { return cur_zero_elev; }
|
inline Point3D get_cur_zero_elev() const { return cur_zero_elev; }
|
||||||
inline float *get_to_sun() { return to_sun; }
|
inline float *get_to_sun() { return to_sun; }
|
||||||
inline void set_to_sun( float x, float y, float z) {
|
inline void set_to_sun( float x, float y, float z ) {
|
||||||
sgSetVec3( to_sun, x, y, z );
|
sgSetVec3( to_sun, x, y, z );
|
||||||
}
|
}
|
||||||
inline float *get_surface_to_sun() { return surface_to_sun; }
|
inline float *get_surface_to_sun() { return surface_to_sun; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue