void myModel::setBlending() { _blendFunc = new osg::BlendFunc; _stateset = _model->getOrCreateStateSet(); _blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); _stateset->setAttributeAndModes( _blendFunc ); }
void Configurar_Material() { // version which sets the color of the wireframe. material->setColorMode(osg::Material::OFF); // switch glColor usage off // turn all lighting off material->setShininess(osg::Material::FRONT_AND_BACK,10.0f); material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,1.0f,0.0f,1.0f)); material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,1.0f,0.0f,1.0f)); material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,1.0f,0.0f,1.0f)); // except emission... in which we set the color we desire material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f)); stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); Torreta->setStateSet(stateset); }
void createShaders(osg::StateSet& ss) { osg::ref_ptr<osg::Shader> verShader= new osg::Shader(osg::Shader::VERTEX,vertSource); osg::ref_ptr<osg::Shader> fragShader= new osg::Shader(osg::Shader::FRAGMENT,fragSource); osg::ref_ptr<osg::Program> program=new osg::Program; program->addShader(verShader.get()); program->addShader(fragShader.get()); osg::ref_ptr<osg::Uniform> mainColor= new osg::Uniform("mainColor",osg::Vec4(1,0.5,0.5,1)); mainColor->setUpdateCallback(new ColorCallback); ss.addUniform(mainColor.get()); ss.setAttributeAndModes(program.get()); }
torreta(int x, int y, int z,int tamaño) { Torreta = new osg::Group(); material = new osg::Material; stateset =new osg::StateSet; //Configurar_Material(); boton=y; left=x; //top=(8*tamaño)+z; //right=(11*tamaño); int tamaño_cubo_grade=tamaño*5; nave* cubomio=new nave (x,y,z,tamaño_cubo_grade); int puntopunta=tamaño_cubo_grade; puntopunta=puntopunta/2; puntopunta=puntopunta-(tamaño/2); nave* cubomio2=new nave(x+puntopunta,y,tamaño_cubo_grade+z,tamaño); Torreta->addChild(cubomio->getNave()); Torreta->addChild(cubomio2->getNave()); top=tamaño_cubo_grade+tamaño+y; right=tamaño_cubo_grade+x; yDisparo=top; xDisparo=x+puntopunta; stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF); };