1
0
Fork 0

Some changes contributed by David Megginson to allow for more interesting

external views.
This commit is contained in:
curt 2000-10-18 21:19:30 +00:00
parent 445c4bbdb1
commit 2eda8480e9
8 changed files with 140 additions and 13 deletions

View file

@ -1,5 +1,6 @@
#include "hud.hxx"
#include "panel.hxx"
#define DO_PANEL_HACK
@ -219,7 +220,7 @@ void HudLadder :: draw( void )
glEnable(GL_LINE_STIPPLE);
#ifdef DO_PANEL_HACK
glLineStipple( 1, current_options.get_panel_status() ? 0x0F0F : 0x00FF );
glLineStipple( 1, fgPanelVisible() ? 0x0F0F : 0x00FF );
#else
glLineStipple( 1, 0x00FF );
#endif

View file

@ -41,6 +41,15 @@
#include "panel.hxx"
bool
fgPanelVisible ()
{
return ((current_options.get_panel_status()) &&
(current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) &&
(current_view.get_view_offset() == 0.0));
}
////////////////////////////////////////////////////////////////////////
// Implementation of FGTextureManager.
@ -125,7 +134,7 @@ FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
_width(_winw), _height(int(_winh * 0.5768 + 1)),
_x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
{
setVisibility(current_options.get_panel_status());
setVisibility(fgPanelVisible());
}
@ -160,7 +169,7 @@ void
FGPanel::update () const
{
// Do nothing if the panel isn't visible.
if (!_visibility)
if (!fgPanelVisible())
return;
// If the mouse is down, do something

View file

@ -567,6 +567,14 @@ private:
};
////////////////////////////////////////////////////////////////////////
// Functions.
////////////////////////////////////////////////////////////////////////
bool fgPanelVisible ();
////////////////////////////////////////////////////////////////////////
// The current panel, if any.

View file

@ -111,7 +111,8 @@ FGBFI::init ()
current_properties.tieDouble("/position/longitude",
getLongitude, setLongitude);
current_properties.tieDouble("/position/altitude",
getAltitude, setAltitude);
// getAltitude, setAltitude);
getAltitude, setAltitude, false);
current_properties.tieDouble("/position/altitude-agl",
getAGL, 0);
@ -234,6 +235,8 @@ FGBFI::init ()
current_properties.tieDouble("/environment/visibility",
getVisibility, setVisibility);
_needReinit = false;
FG_LOG(FG_GENERAL, FG_INFO, "Ending BFI init");
}

View file

@ -346,6 +346,15 @@ bool fgInitPosition( void ) {
fgFDMSetGroundElevation( current_options.get_flight_model(),
f->get_Altitude() * FEET_TO_METER );
#if 0
current_properties.setDoubleValue("/position/longitude",
f->get_Longitude() * RAD_TO_DEG);
current_properties.setDoubleValue("/position/latitude",
f->get_Latitude() * RAD_TO_DEG);
current_properties.setDoubleValue("/position/altitude",
f->get_Altitude() * RAD_TO_DEG);
#endif
FG_LOG( FG_GENERAL, FG_INFO,
"Initial position is: ("
<< (f->get_Longitude() * RAD_TO_DEG) << ", "

View file

@ -158,27 +158,59 @@ 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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.75 );
}
return;
case 65: // A key
speed = current_options.get_speed_up();
@ -375,7 +407,20 @@ void GLUTkey(unsigned char k, int x, int y) {
fgUpdateSkyAndLightingParams();
return;
case 118: // v key
current_options.cycle_view_mode();
// current_options.cycle_view_mode();
if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
current_options.set_view_mode(fgOPTIONS::FG_VIEW_PILOT);
v->set_goal_view_offset( 0.0 );
v->set_view_offset( 0.0 );
} else if (current_options.get_view_mode() ==
fgOPTIONS::FG_VIEW_PILOT) {
current_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 );
pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
}
fgReshape( current_view.get_winWidth(),
current_view.get_winHeight() );
return;
case 120: // x key
fov = current_options.get_fov();
@ -496,27 +541,59 @@ 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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_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 (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.75 );
}
return;
}
} else {

View file

@ -308,6 +308,12 @@ void fgRenderFrame( void ) {
// update view volume parameters
// cout << "before pilot_view update" << endl;
if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW ) {
float * offset = pilot_view.get_pilot_offset();
current_view.set_pilot_offset(offset[0], offset[1], offset[2]);
} else {
current_view.set_pilot_offset(0.0, 0.0, 0.0);
}
pilot_view.UpdateViewParams(*cur_fdm_state);
// cout << "after pilot_view update" << endl;
current_view.UpdateViewParams(cur_view_fdm);
@ -1106,7 +1112,7 @@ static void fgIdleFunction ( void ) {
// options.cxx needs to see this for toggle_panel()
// Handle new window size or exposure
void fgReshape( int width, int height ) {
if ( ! current_options.get_panel_status() || idle_state != 1000 ) {
if ( ! fgPanelVisible() || idle_state != 1000 ) {
current_view.set_win_ratio( (float)height / (float)width );
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
} else {
@ -1410,8 +1416,8 @@ int main( int argc, char **argv ) {
//
FGPath modelpath( current_options.get_fg_root() );
modelpath.append( "Models" );
modelpath.append( "Geometry" );
// modelpath.append( "Models" );
// modelpath.append( "Geometry" );
FGPath texturepath( current_options.get_fg_root() );
texturepath.append( "Models" );
@ -1466,11 +1472,25 @@ int main( int argc, char **argv ) {
// temporary visible aircraft "own ship"
penguin_sel = new ssgSelector;
penguin_pos = new ssgTransform;
// ssgBranch *tux_obj = ssgMakeSphere( 10.0, 10, 10 );
ssgEntity *tux_obj = ssgLoadAC( "glider.ac" );
// ssgEntity *tux_obj = ssgLoadAC( "Tower1x.ac" );
string tux_path =
current_properties.getStringValue("/sim/model/path",
"Models/Geometry/glider.ac");
ssgEntity *tux_obj = ssgLoad((char *)(tux_path.c_str()));
penguin_pos->addKid( tux_obj );
// align the model properly for FGFS
ssgTransform *tux_align = new ssgTransform;
tux_align->addKid(tux_obj);
sgMat4 tux_matrix;
float h_rot =
current_properties.getFloatValue("/sim/model/h-rotation", 0.0);
float p_rot =
current_properties.getFloatValue("/sim/model/p-rotation", 0.0);
float r_rot =
current_properties.getFloatValue("/sim/model/r-rotation", 0.0);
sgMakeRotMat4(tux_matrix, h_rot, h_rot, r_rot);
tux_align->setTransform(tux_matrix);
penguin_pos->addKid( tux_align );
penguin_sel->addKid( penguin_pos );
ssgFlatten( tux_obj );
ssgStripify( penguin_sel );

View file

@ -166,7 +166,7 @@ inline static void fgMakeLOCAL( sgMat4 dst, const double Theta,
void FGView::UpdateViewParams( const FGInterface& f ) {
UpdateViewMath(f);
if ( ! current_options.get_panel_status() ) {
if ( ! fgPanelVisible() ) {
xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) );
} else {
int view_h =