- osg::StateSet *stateSet = new osg::StateSet;
- stateSet->setUserData(new SGMaterialUserData(this));
-
- // Set up the textured state
- stateSet->setAttribute(attrFact->getSmoothShadeModel());
- stateSet->setAttributeAndModes(attrFact->getCullFaceBack());
-
- stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
-
- _status[i].texture_loaded = false;
-
- osg::Material* material = new osg::Material;
- material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
- material->setAmbient(osg::Material::FRONT_AND_BACK, ambient.osg());
- material->setDiffuse(osg::Material::FRONT_AND_BACK, diffuse.osg());
- material->setSpecular(osg::Material::FRONT_AND_BACK, specular.osg());
- material->setEmission(osg::Material::FRONT_AND_BACK, emission.osg());
- material->setShininess(osg::Material::FRONT_AND_BACK, shininess );
- stateSet->setAttribute(material);
-
- if (ambient[3] < 1 || diffuse[3] < 1 ||
- specular[3] < 1 || emission[3] < 1) {
- stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
- stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
- stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
- } else {
- stateSet->setRenderingHint(osg::StateSet::OPAQUE_BIN);
- stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF);
- stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
+ SGPropertyNode_ptr effectProp = new SGPropertyNode();
+ copyProperties(propRoot, effectProp);
+ SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0);
+ for (unsigned int i = 0; i < matState.texture_paths.size(); i++) {
+ SGPropertyNode* texProp = makeChild(effectParamProp, "texture", matState.texture_paths[i].second);
+ makeChild(texProp, "image")->setStringValue(matState.texture_paths[i].first);
+ makeChild(texProp, "filter")
+ ->setStringValue(mipmap ? "linear-mipmap-linear" : "nearest");
+ makeChild(texProp, "wrap-s")
+ ->setStringValue(wrapu ? "repeat" : "clamp");
+ makeChild(texProp, "wrap-t")
+ ->setStringValue(wrapv ? "repeat" : "clamp");