1
0
Fork 0

Changes for animated effects

This commit is contained in:
Tim Moore 2009-11-03 12:41:00 +01:00
parent 3abe700dc8
commit 9a94b26609
3 changed files with 35 additions and 10 deletions

View file

@ -47,6 +47,7 @@
#include <simgear/scene/model/animation.hxx>
#include <simgear/scene/sky/sky.hxx>
#include <simgear/structure/event_mgr.hxx>
#include <simgear/props/AtomicChangeListener.hxx>
#include <simgear/props/props.hxx>
#include <simgear/timing/sg_time.hxx>
#include <simgear/math/sg_random.h>
@ -491,7 +492,7 @@ static void fgMainLoop( void ) {
fgSetFloat("/sim/sound/volume", init_volume);
globals->get_soundmgr()->set_volume(init_volume);
}
simgear::AtomicChangeListener::fireChangeListeners();
fgRequestRedraw();
SG_LOG( SG_ALL, SG_DEBUG, "" );

View file

@ -69,6 +69,7 @@ FGLight::FGLight ()
_scene_ambient(0, 0, 0, 0),
_scene_diffuse(0, 0, 0, 0),
_scene_specular(0, 0, 0, 0),
_scene_chrome(0, 0, 0, 0),
_sky_color(0, 0, 0, 0),
_fog_color(0, 0, 0, 0),
_cloud_color(0, 0, 0, 0),
@ -151,6 +152,15 @@ void FGLight::bind () {
prop->tie("/rendering/dome/fog/red",SGRawValuePointer<float>(&_fog_color[0]));
prop->tie("/rendering/dome/fog/green",SGRawValuePointer<float>(&_fog_color[1]));
prop->tie("/rendering/dome/fog/blue",SGRawValuePointer<float>(&_fog_color[2]));
// Properties used directly by effects
_chromeProps[0] = prop->getNode("/rendering/scene/chrome-light/red", true);
_chromeProps[1] = prop->getNode("/rendering/scene/chrome-light/green",
true);
_chromeProps[2] = prop->getNode("/rendering/scene/chrome-light/blue", true);
_chromeProps[3] = prop->getNode("/rendering/scene/chrome-light/alpha",
true);
for (int i = 0; i < 4; ++i)
_chromeProps[i]->setValue(0.0);
}
void FGLight::unbind () {
@ -265,6 +275,14 @@ void FGLight::update_sky_color () {
_scene_diffuse[3] = 1.0;
gamma_correct_rgb( _scene_diffuse.data() );
SGVec4f chrome = _scene_ambient * .4f + _scene_diffuse;
chrome[3] = 1.0f;
if (chrome != _scene_chrome) {
_scene_chrome = chrome;
for (int i = 0; i < 4; ++i)
_chromeProps[i]->setValue(static_cast<double>(_scene_chrome[i]));
}
color = thesky->get_sun_color();
_scene_specular[0] = color[0] * specular;
_scene_specular[1] = color[1] * specular;

View file

@ -36,6 +36,7 @@
#include <simgear/compiler.h>
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/math/interpolater.hxx>
@ -85,6 +86,7 @@ private:
SGVec4f _scene_ambient;
SGVec4f _scene_diffuse;
SGVec4f _scene_specular;
SGVec4f _scene_chrome;
// clear sky, fog and cloud color
SGVec4f _sky_color;
@ -100,6 +102,9 @@ private:
void update_sky_color ();
void update_adj_fog_color ();
// properties for chrome light; not a tie because I want to fire
// property listeners when the values change.
SGPropertyNode_ptr _chromeProps[4];
public:
FGLight ();
@ -117,6 +122,7 @@ public:
inline const SGVec4f& scene_ambient () const { return _scene_ambient; }
inline const SGVec4f& scene_diffuse () const { return _scene_diffuse; }
inline const SGVec4f& scene_specular () const { return _scene_specular; }
inline const SGVec4f& scene_chrome () const { return _scene_chrome; }
inline const SGVec4f& sky_color () const { return _sky_color; }
inline const SGVec4f& cloud_color () const { return _cloud_color; }