From: Tim Moore Date: Tue, 9 Mar 2010 06:29:26 +0000 (+0100) Subject: animate uniform parameters in effects X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=93c2f70b6464d565c96725de93c614c93eefa2b9;p=simgear.git animate uniform parameters in effects --- diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 3ad93162..400e350a 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -160,6 +160,10 @@ void buildPass(Effect* effect, Technique* tniq, const SGPropertyNode* prop, } } +// Default names for vector property components +const char* vec3Names[] = {"x", "y", "z"}; +const char* vec4Names[] = {"x", "y", "z", "w"}; + osg::Vec4f getColor(const SGPropertyNode* prop) { if (prop->nChildren() == 0) { @@ -808,8 +812,11 @@ EffectNameValue uniformTypesInit[] = {"float-vec3", Uniform::FLOAT_VEC3}, {"float-vec4", Uniform::FLOAT_VEC4}, {"sampler-1d", Uniform::SAMPLER_1D}, + {"sampler-1d-shadow", Uniform::SAMPLER_1D_SHADOW}, {"sampler-2d", Uniform::SAMPLER_2D}, - {"sampler-3d", Uniform::SAMPLER_3D} + {"sampler-2d-shadow", Uniform::SAMPLER_2D_SHADOW}, + {"sampler-3d", Uniform::SAMPLER_3D}, + {"sampler-cube", Uniform::SAMPLER_CUBE} }; EffectPropertyMap uniformTypes(uniformTypesInit); @@ -862,18 +869,29 @@ struct UniformBuilder :public PassAttributeBuilder uniform->setType(uniformType); switch (uniformType) { case Uniform::FLOAT: - uniform->set(valProp->getValue()); + initFromParameters(effect, valProp, uniform.get(), + static_cast(&Uniform::set), + options); break; case Uniform::FLOAT_VEC3: - uniform->set(toOsg(valProp->getValue())); + initFromParameters(effect, valProp, uniform.get(), + static_cast(&Uniform::set), + vec3Names, options); break; case Uniform::FLOAT_VEC4: - uniform->set(toOsg(valProp->getValue())); + initFromParameters(effect, valProp, uniform.get(), + static_cast(&Uniform::set), + vec4Names, options); break; case Uniform::SAMPLER_1D: case Uniform::SAMPLER_2D: case Uniform::SAMPLER_3D: - uniform->set(valProp->getValue()); + case Uniform::SAMPLER_1D_SHADOW: + case Uniform::SAMPLER_2D_SHADOW: + case Uniform::SAMPLER_CUBE: + initFromParameters(effect, valProp, uniform.get(), + static_cast(&Uniform::set), + options); break; default: // avoid compiler warning break;