1
0
Fork 0

Merge branch 'next' of D:\Git_New\flightgear into next

This commit is contained in:
Vivian Meazza 2011-05-24 22:40:23 +01:00
commit 950769117b
7 changed files with 115 additions and 110 deletions

View file

@ -269,7 +269,7 @@ public:
_offset = n->getFloatValue("offset", offset); _offset = n->getFloatValue("offset", offset);
_min = n->getFloatValue("min", min); _min = n->getFloatValue("min", min);
_max = n->getFloatValue("max", max); _max = n->getFloatValue("max", max);
_coeff = 1.0 - 1.0 / powf(10, fabsf(n->getFloatValue("damp", 0.0))); _coeff = 1.0 - 1.0 / powf(10, fabs(n->getFloatValue("damp", 0.0)));
SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false); SGPropertyNode *p = ((SGPropertyNode *)n)->getNode("property", false);
if (p) { if (p) {
const char *path = p->getStringValue(); const char *path = p->getStringValue();

View file

@ -378,90 +378,99 @@ wxRadarBg::update (double delta_time_sec)
_texCoords->clear(); _texCoords->clear();
_textGeode->removeDrawables(0, _textGeode->getNumDrawables()); _textGeode->removeDrawables(0, _textGeode->getNumDrawables());
#if 0
//TODO FIXME Mask below (only used for ARC mode) isn't properly aligned, i.e.
// it assumes the a/c position at the center of the display - though it's somewhere at
// bottom part for ARC mode.
// The mask hadn't worked at all for a while (probably since the OSG port) due to
// another bug (which is fixed now). Now, the mask is disabled completely until s.o.
// adapted the coordinates below. And the mask is only really useful to limit displayed
// weather blobs (not support yet).
// Aircraft echos are already limited properly through wxradar's "limit-deg" property.
{
osg::DrawArrays *maskPSet
= static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(1));
osg::DrawArrays *trimaskPSet
= static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(2));
if (_display_mode == ARC) {
// erase what is out of sight of antenna
/*
|\ /|
| \ / |
| \ / |
---------
| |
| |
---------
*/
float xOffset = 256.0f;
float yOffset = 200.0f;
int firstQuadVert = _vertices->size();
_texCoords->push_back(osg::Vec2f(0.5f, 0.25f));
_vertices->push_back(osg::Vec2f(-xOffset, 0.0 + yOffset));
_texCoords->push_back(osg::Vec2f(1.0f, 0.25f));
_vertices->push_back(osg::Vec2f(xOffset, 0.0 + yOffset));
_texCoords->push_back(osg::Vec2f(1.0f, 0.5f));
_vertices->push_back(osg::Vec2f(xOffset, 256.0 + yOffset));
_texCoords->push_back(osg::Vec2f(0.5f, 0.5f));
_vertices->push_back(osg::Vec2f(-xOffset, 256.0 + yOffset));
maskPSet->set(osg::PrimitiveSet::QUADS, firstQuadVert, 4);
firstQuadVert += 4;
// The triangles aren't supposed to be textured, but there's
// no need to set up a different Geometry, switch modes,
// etc. I happen to know that there's a white pixel in the
// texture at 1.0, 0.0 :)
float centerY = tan(30 * SG_DEGREES_TO_RADIANS);
_vertices->push_back(osg::Vec2f(0.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, 256.0 * centerY));
_vertices->push_back(osg::Vec2f(0.0, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 256.0 * centerY));
_vertices->push_back(osg::Vec2f(-256, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, -256.0));
_vertices->push_back(osg::Vec2f(256, 0.0));
_vertices->push_back(osg::Vec2f(256.0, -256.0));
_vertices->push_back(osg::Vec2f(-256.0, -256.0));
const osg::Vec2f whiteSpot(1.0f, 0.0f);
for (int i = 0; i < 3 * 4; i++)
_texCoords->push_back(whiteSpot);
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, firstQuadVert, 3 * 4);
} else
{
maskPSet->set(osg::PrimitiveSet::QUADS, 0, 0);
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, 0, 0);
}
maskPSet->dirty();
trimaskPSet->dirty();
}
#endif
// remember index of next vertex
int vIndex = _vertices->size();
update_weather(); update_weather();
osg::DrawArrays *quadPSet osg::DrawArrays *quadPSet
= static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(0)); = static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(0));
quadPSet->set(osg::PrimitiveSet::QUADS, 0, _vertices->size());
quadPSet->dirty();
// erase what is out of sight of antenna
/*
|\ /|
| \ / |
| \ / |
---------
| |
| |
---------
*/
osg::DrawArrays *maskPSet
= static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(1));
osg::DrawArrays *trimaskPSet
= static_cast<osg::DrawArrays*>(_geom->getPrimitiveSet(2));
if (_display_mode == ARC) {
float xOffset = 256.0f;
float yOffset = 200.0f;
int firstQuadVert = _vertices->size();
_texCoords->push_back(osg::Vec2f(0.5f, 0.25f));
_vertices->push_back(osg::Vec2f(-xOffset, 0.0 + yOffset));
_texCoords->push_back(osg::Vec2f(1.0f, 0.25f));
_vertices->push_back(osg::Vec2f(xOffset, 0.0 + yOffset));
_texCoords->push_back(osg::Vec2f(1.0f, 0.5f));
_vertices->push_back(osg::Vec2f(xOffset, 256.0 + yOffset));
_texCoords->push_back(osg::Vec2f(0.5f, 0.5f));
_vertices->push_back(osg::Vec2f(-xOffset, 256.0 + yOffset));
maskPSet->set(osg::PrimitiveSet::QUADS, firstQuadVert, 4);
// The triangles aren't supposed to be textured, but there's
// no need to set up a different Geometry, switch modes,
// etc. I happen to know that there's a white pixel in the
// texture at 1.0, 0.0 :)
float centerY = tan(30 * SG_DEGREES_TO_RADIANS);
_vertices->push_back(osg::Vec2f(0.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, 256.0 * centerY));
_vertices->push_back(osg::Vec2f(0.0, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 256.0 * centerY));
_vertices->push_back(osg::Vec2f(-256, 0.0));
_vertices->push_back(osg::Vec2f(256.0, 0.0));
_vertices->push_back(osg::Vec2f(-256.0, -256.0));
_vertices->push_back(osg::Vec2f(256, 0.0));
_vertices->push_back(osg::Vec2f(256.0, -256.0));
_vertices->push_back(osg::Vec2f(-256.0, -256.0));
const osg::Vec2f whiteSpot(1.0f, 0.0f);
for (int i = 0; i < 3 * 4; i++)
_texCoords->push_back(whiteSpot);
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, firstQuadVert + 4, 3 * 4);
} else {
maskPSet->set(osg::PrimitiveSet::QUADS, 0, 0);
trimaskPSet->set(osg::PrimitiveSet::TRIANGLES, 0, 0);
}
maskPSet->dirty();
trimaskPSet->dirty();
// draw without mask
_vertices->clear();
_texCoords->clear();
update_aircraft(); update_aircraft();
update_tacan(); update_tacan();
update_heading_marker(); update_heading_marker();
quadPSet->set(osg::PrimitiveSet::QUADS, 0, _vertices->size()); // draw all new vertices are quads
quadPSet->set(osg::PrimitiveSet::QUADS, vIndex, _vertices->size()-vIndex);
quadPSet->dirty(); quadPSet->dirty();
} }
} }

