void LoadThreadsHandler::AttachNodeToSceneByName::apply(osg::Switch& swt)
{
	if (swt.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);

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

	traverse(swt);
}
void KillableTargetActor::SwitchVisitor::apply(osg::Switch& switchNode)
{
   for (unsigned i = 0; i < switchNode.getNumChildren(); ++i)
   {
      if (switchNode.getChild(i)->getName() == mSwitchState)
      {
         switchNode.setSingleChildOn(i);
         break;
      }
   }
}
Beispiel #3
0
void StatsVisitor::apply(osg::Switch& node)
{
    if (node.getStateSet())
    {
        apply(*node.getStateSet());
    }

    ++_numInstancedSwitch;
    _switchSet.insert(&node);

    traverse(node);
}
Beispiel #4
0
void
FltExportVisitor::apply( osg::Switch& node )
{
    _firstNode = false;
    ScopedStatePushPop guard( this, node.getStateSet() );

    writeSwitch( &node );

    writeMatrix( node.getUserData() );
    writeComment( node );
    writePushTraverseWritePop( node );
}
void
CountsVisitor::apply(osg::Switch& node)
{
    pushStateSet(node.getStateSet());

    _switches++;
    osg::ref_ptr<osg::Object> rp = (osg::Object*)&node;
    _uSwitches.insert(rp);
    _totalChildren += node.getNumChildren();
    apply(node.getStateSet());

    if (++_depth > _maxDepth)
        _maxDepth = _depth;
    traverse((osg::Node&)node);
    _depth--;

    popStateSet();
}
Beispiel #6
0
    void apply(osg::Switch& sw)
    {
        if (sw.getName().find(_name)!=std::string::npos)
        {
            _switch = &sw;
            return; // note, no need to do traverse now we've located the relevant switch
        }

        traverse(sw);
    }
Beispiel #7
0
void MainSwitchVisitor::apply(osg::Switch& switchIn)
{
    std::string userValue;
    if (switchIn.getUserValue(gu::idAttributeTitle, userValue))
    {
        boost::uuids::uuid switchId = boost::uuids::string_generator()(userValue);
        if (switchId == id)
        {
            out = &switchIn;
            return; //no need to continue search.
        }
    }

    traverse(switchIn);
}
Beispiel #8
0
void daeWriter::apply( osg::Switch &node )
{
    debugPrint( node );
    updateCurrentDaeNode();
    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
    currentNode->setId(getNodeName(node,"switch").c_str());

    if (writeExtras)
    {
        // Adds the following to a node

        //<extra type="Switch">
        //    <technique profile="OpenSceneGraph">
        //        <ValueList>1 0</ValueList>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("Switch");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );

        domAny *valueList = (domAny*)teq->add( "ValueList" );

        std::stringstream fw;
        const osg::Switch::ValueList& values = node.getValueList();
        for(osg::Switch::ValueList::const_iterator itr=values.begin();
            itr!=values.end();
            ++itr)
        {
            if (itr != values.begin())
            {
                fw << " ";
            }
            fw << *itr;
        }
        valueList->setValue(fw.str().c_str());
    }

    writeNodeExtra(node);
    
    lastDepth = _nodePath.size();

    // Process all children
    traverse( node );
}