+ // Orientation Offsets matrix
+ MakeVIEW_OFFSET( VIEW_OFFSET,
+ _heading_offset_deg * SG_DEGREES_TO_RADIANS, _view_up,
+ _pitch_offset_deg * SG_DEGREES_TO_RADIANS, right );
+
+ // Make the VIEW matrix.
+ sgSetVec4(VIEW[0], right[0], right[1], right[2],SG_ZERO);
+ sgSetVec4(VIEW[1], forward[0], forward[1], forward[2],SG_ZERO);
+ sgSetVec4(VIEW[2], _view_up[0], _view_up[1], _view_up[2],SG_ZERO);
+ sgSetVec4(VIEW[3], SG_ZERO, SG_ZERO, SG_ZERO,SG_ONE);
+
+ // rotate model or local matrix to get a matrix to apply Eye Position Offsets
+ sgMat4 VIEW_UP; // L0 forward L1 right L2 up
+ sgCopyVec4(VIEW_UP[0], LOCAL[1]);
+ sgCopyVec4(VIEW_UP[1], LOCAL[2]);
+ sgCopyVec4(VIEW_UP[2], LOCAL[0]);
+ sgZeroVec4(VIEW_UP[3]);
+
+ // Eye Position Offsets to vector
+ sgSetVec3( position_offset, _x_offset_m, _y_offset_m, _z_offset_m );
+ sgXformVec3( position_offset, position_offset, VIEW_UP);
+
+ // add the offsets including rotations to the translation vector
+ sgAddVec3( _view_pos, position_offset );
+
+ // multiply the OFFSETS (for heading and pitch) into the VIEW
+ sgPostMultMat4(VIEW, VIEW_OFFSET);
+
+ // add the position data to the matrix
+ sgSetVec4(VIEW[3], _view_pos[0], _view_pos[1], _view_pos[2],SG_ONE);