Ejemplo n.º 1
0
void
ShaderGenerator::apply(osg::Group& group)
{
    if ( !_active ) return;

    traverse(group);

#if 0
    std::set<VirtualProgram*> childVPs;
    unsigned childrenWithVP = 0;
    for(unsigned i=0; i<group.getNumChildren(); ++i)
    {
        osg::StateSet* stateset = group.getChild(i)->getStateSet();
        if ( !stateset )
            break;

        VirtualProgram* vp = dynamic_cast<VirtualProgram*>(stateset->getAttribute(VirtualProgram::SA_TYPE));
        if ( vp )
        {
            childVPs.insert( vp );
            childrenWithVP++;
        }
    }
    if ( childrenWithVP == group.getNumChildren() && childVPs.size() == 1 )
    {
        group.getOrCreateStateSet()->setAttributeAndModes( *childVPs.begin(), 1 );
        for(unsigned i=0; i<group.getNumChildren(); ++i)
        {
            group.getChild(i)->getStateSet()->removeAttribute(VirtualProgram::SA_TYPE);
        }
    }
#endif
}
Ejemplo n.º 2
0
	virtual void apply(osg::Group &group ) {
		for (unsigned int i = 0; i<group.getNumChildren(); ) {
			if( dynamic_cast<osgAL::SoundRoot*>(group.getChild(i)) && _mode==SEARCH_AND_DESTROY ) {
				group.removeChild(i);
			} else {
				if (dynamic_cast<osgAL::SoundRoot*>(group.getChild(i)) && _mode==SEARCH)
					_found_count++;

				group.getChild(i)->accept(*this);
				i++;
			}
		}
	}
Ejemplo n.º 3
0
void CVRCullVisitor::PreCullVisitor::apply(osg::Group& group)
{
    bool setMask = false;
    for(int i = 0; i < group.getNumChildren(); i++)
    {
        _setMask = false;
        group.getChild(i)->accept(*this);
        if(_setMask)
        {
            setMask = true;
        }
    }

    if(group.getNodeMask() & FIRST_CULL_STATUS)
    {
        _setMask = true;
    }
    else if(setMask)
    {
        //std::cerr << "Pulling up node mask." << std::endl;
        _setMask = true;
        group.setNodeMask(group.getNodeMask() | FIRST_CULL_STATUS);
    }

}
Ejemplo n.º 4
0
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);
}
// apply method for groups
void GeometryExtractorVisitor::apply( osg::Group& group ) {
	
	// call the appropriate apply method for all children
	if( group.getNumChildren() > 0 ) {
		for( unsigned int i = 0; i < group.getNumChildren(); i++) {
			osg::Node* node = group.getChild( i );
			apply( *node );
		}
	}
}
Ejemplo n.º 6
0
Archivo: Group.cpp Proyecto: aalex/osg
static bool writeChildren( osgDB::OutputStream& os, const osg::Group& node )
{
    unsigned int size = node.getNumChildren();
    os << size << osgDB::BEGIN_BRACKET << std::endl;
    for ( unsigned int i=0; i<size; ++i )
    {
        os << node.getChild(i);
    }
    os << osgDB::END_BRACKET << std::endl;
    return true;
}
Ejemplo n.º 7
0
 virtual void apply(osg::Group& group)
 {
     for (unsigned int i = 0; i < group.getNumChildren(); i++)
     {
         osg::Node* child = group.getChild(i);
         osg::Node* seam = seamReplacement(child);
         if (child != seam)
         {
             group.replaceChild(child,seam);
         }
         else
         {
             child->accept(*this);
         }
     }
 }
Ejemplo n.º 8
0
void
GeometryValidator::apply(osg::Group& group)
{
    for(unsigned i=0; i<group.getNumChildren(); ++i)
    {
        osg::Geometry* geom = group.getChild(i)->asGeometry();
        if ( geom )
        {
            apply( *geom );
            if ( geom->getVertexArray() == 0L )
            {
                OE_NOTICE << "removing " << geom->getName() << " b/c of null vertex array\n";
                group.removeChild(geom);
                --i;
            }
        }
    }
}
Ejemplo n.º 9
0
	void Actualizar(int x,int y,int tamaño)
	{
	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,0,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,tamaño);
	Torreta->replaceChild(Torreta->getChild(0),cubomio->getNave());
	Torreta->replaceChild(Torreta->getChild(1),cubomio2->getNave());
	top=tamaño_cubo_grade+tamaño+y;
	right=tamaño_cubo_grade+x;
	yDisparo=top;
	xDisparo=x+puntopunta;
	}