Woohoo! some success with external views ...
This commit is contained in:
parent
49aab2af8e
commit
8aab71034a
4 changed files with 37 additions and 180 deletions
|
@ -83,7 +83,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
int speed;
|
||||
|
||||
FGInterface *f = current_aircraft.fdm_state;
|
||||
FGViewerRPH *v = (FGViewerRPH *)globals->get_current_view();
|
||||
FGViewer *v = globals->get_current_view();
|
||||
|
||||
FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
|
||||
if ( puKeyboard(k, PU_DOWN) ) {
|
||||
|
@ -153,75 +153,27 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
return;
|
||||
case 49: // numeric keypad 1
|
||||
v->set_goal_view_offset( FG_PI * 0.75 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.75 );
|
||||
}
|
||||
return;
|
||||
case 50: // numeric keypad 2
|
||||
v->set_goal_view_offset( FG_PI );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, 0.0, 1.0);
|
||||
v->set_view_offset( FG_PI );
|
||||
}
|
||||
return;
|
||||
case 51: // numeric keypad 3
|
||||
v->set_goal_view_offset( FG_PI * 1.25 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.25 );
|
||||
}
|
||||
return;
|
||||
case 52: // numeric keypad 4
|
||||
v->set_goal_view_offset( FG_PI * 0.50 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(0.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.50 );
|
||||
}
|
||||
return;
|
||||
case 54: // numeric keypad 6
|
||||
v->set_goal_view_offset( FG_PI * 1.50 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(0.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.50 );
|
||||
}
|
||||
return;
|
||||
case 55: // numeric keypad 7
|
||||
v->set_goal_view_offset( FG_PI * 0.25 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.25 );
|
||||
}
|
||||
return;
|
||||
case 56: // numeric keypad 8
|
||||
v->set_goal_view_offset( 0.00 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, 0.0, 1.0);
|
||||
v->set_view_offset( 0.00 );
|
||||
}
|
||||
return;
|
||||
case 57: // numeric keypad 9
|
||||
v->set_goal_view_offset( FG_PI * 1.75 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.75 );
|
||||
}
|
||||
return;
|
||||
case 65: // A key
|
||||
speed = globals->get_options()->get_speed_up();
|
||||
|
@ -419,23 +371,6 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
return;
|
||||
case 118: // v key
|
||||
globals->set_current_view( globals->get_viewmgr()->next_view() );
|
||||
#if 0
|
||||
// globals->get_options()->cycle_view_mode();
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_options()->set_view_mode(FGOptions::FG_VIEW_PILOT);
|
||||
v->set_goal_view_offset( 0.0 );
|
||||
v->set_view_offset( 0.0 );
|
||||
} else if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_PILOT )
|
||||
{
|
||||
globals->get_options()->set_view_mode( FGOptions::FG_VIEW_FOLLOW );
|
||||
v->set_goal_view_offset( FG_PI * 1.75 );
|
||||
v->set_view_offset( FG_PI * 1.75 );
|
||||
globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
fgReshape( globals->get_options()->get_xsize(),
|
||||
globals->get_options()->get_ysize() );
|
||||
return;
|
||||
|
@ -474,7 +409,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
|
||||
// Handle "special" keyboard events
|
||||
void GLUTspecialkey(int k, int x, int y) {
|
||||
FGViewerRPH *v = (FGViewerRPH *)globals->get_current_view();
|
||||
FGViewer *v = globals->get_current_view();
|
||||
|
||||
FG_LOG( FG_INPUT, FG_DEBUG, "Special key hit = " << k );
|
||||
|
||||
|
@ -556,75 +491,27 @@ void GLUTspecialkey(int k, int x, int y) {
|
|||
}
|
||||
case GLUT_KEY_END: // numeric keypad 1
|
||||
v->set_goal_view_offset( FG_PI * 0.75 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW)
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.75 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_DOWN: // numeric keypad 2
|
||||
v->set_goal_view_offset( FG_PI );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, 0.0, 1.0);
|
||||
v->set_view_offset( FG_PI );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
|
||||
v->set_goal_view_offset( FG_PI * 1.25 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW)
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(-25.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.25 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_LEFT: // numeric keypad 4
|
||||
v->set_goal_view_offset( FG_PI * 0.50 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(0.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.50 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_RIGHT: // numeric keypad 6
|
||||
v->set_goal_view_offset( FG_PI * 1.50 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(0.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.50 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_HOME: // numeric keypad 7
|
||||
v->set_goal_view_offset( FG_PI * 0.25 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, 25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 0.25 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_UP: // numeric keypad 8
|
||||
v->set_goal_view_offset( 0.00 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, 0.0, 1.0);
|
||||
v->set_view_offset( 0.00 );
|
||||
}
|
||||
return;
|
||||
case GLUT_KEY_PAGE_UP: // numeric keypad 9
|
||||
v->set_goal_view_offset( FG_PI * 1.75 );
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
|
||||
v->set_view_offset( FG_PI * 1.75 );
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -341,12 +341,16 @@ void fgRenderFrame( void ) {
|
|||
|
||||
sgVec3 po; // chase view pilot_offset
|
||||
sgVec3 wup; // chase view world up
|
||||
sgSetVec3( po, 0.0, 0.0, 200.0 );
|
||||
sgSetVec3( po, 0.0, 0.0, 50.0 );
|
||||
sgCopyVec3( wup, pilot_view->get_world_up() );
|
||||
// sgMat4 CXFM; // chase view + pilot offset xform
|
||||
// sgMakeRotMat4( CXFM, cur_fdm_state->get_Psi() * RAD_TO_DEG, wup );
|
||||
// sgVec3 npo; // new pilot offset after rotation
|
||||
// sgXformVec3( npo, po, CXFM );
|
||||
sgMat4 CXFM; // chase view + pilot offset xform
|
||||
sgMakeRotMat4( CXFM,
|
||||
chase_view->get_view_offset() * RAD_TO_DEG -
|
||||
cur_fdm_state->get_Psi() * RAD_TO_DEG,
|
||||
wup );
|
||||
sgVec3 npo; // new pilot offset after rotation
|
||||
sgXformVec3( po, po, pilot_view->get_UP() );
|
||||
sgXformVec3( npo, po, CXFM );
|
||||
|
||||
chase_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
|
||||
cur_fdm_state->get_Lat_geocentric(),
|
||||
|
@ -355,26 +359,11 @@ void fgRenderFrame( void ) {
|
|||
chase_view->set_sea_level_radius( cur_fdm_state->
|
||||
get_Sea_level_radius() *
|
||||
FEET_TO_METER );
|
||||
chase_view->set_pilot_offset( po[0], po[1], po[2] );
|
||||
sgVec3 negpo;
|
||||
sgNegateVec3( negpo, po );
|
||||
chase_view->set_view_forward( negpo );
|
||||
chase_view->set_pilot_offset( npo[0], npo[1], npo[2] );
|
||||
chase_view->set_view_forward( pilot_view->get_view_pos() );
|
||||
chase_view->set_view_up( wup );
|
||||
|
||||
#if 0
|
||||
// this is a test, we are trying to match RPH and LookAt
|
||||
// matrices
|
||||
chase_view->set_geod_view_pos( cur_fdm_state->get_Longitude(),
|
||||
cur_fdm_state->get_Lat_geocentric(),
|
||||
cur_fdm_state->get_Altitude() *
|
||||
FEET_TO_METER );
|
||||
chase_view->set_sea_level_radius( cur_fdm_state->
|
||||
get_Sea_level_radius() *
|
||||
FEET_TO_METER );
|
||||
chase_view->set_view_forward( pilot_view->get_view_forward() );
|
||||
chase_view->set_view_up( pilot_view->get_view_up() );
|
||||
#endif
|
||||
|
||||
sgMat4 rph;
|
||||
sgCopyMat4( rph, pilot_view->get_VIEW() );
|
||||
cout << "RPH Matrix = " << endl;
|
||||
|
@ -395,22 +384,9 @@ void fgRenderFrame( void ) {
|
|||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// update view volume parameters
|
||||
// cout << "before pilot_view update" << endl;
|
||||
#if 0
|
||||
if ( globals->get_options()->get_view_mode() ==
|
||||
FGOptions::FG_VIEW_FOLLOW )
|
||||
{
|
||||
float * offset = globals->get_current_view()->get_pilot_offset();
|
||||
globals->get_current_view()->set_pilot_offset( offset[0],
|
||||
offset[1],
|
||||
offset[2] );
|
||||
} else {
|
||||
globals->get_current_view()->set_pilot_offset(0.0, 0.0, 0.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// update view port
|
||||
if ( ! fgPanelVisible() ) {
|
||||
xglViewport( 0, 0 ,
|
||||
(GLint)(globals->get_options()->get_xsize()),
|
||||
|
@ -737,39 +713,32 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
|
|||
}
|
||||
|
||||
// update the view angle
|
||||
FGViewer *v = globals->get_current_view();
|
||||
for ( i = 0; i < multi_loop; i++ ) {
|
||||
if ( fabs(globals->get_current_view()->get_goal_view_offset() -
|
||||
globals->get_current_view()->get_view_offset()) < 0.05 )
|
||||
{
|
||||
globals->get_current_view()->set_view_offset( globals->get_current_view()->get_goal_view_offset() );
|
||||
if ( fabs(v->get_goal_view_offset() - v->get_view_offset()) < 0.05 ) {
|
||||
v->set_view_offset( v->get_goal_view_offset() );
|
||||
break;
|
||||
} else {
|
||||
// move current_view.view_offset towards
|
||||
// current_view.goal_view_offset
|
||||
if ( globals->get_current_view()->get_goal_view_offset() >
|
||||
globals->get_current_view()->get_view_offset() )
|
||||
if ( v->get_goal_view_offset() > v->get_view_offset() )
|
||||
{
|
||||
if ( globals->get_current_view()->get_goal_view_offset() -
|
||||
globals->get_current_view()->get_view_offset() < FG_PI )
|
||||
{
|
||||
globals->get_current_view()->inc_view_offset( 0.01 );
|
||||
if ( v->get_goal_view_offset() - v->get_view_offset() < FG_PI ){
|
||||
v->inc_view_offset( 0.01 );
|
||||
} else {
|
||||
globals->get_current_view()->inc_view_offset( -0.01 );
|
||||
v->inc_view_offset( -0.01 );
|
||||
}
|
||||
} else {
|
||||
if ( globals->get_current_view()->get_view_offset() -
|
||||
globals->get_current_view()->get_goal_view_offset() <
|
||||
FG_PI )
|
||||
{
|
||||
globals->get_current_view()->inc_view_offset( -0.01 );
|
||||
if ( v->get_view_offset() - v->get_goal_view_offset() < FG_PI ){
|
||||
v->inc_view_offset( -0.01 );
|
||||
} else {
|
||||
globals->get_current_view()->inc_view_offset( 0.01 );
|
||||
v->inc_view_offset( 0.01 );
|
||||
}
|
||||
}
|
||||
if ( globals->get_current_view()->get_view_offset() > FG_2PI ) {
|
||||
globals->get_current_view()->inc_view_offset( -FG_2PI );
|
||||
} else if ( globals->get_current_view()->get_view_offset() < 0 ) {
|
||||
globals->get_current_view()->inc_view_offset( FG_2PI );
|
||||
if ( v->get_view_offset() > FG_2PI ) {
|
||||
v->inc_view_offset( -FG_2PI );
|
||||
} else if ( v->get_view_offset() < 0 ) {
|
||||
v->inc_view_offset( FG_2PI );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,19 +135,19 @@ void FGViewerLookAt::update() {
|
|||
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "sea level radius = " << sea_level_radius );
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
|
||||
FG_LOG( FG_VIEW, FG_INFO, "Absolute view pos = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = "
|
||||
<< abs_view_pos[0] << ","
|
||||
<< abs_view_pos[1] << ","
|
||||
<< abs_view_pos[2] );
|
||||
FG_LOG( FG_VIEW, FG_INFO, "Relative view pos = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
|
||||
<< view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
|
||||
FG_LOG( FG_VIEW, FG_INFO, "pilot offset = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "pilot offset = "
|
||||
<< pilot_offset[0] << "," << pilot_offset[1] << ","
|
||||
<< pilot_offset[2] );
|
||||
FG_LOG( FG_VIEW, FG_INFO, "view forward = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "view forward = "
|
||||
<< view_forward[0] << "," << view_forward[1] << ","
|
||||
<< view_forward[2] );
|
||||
FG_LOG( FG_VIEW, FG_INFO, "view up = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "view up = "
|
||||
<< view_up[0] << "," << view_up[1] << ","
|
||||
<< view_up[2] );
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ void FGViewerRPH::update() {
|
|||
<< abs_view_pos[0] << ","
|
||||
<< abs_view_pos[1] << ","
|
||||
<< abs_view_pos[2] );
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) Relative view pos = "
|
||||
<< view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
|
||||
|
||||
// code to calculate LOCAL matrix calculated from Phi, Theta, and
|
||||
|
@ -275,8 +275,9 @@ void FGViewerRPH::update() {
|
|||
// cout << "VIEW_OFFSET matrix" << endl;
|
||||
// print_sgMat4( VIEW_OFFSET );
|
||||
sgXformVec3( view_forward, forward, VIEW_OFFSET );
|
||||
// cout << "view_forward = " << view_forward[0] << ","
|
||||
// << view_forward[1] << "," << view_forward[2] << endl;
|
||||
FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) view forward = "
|
||||
<< view_forward[0] << "," << view_forward[1] << ","
|
||||
<< view_forward[2] );
|
||||
|
||||
// VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
|
||||
#ifdef USE_FAST_VIEWROT
|
||||
|
|
Loading…
Add table
Reference in a new issue