View file

@ -306,6 +306,7 @@ void fgWarpMouse(int x, int y)
void fgOSInit(int* argc, char** argv) void fgOSInit(int* argc, char** argv)
{ {
globals->get_renderer()->init();
WindowSystemAdapter::setWSA(new WindowSystemAdapter); WindowSystemAdapter::setWSA(new WindowSystemAdapter);
} }

View file

@ -212,6 +212,7 @@ static void fgMainLoop( void ) {
} }
else else
{ {
fgSplashProgress("loading scenery");
// be nice to loader threads while waiting for initial scenery, reduce to 2fps // be nice to loader threads while waiting for initial scenery, reduce to 2fps
simgear::sleepForMSec(500); simgear::sleepForMSec(500);
} }
@ -314,7 +315,7 @@ SGPath resolve_path(const std::string& s)
} }
// This is the top level master main function that is registered as // This is the top level master main function that is registered as
// our idle funciton // our idle function
// The first few passes take care of initialization things (a couple // The first few passes take care of initialization things (a couple
// per pass) and once everything has been initialized fgMainLoop from // per pass) and once everything has been initialized fgMainLoop from
@ -348,20 +349,17 @@ static void fgIdleFunction ( void ) {
if (!guiFinishInit()) if (!guiFinishInit())
return; return;
idle_state++; idle_state++;
fgSplashProgress("reading aircraft list"); fgSplashProgress("loading aircraft list");
} else if ( idle_state == 2 ) { } else if ( idle_state == 2 ) {
idle_state++; idle_state++;
fgSplashProgress("loading navigation data");
fgSplashProgress("reading airport & navigation data");
} else if ( idle_state == 3 ) { } else if ( idle_state == 3 ) {
idle_state++; idle_state++;
fgInitNav(); fgInitNav();
fgSplashProgress("setting up scenery");
fgSplashProgress("initializing scenery system");
} else if ( idle_state == 4 ) { } else if ( idle_state == 4 ) {
idle_state++; idle_state++;
@ -386,14 +384,13 @@ static void fgIdleFunction ( void ) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
fgInitCommands(); fgInitCommands();
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialize the material manager // Initialize the material manager
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
globals->set_matlib( new SGMaterialLib ); globals->set_matlib( new SGMaterialLib );
simgear::SGModelLib::init(globals->get_fg_root(), globals->get_props()); simgear::SGModelLib::init(globals->get_fg_root(), globals->get_props());
simgear::SGModelLib::setPanelFunc(load_panel); simgear::SGModelLib::setPanelFunc(load_panel);
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialize the TG scenery subsystem. // Initialize the TG scenery subsystem.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -402,15 +399,12 @@ static void fgIdleFunction ( void ) {
globals->get_scenery()->bind(); globals->get_scenery()->bind();
globals->set_tile_mgr( new FGTileMgr ); globals->set_tile_mgr( new FGTileMgr );
fgSplashProgress("loading aircraft"); fgSplashProgress("loading aircraft");
} else if ( idle_state == 5 ) { } else if ( idle_state == 5 ) {
idle_state++; idle_state++;
fgSplashProgress("generating sky elements"); fgSplashProgress("initializing sky elements");
} else if ( idle_state == 6 ) { } else if ( idle_state == 6 ) {
idle_state++; idle_state++;
@ -471,10 +465,8 @@ static void fgIdleFunction ( void ) {
// airport->setName( "Airport Lighting" ); // airport->setName( "Airport Lighting" );
// lighting->addKid( airport ); // lighting->addKid( airport );
// build our custom render states
fgSplashProgress("initializing subsystems"); fgSplashProgress("initializing subsystems");
} else if ( idle_state == 7 ) { } else if ( idle_state == 7 ) {
idle_state++; idle_state++;
// Initialize audio support // Initialize audio support
@ -531,18 +523,18 @@ static void fgIdleFunction ( void ) {
fgSetPosFromAirportIDandHdg( apt, hdg ); fgSetPosFromAirportIDandHdg( apt, hdg );
} }
} }
fgSplashProgress("setting up time & renderer");
fgSplashProgress("initializing graphics engine");
} else if ( idle_state == 8 ) { } else if ( idle_state == 8 ) {
idle_state = 1000; idle_state = 1000;
// setup OpenGL view parameters // setup OpenGL view parameters
globals->get_renderer()->init(); globals->get_renderer()->setupView();
globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"), globals->get_renderer()->resize( fgGetInt("/sim/startup/xsize"),
fgGetInt("/sim/startup/ysize") ); fgGetInt("/sim/startup/ysize") );
fgSplashProgress("loading scenery objects");
int session = fgGetInt("/sim/session",0); int session = fgGetInt("/sim/session",0);
session++; session++;
fgSetInt("/sim/session",session); fgSetInt("/sim/session",session);
@ -673,5 +665,3 @@ int fgMainInit( int argc, char **argv ) {
return result; return result;
} }

