This supports pathnames relative to a model in effect definitions.
return getEffectPropertyNode(effect, child);
}
-string getGlobalProperty(const SGPropertyNode* prop)
+string getGlobalProperty(const SGPropertyNode* prop,
+ const SGReaderWriterXMLOptions* options)
{
if (!prop)
return string();
const SGPropertyNode* useProp = prop->getChild("use");
if (!useProp)
return string();
+ string propName = useProp->getStringValue();
+ SGPropertyNode_ptr propRoot;
+ if (propName[0] == '/') {
+ return propName;
+ } else if ((propRoot = options->getPropRoot())) {
+ string result = propRoot->getPath();
+ result.append("/");
+ result.append(propName);
+ return result;
+ } else {
+ throw effect::
+ BuilderException("No property root to use with relative name "
+ + propName);
+ }
+
return useProp->getStringValue();
}
{
class Effect;
class Pass;
+class SGReaderWriterXMLOptions;
/**
* Builder that returns an object, probably an OSG object.
* @return empty if prop doesn't contain a <use> clause; otherwise the
* mentioned node name.
*/
-std::string getGlobalProperty(const SGPropertyNode* prop);
+std::string getGlobalProperty(const SGPropertyNode* prop,
+ const SGReaderWriterXMLOptions *);
class PassAttributeBuilder : public SGReferenced
{
template<typename ObjType, typename OSGParamType>
void
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
- void (ObjType::*setter)(const OSGParamType))
+ void (ObjType::*setter)(const OSGParamType),
+ const SGReaderWriterXMLOptions* options)
{
const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
if (!valProp)
if (valProp->nChildren() == 0) {
obj->*setter(valProp->getValue<OSGParamType>());
} else {
- std::string propName = getGlobalProperty(prop);
+ std::string propName = getGlobalProperty(prop, options);
ScalarChangeListener<ObjType, OSGParamType>* listener
= new ScalarChangeListener<ObjType, OSGParamType>(obj, setter,
propName);
void
initFromParameters(Effect* effect, const SGPropertyNode* prop, ObjType* obj,
void (ObjType::*setter)(const OSGParamType&),
- NameItrType nameItr)
+ NameItrType nameItr, const SGReaderWriterXMLOptions* options)
{
typedef typename OSGBridge<OSGParamType>::sg_type sg_type;
const SGPropertyNode* valProp = getEffectPropertyNode(effect, prop);
(obj->*setter)(OSGBridge<OSGParamType>
::getOsgType(valProp->getValue<sg_type>()));
} else {
- string listenPropName = getGlobalProperty(valProp);
+ string listenPropName = getGlobalProperty(valProp, options);
if (listenPropName.empty())
return;
typedef OSGFunctor<ObjType, OSGParamType> Functor;
using namespace effect;
TexEnvCombine* buildTexEnvCombine(Effect* effect,
- const SGPropertyNode* envProp);
+ const SGPropertyNode* envProp,
+ const SGReaderWriterXMLOptions* options);
TexGen* buildTexGen(Effect* Effect, const SGPropertyNode* tgenProp);
// Hack to force inclusion of TextureBuilder.cxx in library
}
const SGPropertyNode* combineProp = prop->getChild("texenv-combine");
TexEnvCombine* combiner = 0;
- if (combineProp && ((combiner = buildTexEnvCombine(effect, combineProp))))
+ if (combineProp && ((combiner = buildTexEnvCombine(effect, combineProp,
+ options))))
pass->setTextureAttributeAndModes(unit, combiner);
const SGPropertyNode* tgenProp = prop->getChild("texgen");
TexGen* tgen = 0;
EffectPropertyMap<TexEnvCombine::OperandParam> operandParams(opParamInit);
-TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp)
+TexEnvCombine* buildTexEnvCombine(Effect* effect, const SGPropertyNode* envProp,
+ const SGReaderWriterXMLOptions* options)
{
if (!isAttributeActive(effect, envProp))
return 0;
const SGPropertyNode* colorNode = envProp->getChild("constant-color");
if (colorNode)
initFromParameters(effect, colorNode, result,
- &TexEnvCombine::setConstantColor, colorFields);
+ &TexEnvCombine::setConstantColor, colorFields,
+ options);
return result;
}