/** Attacca al/ai nodi che corrispondono a nodeName */
void LoadThreadsHandler::AttachNodeToSceneByName::apply(osg::Group& grp)
{
	if (grp.getName() == _nodeName)
	{
		if(!_attached || _multipleattach)
		{
			if(_ranged)
			{
				osg::ref_ptr<osg::LOD> newlod = new osg::LOD;
				newlod->setName("RangedLOD_" + _attachNode->getName());

				newlod->addChild(_attachNode.get(), _min, _max);

				grp.addChild(newlod.get());
			}
			else
			{
				grp.addChild(_attachNode.get());
			}
			
			_attached = true;
		}
	}

	traverse(grp);
}
void
RemoveEmptyGroupsVisitor::apply( osg::Group& group )
{
    bool removed = true;
    while( removed )
    {
        removed = false;
        for( unsigned i = 0; i < group.getNumChildren(); ++i )
        {
            osg::Group* child = group.getChild(i)->asGroup();
            if ( child )
            {
                if (child->className() == std::string("Group") &&
                    child->getStateSet() == 0L            &&
                    child->getCullCallback() == 0L        &&
                    child->getUpdateCallback() == 0L      &&
                    child->getUserData() == 0L            &&
                    child->getName().empty()              &&
                    child->getDescriptions().size() == 0 )
                {
                    for( unsigned j = 0; j < child->getNumChildren(); ++j )
                    {
                        group.addChild( child->getChild( j ) );
                    }

                    group.removeChild( i-- );
                    removed = true;
                }                
            }
        }
    }

    traverse(group);
}
Esempio n. 3
0
File: Group.cpp Progetto: aalex/osg
static bool readChildren( osgDB::InputStream& is, osg::Group& node )
{
    unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
    for ( unsigned int i=0; i<size; ++i )
    {
        osg::Node* child = dynamic_cast<osg::Node*>( is.readObject() );
        if ( child ) node.addChild( child );
    }
    is >> osgDB::END_BRACKET;
    return true;
}
Esempio n. 4
0
	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);
	};