View file

@ -440,7 +440,11 @@ FGRenderer::init( void )
_cloud_status = fgGetNode("/environment/clouds/status", true); _cloud_status = fgGetNode("/environment/clouds/status", true);
_visibility_m = fgGetNode("/environment/visibility-m", true); _visibility_m = fgGetNode("/environment/visibility-m", true);
}
void
FGRenderer::setupView( void )
{
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer(); osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
osg::initNotifyLevel(); osg::initNotifyLevel();
@ -593,12 +597,10 @@ FGRenderer::update()
// Update all Visuals (redraws anything graphics related) // Update all Visuals (redraws anything graphics related)
void void
FGRenderer::update( bool refresh_camera_settings ) { FGRenderer::update( bool refresh_camera_settings ) {
if ((!_scenery_loaded.get())|| if (!(_scenery_loaded->getBoolValue() ||
!(_scenery_loaded->getBoolValue() ||
_scenery_override->getBoolValue())) _scenery_override->getBoolValue()))
{ {
// alas, first "update" is being called before "init"... _splash_alpha->setDoubleValue(1.0);
fgSetDouble("/sim/startup/splash-alpha", 1.0);
return; return;
} }
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer(); osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
@ -611,10 +613,10 @@ FGRenderer::update( bool refresh_camera_settings ) {
double delay_time = SGMiscd::min(fade_time/fade_steps_per_sec, double delay_time = SGMiscd::min(fade_time/fade_steps_per_sec,
(SGTimeStamp::now() - _splash_time).toSecs()); (SGTimeStamp::now() - _splash_time).toSecs());
_splash_time = SGTimeStamp::now(); _splash_time = SGTimeStamp::now();
double sAlpha = fgGetDouble("/sim/startup/splash-alpha", 1.0); double sAlpha = _splash_alpha->getDoubleValue();
sAlpha -= SGMiscd::max(0.0,delay_time/fade_time); sAlpha -= SGMiscd::max(0.0,delay_time/fade_time);
FGScenerySwitchCallback::scenery_enabled = (sAlpha<1.0); FGScenerySwitchCallback::scenery_enabled = (sAlpha<1.0);
fgSetDouble("/sim/startup/splash-alpha", sAlpha); _splash_alpha->setDoubleValue(sAlpha);
} }
bool skyblend = _skyblend->getBoolValue(); bool skyblend = _skyblend->getBoolValue();
@ -770,16 +772,16 @@ FGRenderer::update( bool refresh_camera_settings ) {
// Handle new window size or exposure // Handle new window size or exposure
void void
FGRenderer::resize( int width, int height ) { FGRenderer::resize( int width, int height ) {
int view_h; int view_h = height;
if ( (!_virtual_cockpit->getBoolValue())
&& fgPanelVisible() && idle_state == 1000 ) {
view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
globals->get_current_panel()->getYOffset()) / 768.0);
} else {
view_h = height;
}
// the following breaks aspect-ratio of the main 3D scenery window when 2D panels are moved
// in y direction - causing issues for aircraft with 2D panels (/sim/virtual_cockpit=false).
// Disabling for now. Seems this useful for the pre-OSG time only.
// if ( (!_virtual_cockpit->getBoolValue())
// && fgPanelVisible() && idle_state == 1000 ) {
// view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
// globals->get_current_panel()->getYOffset()) / 768.0);
// }
static int lastwidth = 0; static int lastwidth = 0;
static int lastheight = 0; static int lastheight = 0;
if (width != lastwidth) if (width != lastwidth)

View file

@ -47,6 +47,8 @@ public:
void splashinit(); void splashinit();
void init(); void init();
void setupView();
void resize(int width, int height ); void resize(int width, int height );
// calling update( refresh_camera_settings = false ) will not // calling update( refresh_camera_settings = false ) will not

View file

@ -295,6 +295,7 @@ static osg::Node* fgCreateSplashCamera()
text->setPosition(osg::Vec3(0, -0.92, 0)); text->setPosition(osg::Vec3(0, -0.92, 0));
text->setAlignment(osgText::Text::CENTER_CENTER); text->setAlignment(osgText::Text::CENTER_CENTER);
SGPropertyNode* prop = fgGetNode("/sim/startup/splash-progress-text", true); SGPropertyNode* prop = fgGetNode("/sim/startup/splash-progress-text", true);
prop->setStringValue("initializing");
text->setUpdateCallback(new FGSplashTextUpdateCallback(prop)); text->setUpdateCallback(new FGSplashTextUpdateCallback(prop));
geode->addDrawable(text); geode->addDrawable(text);