1
0
Fork 0

Harald JOHNSEN:

Changes
=======

New volumetric shadows for FlightGear.

There is now two new checkboxes in the rendering dialog to enable/disable shadows
for the user aircraft and for static scenery objects (ie those defined in the .stg files).
AI and random objects are not handled for the moment.


known bugs
==========
- ghost objects
This commit is contained in:
ehofman 2005-06-26 17:21:18 +00:00
parent 8e5eed90d5
commit f2cf76171f
3 changed files with 34 additions and 1 deletions

View file

@ -51,6 +51,8 @@
#include <simgear/environment/visual_enviro.hxx> #include <simgear/environment/visual_enviro.hxx>
#include <simgear/scene/model/shadowvolume.hxx>
#include <Scenery/tileentry.hxx> #include <Scenery/tileentry.hxx>
#include <Time/light.hxx> #include <Time/light.hxx>
#include <Time/light.hxx> #include <Time/light.hxx>
@ -115,6 +117,8 @@ ssgSimpleState *default_state;
ssgSimpleState *hud_and_panel; ssgSimpleState *hud_and_panel;
ssgSimpleState *menus; ssgSimpleState *menus;
SGShadowVolume *shadows;
FGRenderer::FGRenderer() FGRenderer::FGRenderer()
{ {
#ifdef FG_JPEG_SERVER #ifdef FG_JPEG_SERVER
@ -170,6 +174,11 @@ FGRenderer::build_states( void ) {
menus->disable( GL_CULL_FACE ); menus->disable( GL_CULL_FACE );
menus->disable( GL_TEXTURE_2D ); menus->disable( GL_TEXTURE_2D );
menus->enable( GL_BLEND ); menus->enable( GL_BLEND );
shadows = new SGShadowVolume;
shadows->init( fgGetNode("/sim/rendering", true) );
shadows->addOccluder( globals->get_scenery()->get_aircraft_branch(), SGShadowVolume::occluderTypeAircraft );
} }
@ -441,6 +450,14 @@ FGRenderer::update( bool refresh_camera_settings ) {
sstate.moon_dist = 40000.0 * moon_horiz_eff; sstate.moon_dist = 40000.0 * moon_horiz_eff;
thesky->reposition( sstate, delta_time_sec ); thesky->reposition( sstate, delta_time_sec );
shadows->setupShadows(
current__view->getLongitude_deg(),
current__view->getLatitude_deg(),
globals->get_time_params()->getGst(),
globals->get_ephem()->getSunRightAscension(),
globals->get_ephem()->getSunDeclination(),
l->get_sun_angle());
} }
glEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );
@ -680,6 +697,13 @@ FGRenderer::update( bool refresh_camera_settings ) {
- current__view->getHeadingOffset_deg(), - current__view->getHeadingOffset_deg(),
fgGetDouble("/velocities/airspeed-kt", 0.0)); fgGetDouble("/velocities/airspeed-kt", 0.0));
// compute shadows and project them on screen
bool is_internal = globals->get_current_view()->getInternal();
// draw before ac because ac internal rendering clear the depth buffer
if( is_internal )
shadows->endOfFrame();
if ( draw_otw ) { if ( draw_otw ) {
FGTileMgr::set_tile_filter( false ); FGTileMgr::set_tile_filter( false );
sgSetModelFilter( false ); sgSetModelFilter( false );
@ -696,6 +720,8 @@ FGRenderer::update( bool refresh_camera_settings ) {
sgSetModelFilter( true ); sgSetModelFilter( true );
globals->get_aircraft_model()->select( true ); globals->get_aircraft_model()->select( true );
} }
if( !is_internal )
shadows->endOfFrame();
// display HUD && Panel // display HUD && Panel
glDisable( GL_FOG ); glDisable( GL_FOG );

View file

@ -39,7 +39,7 @@ public:
// even know what many of them do, but they're pure virtual and // even know what many of them do, but they're pure virtual and
// require implementation. // require implementation.
// //
virtual int getNumTriangles() { die(); return 0; } virtual int getNumTriangles() { return 0; }
virtual void getTriangle(int n, short* v1, short* v2, short* v3) { die(); } virtual void getTriangle(int n, short* v1, short* v2, short* v3) { die(); }
virtual int getNumLines() { die(); return 0; } virtual int getNumLines() { die(); return 0; }
virtual void getLine(int n, short* v1, short* v2) { die(); } virtual void getLine(int n, short* v1, short* v2) { die(); }

View file

@ -35,6 +35,7 @@
#include <simgear/math/vector.hxx> #include <simgear/math/vector.hxx>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include <simgear/scene/model/modellib.hxx> #include <simgear/scene/model/modellib.hxx>
#include <simgear/scene/model/shadowvolume.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
@ -57,6 +58,8 @@ queue<FGTileEntry *> FGTileMgr::delete_queue;
bool FGTileMgr::tile_filter = true; bool FGTileMgr::tile_filter = true;
extern SGShadowVolume *shadows;
// Constructor // Constructor
FGTileMgr::FGTileMgr(): FGTileMgr::FGTileMgr():
state( Start ), state( Start ),
@ -124,6 +127,7 @@ void FGTileMgr::sched_tile( const SGBucket& b, const bool is_inner_ring ) {
long index = tile_cache.get_oldest_tile(); long index = tile_cache.get_oldest_tile();
if ( index >= 0 ) { if ( index >= 0 ) {
FGTileEntry *old = tile_cache.get_tile( index ); FGTileEntry *old = tile_cache.get_tile( index );
shadows->deleteOccluderFromTile( (ssgBranch *) old->get_terra_transform() );
old->disconnect_ssg_nodes(); old->disconnect_ssg_nodes();
delete_queue.push( old ); delete_queue.push( old );
tile_cache.clear_entry( index ); tile_cache.clear_entry( index );
@ -315,6 +319,9 @@ void FGTileMgr::update_queues()
globals->get_sim_time_sec() ); globals->get_sim_time_sec() );
if ( obj_model != NULL ) { if ( obj_model != NULL ) {
dm->get_obj_trans()->addKid( obj_model ); dm->get_obj_trans()->addKid( obj_model );
shadows->addOccluder( (ssgBranch *) obj_model->getParent(0),
SGShadowVolume::occluderTypeTileObject,
(ssgBranch *) dm->get_tile()->get_terra_transform());
} }
} catch (const sg_exception& exc) { } catch (const sg_exception& exc) {
SG_LOG( SG_ALL, SG_ALERT, exc.getMessage() ); SG_LOG( SG_ALL, SG_ALERT, exc.getMessage() );