#include <Math/polar3d.hxx>
#include <Math/fg_random.h>
#include <Misc/fgpath.hxx>
+#ifdef FG_NETWORK_OLK
+#include <Network/network.h>
+#endif
+#include <Objects/materialmgr.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
#include <Time/event.hxx>
// ssg variables
ssgRoot *scene = NULL;
ssgBranch *terrain = NULL;
-ssgTransform *penguin = NULL;
+ssgSelector *penguin_sel = NULL;
+ssgTransform *penguin_pos = NULL;
// The following defines flight gear options. Because glutlib will also
// xglFogi (GL_FOG_MODE, GL_LINEAR);
xglFogi (GL_FOG_MODE, GL_EXP2);
- // Fog density is now set when the weather system is initialized
- // xglFogf (GL_FOG_DENSITY, w->fog_density);
if ( (current_options.get_fog() == 1) ||
(current_options.get_shading() == 0) ) {
// if fastest fog requested, or if flat shading force fastest
xglEnable( GL_DEPTH_TEST );
if ( current_options.get_fog() > 0 ) {
xglEnable( GL_FOG );
- xglFogfv (GL_FOG_COLOR, l->adj_fog_color);
+ xglFogi( GL_FOG_MODE, GL_EXP2 );
+ xglFogfv( GL_FOG_COLOR, l->adj_fog_color );
}
// set lighting parameters
- xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
- xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
+ xglLightfv( GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
+ xglLightfv( GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
// xglLightfv(GL_LIGHT0, GL_SPECULAR, white );
if ( current_options.get_textures() ) {
// xglMaterialfv (GL_FRONT, GL_DIFFUSE, white);
}
- global_tile_mgr.render();
+ // global_tile_mgr.render();
+
+ // ssg test
+
+ xglMatrixMode( GL_PROJECTION );
+ xglLoadIdentity();
+ ssgSetFOV( current_options.get_fov(), 0.0f );
+
+ double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
+ - scenery.cur_elev;
+
+ // FG_LOG( FG_ALL, FG_INFO, "visibility is "
+ // << current_weather.get_visibility() );
+
+ if ( agl > 10.0 ) {
+ // ssgSetNearFar( 10.0f, current_weather.get_visibility() );
+ ssgSetNearFar( 10.0f, 100000.0f );
+ } else {
+ // ssgSetNearFar( 0.5f, current_weather.get_visibility() );
+ ssgSetNearFar( 0.5f, 100000.0f );
+ }
+
+ sgMat4 sgVIEW;
+
+ while ( current_view.follow.size() > 400 ) {
+ current_view.follow.pop_front();
+ }
+
+ if ( current_view.view_mode == FGView::FG_VIEW_FIRST_PERSON ) {
+ // select current view matrix
+ sgCopyMat4( sgVIEW, current_view.sgVIEW );
+
+ // disable TuX
+ penguin_sel->select(0);
+ } else if ( current_view.view_mode == FGView::FG_VIEW_FOLLOW ) {
+ // select view matrix from front of view matrix queue
+ FGMat4Wrapper tmp = current_view.follow.front();
+ sgCopyMat4( sgVIEW, tmp.m );
+
+ // enable TuX and set up his position and orientation
+ penguin_sel->select(1);
+
+ sgMat4 sgTRANS;
+ sgMakeTransMat4( sgTRANS,
+ current_view.view_pos.x(),
+ current_view.view_pos.y(),
+ current_view.view_pos.z() );
+
+ sgVec3 ownship_up;
+ sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
+
+ sgMat4 sgROT;
+ sgMakeRotMat4( sgROT, -90.0, ownship_up );
+
+ sgMat4 sgTMP;
+ sgMat4 sgTUX;
+ sgMultMat4( sgTMP, sgROT, current_view.sgVIEW_ROT );
+ sgMultMat4( sgTUX, sgTMP, sgTRANS );
+
+ sgCoord tuxpos;
+ sgSetCoord( &tuxpos, sgTUX );
+ penguin_pos->setTransform( &tuxpos );
+ }
+
+ ssgSetCamera( sgVIEW );
+
+ // position tile nodes and update range selectors
+ global_tile_mgr.prep_ssg_nodes();
+
+ // force the default state so ssg can get back on track if
+ // we've changed things elsewhere
+ FGMaterialSlot m_slot;
+ FGMaterialSlot *m_ptr = &m_slot;
+ if ( material_mgr.find( "Default", m_ptr ) );
+ m_ptr->get_state()->force();
+
+ // draw the ssg scene
+ ssgCullAndDraw( scene );
xglDisable( GL_TEXTURE_2D );
xglDisable( GL_FOG );
xglDisable ( GL_BLEND ) ;
xglEnable( GL_FOG );
- // ssg test
-
- xglMatrixMode(GL_PROJECTION);
- xglLoadIdentity();
- ssgSetFOV(60.0f, 0.0f);
- ssgSetNearFar(1.0f, 14000.0f);
- sgMat4 sgTRANS;
-
- sgMakeTransMat4( sgTRANS,
- current_view.view_pos.x()
- + current_view.view_forward[0] * 20,
- current_view.view_pos.y()
- + current_view.view_forward[1] * 20,
- current_view.view_pos.z()
- + current_view.view_forward[2] * 20 );
-
- sgMat4 sgTMP;
- sgMat4 sgTUX;
- sgMultMat4( sgTMP, current_view.sgUP, sgTRANS );
- sgMultMat4( sgTUX, current_view.sgLARC_TO_SSG, sgTMP );
-
- sgCoord tuxpos;
- sgSetCoord( &tuxpos, sgTUX );
- penguin->setTransform( &tuxpos );
-
- sgMakeTransMat4( sgTRANS,
- current_view.view_pos.x(),
- current_view.view_pos.y(),
- current_view.view_pos.z() );
- sgMat4 sgVIEW;
- sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS );
- ssgSetCamera( sgVIEW );
- // ssgSetCamera( current_view.sgVIEW );
- ssgCullAndDraw( scene );
-
}
xglutSwapBuffers();
// printf("updating flight model x %d\n", multi_loop);
fgFDMUpdate( current_options.get_flight_model(),
- cur_fdm_state, multi_loop, remainder );
+ cur_fdm_state, multi_loop * 1, remainder );
} else {
fgFDMUpdate( current_options.get_flight_model(),
cur_fdm_state, 0, remainder );
// distribution) specifically from the ssg tux example
//
- ssgModelPath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
- ssgTexturePath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
- // ssgModelPath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
- // ssgTexturePath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
+ FGPath modelpath( current_options.get_fg_root() );
+ modelpath.append( "Models" );
+ modelpath.append( "Geometry" );
+
+ FGPath texturepath( current_options.get_fg_root() );
+ texturepath.append( "Models" );
+ texturepath.append( "Textures" );
+
+ ssgModelPath( (char *)modelpath.c_str() );
+ ssgTexturePath( (char *)texturepath.c_str() );
scene = new ssgRoot;
terrain = new ssgBranch;
terrain->setName( "Terrain" );
- penguin = new ssgTransform;
+ penguin_sel = new ssgSelector;
+ penguin_pos = new ssgTransform;
- ssgEntity *tux_obj = ssgLoadAC( "tuxedo.ac" );
- penguin->addKid( tux_obj );
+ // ssgEntity *tux_obj = ssgLoadAC( "glider.ac" );
+ ssgEntity *tux_obj = ssgLoadAC( "Tower1x.ac" );
+ penguin_pos->addKid( tux_obj );
+ penguin_sel->addKid( penguin_pos );
ssgFlatten( tux_obj );
- ssgStripify( penguin );
+ ssgStripify( penguin_sel );
+
+#ifdef FG_NETWORK_OLK
+ // Do the network intialization
+ printf("Multipilot mode %s\n", fg_net_init() );
+#endif
scene->addKid( terrain );
- scene->addKid( penguin );
+ scene->addKid( penguin_sel );
// pass control off to the master GLUT event handler
glutMainLoop();