- if (_type == FG_RPH) {
-
- // code to calculate LOCAL matrix calculated from Phi, Theta, and
- // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
- // flight model
-
- fgMakeLOCAL( LOCAL, _pitch_deg * SG_DEGREES_TO_RADIANS,
- _roll_deg * SG_DEGREES_TO_RADIANS,
- -_heading_deg * SG_DEGREES_TO_RADIANS);
-
- // Make the world up rotation matrix for pilot view
- sgMakeRotMat4( UP, _lon_deg, 0.0, -_lat_deg );
-
- // get the world up verctor from the worldup rotation matrix
- sgSetVec3( world_up, UP[0][0], UP[0][1], UP[0][2] );
-
- // VIEWo becomes the rotation matrix with world_up incorporated
- sgCopyMat4( VIEWo, LOCAL );
- sgPostMultMat4( VIEWo, UP );
-
- // generate the sg view up and forward vectors
- sgSetVec3( view_up, VIEWo[0][0], VIEWo[0][1], VIEWo[0][2] );
- sgSetVec3( right, VIEWo[1][0], VIEWo[1][1], VIEWo[1][2] );
- sgSetVec3( forward, VIEWo[2][0], VIEWo[2][1], VIEWo[2][2] );
-
- // apply the offsets in world coordinates
- sgVec3 pilot_offset_world;
- sgSetVec3( pilot_offset_world,
- _z_offset_m, _y_offset_m, -_x_offset_m );
- sgXformVec3( pilot_offset_world, pilot_offset_world, VIEWo );
-
- // generate the view offset matrix using orientation offset (heading)
- sgMakeRotMat4( VIEW_OFFSET, _heading_offset_deg, view_up );
-
- // create a tilt matrix using orientation offset (pitch)
- sgMat4 VIEW_TILT;
- sgMakeRotMat4( VIEW_TILT, _pitch_offset_deg, right );
- sgPreMultMat4(VIEW_OFFSET, VIEW_TILT);
- sgXformVec3( view_forward, forward, VIEW_OFFSET );
- SG_LOG( SG_VIEW, SG_DEBUG, "(RPH) view forward = "
- << view_forward[0] << "," << view_forward[1] << ","
- << view_forward[2] );
-
- // VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
- fgMakeViewRot( VIEW_ROT, VIEW_OFFSET, VIEWo );
-
- sgVec3 trans_vec;
- sgAddVec3( trans_vec, view_pos, pilot_offset_world );
-
- // VIEW = VIEW_ROT * TRANS
- sgCopyMat4( VIEW, VIEW_ROT );
- sgPostMultMat4ByTransMat4( VIEW, trans_vec );