scenery: Make sure makeEffects has reader writer options.

This commit is contained in:
Mathias Froehlich
2012-10-03 20:23:05 +02:00
parent f7a87789ab
commit 9c9bfc1a98
7 changed files with 26 additions and 9 deletions

View File

@@ -32,6 +32,7 @@
#include <simgear/scene/material/Pass.hxx>
#include <simgear/scene/util/CopyOp.hxx>
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <boost/scoped_array.hpp>
#include <boost/foreach.hpp>
@@ -94,8 +95,10 @@ public:
SGLightAnimation::SGLightAnimation(const SGPropertyNode* configNode,
SGPropertyNode* modelRoot,
const osgDB::Options* options,
const string &path, int i) :
SGAnimation(configNode, modelRoot)
SGAnimation(configNode, modelRoot),
_options(options)
{
_light_type = getConfig()->getStringValue("light-type");
_position = SGVec3d( getConfig()->getDoubleValue("position/x"), getConfig()->getDoubleValue("position/y"), getConfig()->getDoubleValue("position/z") );
@@ -182,7 +185,7 @@ SGLightAnimation::install(osg::Node& node)
return;
}
effect = simgear::makeEffect(effectProp, true);
effect = simgear::makeEffect(effectProp, true, dynamic_cast<const simgear::SGReaderWriterOptions*>(_options.get()));
if (iter == lightEffectMap.end() && cacheEffect)
lightEffectMap.insert(EffectMap::value_type(_key, effect));
else if (cacheEffect)

View File

@@ -424,7 +424,7 @@ SGAnimation::animate(osg::Node* node, const SGPropertyNode* configNode,
SGTranslateAnimation animInst(configNode, modelRoot);
animInst.apply(node);
} else if (type == "light") {
SGLightAnimation animInst(configNode, modelRoot, path, i);
SGLightAnimation animInst(configNode, modelRoot, options, path, i);
animInst.apply(node);
} else if (type == "null" || type == "none" || type.empty()) {
SGGroupAnimation animInst(configNode, modelRoot);

View File

@@ -350,6 +350,7 @@ class SGLightAnimation : public SGAnimation {
public:
SGLightAnimation(const SGPropertyNode* configNode,
SGPropertyNode* modelRoot,
const osgDB::Options* options,
const string &path, int i);
virtual osg::Group* createAnimationGroup(osg::Group& parent);
virtual void install(osg::Node& node);
@@ -369,6 +370,7 @@ private:
class UpdateCallback;
friend class UpdateCallback;
SGSharedPtr<SGExpressiond> _animationValue;
osg::ref_ptr<const osgDB::Options> _options;
};
#endif // _SG_ANIMATION_HXX

View File

@@ -38,9 +38,11 @@
#include <osg/ShadeModel>
#include <osg/PrimitiveSet>
#include <osg/CullFace>
#include <osgDB/Registry>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/VectorArrayAdapter.hxx>
#include <simgear/scene/material/Effect.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
@@ -159,14 +161,14 @@ void SGSkyDome::makeDome(int rings, int bands, DrawElementsUShort& elements)
// initialize the sky object and connect it into our scene graph
osg::Node*
SGSkyDome::build( double hscale, double vscale ) {
SGSkyDome::build( double hscale, double vscale, simgear::SGReaderWriterOptions *options ) {
EffectGeode* geode = new EffectGeode;
// Geode* geode = new Geode;
geode->setName("Skydome");
geode->setCullingActive(false); // Prevent skydome from being culled away
Effect *effect = makeEffect("Effects/skydome", true);
Effect *effect = makeEffect("Effects/skydome", true, options);
if(effect)
geode->setEffect(effect);

View File

@@ -39,6 +39,10 @@ namespace osg
class DrawElementsUShort;
}
namespace simgear {
class SGReaderWriterOptions;
}
class SGSkyDome : public SGReferenced {
osg::ref_ptr<osg::MatrixTransform> dome_transform;
double asl;
@@ -55,7 +59,7 @@ public:
// initialize the sky object and connect it into our scene graph
// root
osg::Node *build( double hscale = 80000.0, double vscale = 80000.0 );
osg::Node *build( double hscale = 80000.0, double vscale = 80000.0, simgear::SGReaderWriterOptions *options = 0 );
// repaint the sky colors based on current value of sun_angle,
// sky, and fog colors. This updates the color arrays for

View File

@@ -81,10 +81,11 @@ SGSky::~SGSky( void )
// the provided branch
void SGSky::build( double h_radius_m, double v_radius_m,
double sun_size, double moon_size,
const SGEphemeris& eph, SGPropertyNode *property_tree_node )
const SGEphemeris& eph, SGPropertyNode *property_tree_node,
simgear::SGReaderWriterOptions* options )
{
dome = new SGSkyDome;
pre_transform->addChild( dome->build( h_radius_m, v_radius_m ) );
pre_transform->addChild( dome->build( h_radius_m, v_radius_m, options ) );
pre_transform->addChild(_ephTransform.get());
planets = new SGStars;

View File

@@ -53,6 +53,10 @@
#include <simgear/scene/sky/oursun.hxx>
#include <simgear/scene/sky/stars.hxx>
namespace simgear {
class SGReaderWriterOptions;
}
typedef struct {
SGVec3d pos;
SGGeod pos_geod;
@@ -272,7 +276,8 @@ public:
*/
void build( double h_radius_m, double v_radius_m,
double sun_size, double moon_size,
const SGEphemeris& eph, SGPropertyNode *property_tree_node );
const SGEphemeris& eph, SGPropertyNode *property_tree_node,
simgear::SGReaderWriterOptions* options = 0);
/**
* Repaint the sky components based on current value of sun_angle,