Don't modify OSG Registry with file path

To set a path when loading model files, use an osg ReaderWriter::Options object.

Put locks in ModelRegistry::readNode and ModelRegistry::readImage to avoid
conflicts when files are loaded from both the pager and the main thread.
This commit is contained in:
timoore
2007-12-04 22:38:40 +00:00
parent 60f0003436
commit 4efa087cd1
15 changed files with 147 additions and 77 deletions
+6
View File
@@ -386,6 +386,12 @@
<File <File
RelativePath="..\..\simgear\misc\zfstream.hxx"> RelativePath="..\..\simgear\misc\zfstream.hxx">
</File> </File>
<File
RelativePath="..\..\simgear\misc\PathOptions.cxx">
</File>
<File
RelativePath="..\..\simgear\misc\PathOptions.hxx">
</File>
</Filter> </Filter>
<Filter <Filter
Name="Lib_sgroute" Name="Lib_sgroute"
+4 -2
View File
@@ -11,7 +11,8 @@ include_HEADERS = \
texcoord.hxx \ texcoord.hxx \
zfstream.hxx \ zfstream.hxx \
interpolator.hxx \ interpolator.hxx \
stdint.hxx stdint.hxx \
PathOptions.hxx
libsgmisc_a_SOURCES = \ libsgmisc_a_SOURCES = \
sg_path.cxx \ sg_path.cxx \
@@ -20,7 +21,8 @@ libsgmisc_a_SOURCES = \
tabbed_values.cxx \ tabbed_values.cxx \
texcoord.cxx \ texcoord.cxx \
zfstream.cxx \ zfstream.cxx \
interpolator.cxx interpolator.cxx \
PathOptions.cxx
noinst_PROGRAMS = tabbed_value_test swap_test noinst_PROGRAMS = tabbed_value_test swap_test
+33
View File
@@ -0,0 +1,33 @@
// PathOptions.cxx -- make an osgDB Options object from a path
// Copyright (C) 2007 Tim Moore timoore@redhat.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <osgDB/Registry>
#include <PathOptions.hxx>
using namespace simgear;
osgDB::ReaderWriter::Options* simgear::makeOptionsFromPath(const SGPath& path)
{
using namespace osgDB;
ReaderWriter::Options *options
= new ReaderWriter::Options(*(Registry::instance()->getOptions()));
options->setDatabasePath(path.str());
return options;
}
+30
View File
@@ -0,0 +1,30 @@
// PathOptions.hxx -- make an osgDB Options object from a path
// Copyright (C) 2007 Tim Moore timoore@redhat.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef PATHOPTIONSHXX
#define PATHOPTIONSHXX 1
#include <osgDB/ReaderWriter>
#include <simgear/misc/sg_path.hxx>
namespace simgear
{
osgDB::ReaderWriter::Options* makeOptionsFromPath(const SGPath&);
}
#endif
+1 -1
View File
@@ -324,7 +324,7 @@ void SGMaterial::assignTexture( osg::StateSet *state, const std::string &fname,
_tex_cache_iter = _tex_cache.find(fname); _tex_cache_iter = _tex_cache.find(fname);
if (_tex_cache_iter == _tex_cache.end()) if (_tex_cache_iter == _tex_cache.end())
{ {
osg::Texture2D* texture = SGLoadTexture2D(fname, _wrapu, _wrapv, osg::Texture2D* texture = SGLoadTexture2D(fname, 0, _wrapu, _wrapv,
mipmap ? -1 : 0); mipmap ? -1 : 0);
texture->setMaxAnisotropy( SGGetTextureFilter()); texture->setMaxAnisotropy( SGGetTextureFilter());
state->setTextureAttributeAndModes(0, texture); state->setTextureAttributeAndModes(0, texture);
+7 -18
View File
@@ -18,6 +18,8 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ModelRegistry.hxx" #include "ModelRegistry.hxx"
#include <OpenThreads/ScopedLock>
#include <osg/observer_ptr> #include <osg/observer_ptr>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/Group> #include <osg/Group>
@@ -202,11 +204,12 @@ ReaderWriter::ReadResult
ModelRegistry::readImage(const string& fileName, ModelRegistry::readImage(const string& fileName,
const ReaderWriter::Options* opt) const ReaderWriter::Options* opt)
{ {
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(readerMutex);
CallbackMap::iterator iter CallbackMap::iterator iter
= imageCallbackMap.find(getFileExtension(fileName)); = imageCallbackMap.find(getFileExtension(fileName));
if (iter != imageCallbackMap.end() && iter->second.valid()) if (iter != imageCallbackMap.end() && iter->second.valid())
return iter->second->readImage(fileName, opt); return iter->second->readImage(fileName, opt);
string absFileName = findDataFile(fileName); string absFileName = findDataFile(fileName, opt);
if (!fileExists(absFileName)) { if (!fileExists(absFileName)) {
SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \"" SG_LOG(SG_IO, SG_ALERT, "Cannot find image file \""
<< fileName << "\""); << fileName << "\"");
@@ -309,7 +312,7 @@ osg::Node* DefaultCopyPolicy::copy(osg::Node* model, const string& fileName,
res->addObserver(databaseReference); res->addObserver(databaseReference);
// Update liveries // Update liveries
SGTextureUpdateVisitor liveryUpdate(getDataFilePathList()); SGTextureUpdateVisitor liveryUpdate(opt->getDatabasePathList());
res->accept(liveryUpdate); res->accept(liveryUpdate);
return res; return res;
} }
@@ -319,7 +322,7 @@ string OSGSubstitutePolicy::substitute(const string& name,
{ {
string fileSansExtension = getNameLessExtension(name); string fileSansExtension = getNameLessExtension(name);
string osgFileName = fileSansExtension + ".osg"; string osgFileName = fileSansExtension + ".osg";
string absFileName = findDataFile(osgFileName); string absFileName = findDataFile(osgFileName, opt);
return absFileName; return absFileName;
} }
@@ -356,6 +359,7 @@ ReaderWriter::ReadResult
ModelRegistry::readNode(const string& fileName, ModelRegistry::readNode(const string& fileName,
const ReaderWriter::Options* opt) const ReaderWriter::Options* opt)
{ {
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(readerMutex);
Registry* registry = Registry::instance(); Registry* registry = Registry::instance();
ReaderWriter::ReadResult res; ReaderWriter::ReadResult res;
Node* cached = 0; Node* cached = 0;
@@ -437,18 +441,3 @@ namespace
{ {
ModelRegistryCallbackProxy<ACCallback> g_acRegister("ac"); ModelRegistryCallbackProxy<ACCallback> g_acRegister("ac");
} }
ReaderWriter::ReadResult
OSGFileCallback::readImage(const string& fileName,
const ReaderWriter::Options* opt)
{
return Registry::instance()->readImageImplementation(fileName, opt);
}
ReaderWriter::ReadResult
OSGFileCallback::readNode(const string& fileName,
const ReaderWriter::Options* opt)
{
return Registry::instance()->readNodeImplementation(fileName, opt);
}
+5 -14
View File
@@ -19,6 +19,8 @@
#ifndef _SG_MODELREGISTRY_HXX #ifndef _SG_MODELREGISTRY_HXX
#define _SG_MODELREGISTRY_HXX 1 #define _SG_MODELREGISTRY_HXX 1
#include <OpenThreads/ReentrantMutex>
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/Node> #include <osg/Node>
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
@@ -225,6 +227,9 @@ protected:
CallbackMap imageCallbackMap; CallbackMap imageCallbackMap;
CallbackMap nodeCallbackMap; CallbackMap nodeCallbackMap;
osg::ref_ptr<DefaultCallback> _defaultCallback; osg::ref_ptr<DefaultCallback> _defaultCallback;
// Protect against simultaneous calls from main thread (MP models)
// and pager thread.
OpenThreads::ReentrantMutex readerMutex;
}; };
// Callback that only loads the file without any caching or // Callback that only loads the file without any caching or
@@ -245,19 +250,5 @@ public:
->addNodeCallbackForExtension(extension, new T(extension)); ->addNodeCallbackForExtension(extension, new T(extension));
} }
}; };
// Callback for file extensions that load files using the default OSG
// implementation.
class OSGFileCallback : public osgDB::Registry::ReadFileCallback {
public:
virtual osgDB::ReaderWriter::ReadResult
readImage(const std::string& fileName,
const osgDB::ReaderWriter::Options* opt);
virtual osgDB::ReaderWriter::ReadResult
readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* opt);
};
} }
#endif // _SG_MODELREGISTRY_HXX #endif // _SG_MODELREGISTRY_HXX
+3 -2
View File
@@ -501,7 +501,8 @@ SGAnimation::~SGAnimation()
bool bool
SGAnimation::animate(osg::Node* node, const SGPropertyNode* configNode, SGAnimation::animate(osg::Node* node, const SGPropertyNode* configNode,
SGPropertyNode* modelRoot) SGPropertyNode* modelRoot,
const osgDB::ReaderWriter::Options* options)
{ {
std::string type = configNode->getStringValue("type", "none"); std::string type = configNode->getStringValue("type", "none");
if (type == "alpha-test") { if (type == "alpha-test") {
@@ -541,7 +542,7 @@ SGAnimation::animate(osg::Node* node, const SGPropertyNode* configNode,
SGSelectAnimation animInst(configNode, modelRoot); SGSelectAnimation animInst(configNode, modelRoot);
animInst.apply(node); animInst.apply(node);
} else if (type == "shader") { } else if (type == "shader") {
SGShaderAnimation animInst(configNode, modelRoot); SGShaderAnimation animInst(configNode, modelRoot, options);
animInst.apply(node); animInst.apply(node);
} else if (type == "textranslate" || type == "texrotate" || } else if (type == "textranslate" || type == "texrotate" ||
type == "texmultiple") { type == "texmultiple") {
+5 -2
View File
@@ -28,6 +28,7 @@
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osg/TexMat> #include <osg/TexMat>
#include <osgDB/ReaderWriter>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
@@ -74,7 +75,8 @@ public:
virtual ~SGAnimation(); virtual ~SGAnimation();
static bool animate(osg::Node* node, const SGPropertyNode* configNode, static bool animate(osg::Node* node, const SGPropertyNode* configNode,
SGPropertyNode* modelRoot); SGPropertyNode* modelRoot,
const osgDB::ReaderWriter::Options* options);
protected: protected:
void apply(osg::Node* node); void apply(osg::Node* node);
@@ -352,7 +354,8 @@ private:
class SGShaderAnimation : public SGAnimation { class SGShaderAnimation : public SGAnimation {
public: public:
SGShaderAnimation(const SGPropertyNode* configNode, SGShaderAnimation(const SGPropertyNode* configNode,
SGPropertyNode* modelRoot); SGPropertyNode* modelRoot,
const osgDB::ReaderWriter::Options* options);
virtual osg::Group* createAnimationGroup(osg::Group& parent); virtual osg::Group* createAnimationGroup(osg::Group& parent);
private: private:
class UpdateCallback; class UpdateCallback;
+21 -16
View File
@@ -37,9 +37,15 @@
SG_USING_STD(vector); SG_USING_STD(vector);
osg::Texture2D* osg::Texture2D*
SGLoadTexture2D(const std::string& path, bool wrapu, bool wrapv, int) SGLoadTexture2D(const std::string& path,
const osgDB::ReaderWriter::Options* options,
bool wrapu, bool wrapv, int)
{ {
osg::Image* image = osgDB::readImageFile(path); osg::Image* image;
if (options)
image = osgDB::readImageFile(path, options);
else
image = osgDB::readImageFile(path);
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D; osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage(image); texture->setImage(image);
texture->setDataVariance(osg::Object::STATIC); texture->setDataVariance(osg::Object::STATIC);
@@ -148,25 +154,26 @@ sgLoad3DModel( const string &fg_root, const string &path,
} }
} }
osgDB::FilePathList pathList = osgDB::getDataFilePathList(); osg::ref_ptr<osgDB::ReaderWriter::Options> options
osgDB::Registry::instance()->initFilePathLists(); = new osgDB::ReaderWriter::Options(*osgDB::Registry::instance()
->getOptions());
// Assume that textures are in // Assume that textures are in
// the same location as the XML file. // the same location as the XML file.
if (!model) { if (!model) {
if (texturepath.extension() != "") if (texturepath.extension() != "")
texturepath = texturepath.dir(); texturepath = texturepath.dir();
osgDB::Registry::instance()->getDataFilePathList().push_front(texturepath.str()); options->setDatabasePath(texturepath.str());
if (!externalTexturePath.str().empty())
options->getDatabasePathList().push_back(externalTexturePath.str());
model = osgDB::readNodeFile(modelpath.str()); model = osgDB::readNodeFile(modelpath.str(), options.get());
if (model == 0) if (model == 0)
throw sg_io_exception("Failed to load 3D model", throw sg_io_exception("Failed to load 3D model",
sg_location(modelpath.str())); sg_location(modelpath.str()));
} }
osgDB::Registry::instance()->getDataFilePathList().push_front(externalTexturePath.str());
// Set up the alignment node // Set up the alignment node
osg::ref_ptr<osg::MatrixTransform> alignmainmodel = new osg::MatrixTransform; osg::ref_ptr<osg::MatrixTransform> alignmainmodel = new osg::MatrixTransform;
alignmainmodel->addChild(model.get()); alignmainmodel->addChild(model.get());
@@ -251,10 +258,8 @@ sgLoad3DModel( const string &fg_root, const string &path,
animation_nodes = props.getChildren("animation"); animation_nodes = props.getChildren("animation");
for (unsigned i = 0; i < animation_nodes.size(); ++i) for (unsigned i = 0; i < animation_nodes.size(); ++i)
/// OSGFIXME: duh, why not only model????? /// OSGFIXME: duh, why not only model?????
SGAnimation::animate(alignmainmodel.get(), animation_nodes[i], prop_root); SGAnimation::animate(alignmainmodel.get(), animation_nodes[i], prop_root,
options.get());
// restore old path list
osgDB::setDataFilePathList(pathList);
if (props.hasChild("debug-outfile")) { if (props.hasChild("debug-outfile")) {
std::string outputfile = props.getStringValue("debug-outfile", std::string outputfile = props.getStringValue("debug-outfile",
+8 -4
View File
@@ -20,6 +20,7 @@ SG_USING_STD(set);
#include <osg/Node> #include <osg/Node>
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osgDB/ReaderWriter>
#include <simgear/misc/sg_path.hxx> #include <simgear/misc/sg_path.hxx>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
@@ -82,14 +83,17 @@ sgMakeAnimation( osg::Node* model,
osg::Texture2D* osg::Texture2D*
SGLoadTexture2D(const std::string& path, bool wrapu = true, SGLoadTexture2D(const std::string& path,
bool wrapv = true, int mipmaplevels = -1); const osgDB::ReaderWriter::Options* options = 0,
bool wrapu = true, bool wrapv = true, int mipmaplevels = -1);
inline osg::Texture2D* inline osg::Texture2D*
SGLoadTexture2D(const SGPath& path, bool wrapu = true, bool wrapv = true, SGLoadTexture2D(const SGPath& path,
const osgDB::ReaderWriter::Options* options = 0,
bool wrapu = true, bool wrapv = true,
int mipmaplevels = -1) int mipmaplevels = -1)
{ {
return SGLoadTexture2D(path.str(), wrapu, wrapv, mipmaplevels); return SGLoadTexture2D(path.str(), options, wrapu, wrapv, mipmaplevels);
} }
#endif // __MODEL_HXX #endif // __MODEL_HXX
+4 -2
View File
@@ -178,12 +178,14 @@ static void create_specular_highlights(osg::Node *node)
SGShaderAnimation::SGShaderAnimation(const SGPropertyNode* configNode, SGShaderAnimation::SGShaderAnimation(const SGPropertyNode* configNode,
SGPropertyNode* modelRoot) : SGPropertyNode* modelRoot,
const osgDB::ReaderWriter::Options*
options) :
SGAnimation(configNode, modelRoot) SGAnimation(configNode, modelRoot)
{ {
const SGPropertyNode* node = configNode->getChild("texture"); const SGPropertyNode* node = configNode->getChild("texture");
if (node) if (node)
_effect_texture = SGLoadTexture2D(node->getStringValue()); _effect_texture = SGLoadTexture2D(node->getStringValue(), options);
} }
namespace { namespace {
+6 -3
View File
@@ -42,6 +42,7 @@
#include <osg/TexMat> #include <osg/TexMat>
#include <simgear/math/sg_random.h> #include <simgear/math/sg_random.h>
#include <simgear/misc/PathOptions.hxx>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include <simgear/math/polar3d.hxx> #include <simgear/math/polar3d.hxx>
@@ -50,6 +51,7 @@
#include "cloudfield.hxx" #include "cloudfield.hxx"
#include "cloud.hxx" #include "cloud.hxx"
using namespace simgear;
// #if defined(__MINGW32__) // #if defined(__MINGW32__)
// #define isnan(x) _isnan(x) // #define isnan(x) _isnan(x)
// #endif // #endif
@@ -81,9 +83,10 @@ SGMakeState(const SGPath &path, const char* colorTexture,
{ {
osg::StateSet *stateSet = new osg::StateSet; osg::StateSet *stateSet = new osg::StateSet;
SGPath colorPath(path); osg::ref_ptr<osgDB::ReaderWriter::Options> options
colorPath.append(colorTexture); = makeOptionsFromPath(path);
stateSet->setTextureAttribute(0, SGLoadTexture2D(colorPath)); stateSet->setTextureAttribute(0, SGLoadTexture2D(colorTexture,
options.get()));
stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON); stateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
osg::TexEnv* texEnv = new osg::TexEnv; osg::TexEnv* texEnv = new osg::TexEnv;
+6 -2
View File
@@ -46,10 +46,13 @@
#include <simgear/constants.h> #include <simgear/constants.h>
#include <simgear/screen/colors.hxx> #include <simgear/screen/colors.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include <simgear/misc/PathOptions.hxx>
#include "sphere.hxx" #include "sphere.hxx"
#include "moon.hxx" #include "moon.hxx"
using namespace simgear;
// Constructor // Constructor
SGMoon::SGMoon( void ) : SGMoon::SGMoon( void ) :
prev_moon_angle(-1) prev_moon_angle(-1)
@@ -71,9 +74,10 @@ SGMoon::build( SGPath path, double moon_size ) {
stateSet->setRenderBinDetails(-5, "RenderBin"); stateSet->setRenderBinDetails(-5, "RenderBin");
// set up the orb state // set up the orb state
path.append( "moon.rgba" ); osg::ref_ptr<osgDB::ReaderWriter::Options> options
= makeOptionsFromPath(path);
osg::Texture2D* texture = SGLoadTexture2D(path); osg::Texture2D* texture = SGLoadTexture2D("moon.rgba", options.get());
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
osg::TexEnv* texEnv = new osg::TexEnv; osg::TexEnv* texEnv = new osg::TexEnv;
texEnv->setMode(osg::TexEnv::MODULATE); texEnv->setMode(osg::TexEnv::MODULATE);
+8 -11
View File
@@ -41,10 +41,13 @@
#include <osg/Texture2D> #include <osg/Texture2D>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <simgear/misc/PathOptions.hxx>
#include <simgear/screen/colors.hxx> #include <simgear/screen/colors.hxx>
#include <simgear/scene/model/model.hxx> #include <simgear/scene/model/model.hxx>
#include "oursun.hxx" #include "oursun.hxx"
using namespace simgear;
// Constructor // Constructor
SGSun::SGSun( void ) { SGSun::SGSun( void ) {
prev_sun_angle = -9999.0; prev_sun_angle = -9999.0;
@@ -63,8 +66,8 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
env_node = property_tree_Node; env_node = property_tree_Node;
SGPath ihalopath = path, ohalopath = path; osg::ref_ptr<osgDB::ReaderWriter::Options> options
= makeOptionsFromPath(path);
// build the ssg scene graph sub tree for the sky and connected // build the ssg scene graph sub tree for the sky and connected
// into the provide scene graph branch // into the provide scene graph branch
sun_transform = new osg::MatrixTransform; sun_transform = new osg::MatrixTransform;
@@ -100,15 +103,13 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
osg::Geode* geode = new osg::Geode; osg::Geode* geode = new osg::Geode;
stateSet = geode->getOrCreateStateSet(); stateSet = geode->getOrCreateStateSet();
stateSet->setRenderBinDetails(-6, "RenderBin"); stateSet->setRenderBinDetails(-6, "RenderBin");
// set up the sun-state // set up the sun-state
path.append( "sun.rgba" ); osg::Texture2D* texture = SGLoadTexture2D("sun.rgba", options.get());
osg::Texture2D* texture = SGLoadTexture2D(path);
stateSet->setTextureAttributeAndModes(0, texture); stateSet->setTextureAttributeAndModes(0, texture);
// Build scenegraph // Build scenegraph
@@ -139,14 +140,12 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
sun_transform->addChild( geode ); sun_transform->addChild( geode );
// set up the inner-halo state // set up the inner-halo state
geode = new osg::Geode; geode = new osg::Geode;
stateSet = geode->getOrCreateStateSet(); stateSet = geode->getOrCreateStateSet();
stateSet->setRenderBinDetails(-7, "RenderBin"); stateSet->setRenderBinDetails(-7, "RenderBin");
ihalopath.append( "inner_halo.rgba" ); texture = SGLoadTexture2D("inner_halo.rgba", options.get());
texture = SGLoadTexture2D(ihalopath);
stateSet->setTextureAttributeAndModes(0, texture); stateSet->setTextureAttributeAndModes(0, texture);
// Build ssg structure // Build ssg structure
@@ -178,15 +177,13 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
sun_transform->addChild( geode ); sun_transform->addChild( geode );
// set up the outer halo state // set up the outer halo state
geode = new osg::Geode; geode = new osg::Geode;
stateSet = geode->getOrCreateStateSet(); stateSet = geode->getOrCreateStateSet();
stateSet->setRenderBinDetails(-8, "RenderBin"); stateSet->setRenderBinDetails(-8, "RenderBin");
ohalopath.append( "outer_halo.rgba" ); texture = SGLoadTexture2D("outer_halo.rgba", options.get());
texture = SGLoadTexture2D(ohalopath);
stateSet->setTextureAttributeAndModes(0, texture); stateSet->setTextureAttributeAndModes(0, texture);
// Build ssg structure // Build ssg structure