Пример #1
0
ActionBase::ResultE Switch::render(Action *action)
{
    ActionBase::ResultE  returnValue = ActionBase::Continue;

    DrawActionBase  *da          = dynamic_cast<DrawActionBase *>(action);

    if((getChoice() >= 0                          ) && 
       (UInt32(getChoice()) < action->getNNodes()))
    {
        da->useNodeList();

        if(da->isVisible(action->getNode(getChoice())))
        {
            da->addNode(action->getNode(getChoice()));
        }
    }
    else if(getChoice() == ALL)
    {
        if(da->selectVisibles() == 0)
        {
            returnValue = ActionBase::Skip;
        }
    }
    else
    {
        returnValue = ActionBase::Skip;
    }

    return returnValue;
}
Пример #2
0
Action::ResultE ShadingCallbacks::switchRender(CNodePtr &pNode, 
                                               Action   *action)
{
    Action::ResultE  returnValue = Action::Continue;

    DrawActionBase  *da  = dynamic_cast<DrawActionBase *>(action         );
    Switch          *pSw = dynamic_cast<Switch         *>(pNode.getCPtr());

    if((pSw->getChoice() >= 0                  ) && 
       (pSw->getChoice() <  action->getNNodes())  )
    {
        da->useNodeList();

        if(da->isVisible(action->getNode(pSw->getChoice()).getCPtr()))
        {
            da->addNode(action->getNode(pSw->getChoice()));
        }
    }
    else if(pSw->getChoice() == Switch::ALL)
    {
        if(da->selectVisibles() == 0)
            returnValue = Action::Skip;
    }
    else
    {
        returnValue = Action::Skip;
    }

    return returnValue;
}
Пример #3
0
Action::ResultE Group::drawEnter(Action *action)
{
    DrawActionBase *da = dynamic_cast<DrawActionBase *>(action);

    if(da->selectVisibles() == 0)
        return Action::Skip;
    
    return Action::Continue;
}
Пример #4
0
Action::ResultE DirectionalLight::renderEnter(Action *action)
{
    if(getOn() == false)
        return Action::Continue;

    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);
    da->getStatistics()->getElem(DirectionalLight::statNDirectionalLights)->inc();
    
    return Light::renderEnter(action);
}
Пример #5
0
Action::ResultE ShadingCallbacks::groupRenderEnter(CNodePtr &, 
                                                   Action   *action)
{
    DrawActionBase *da = dynamic_cast<DrawActionBase *>(action);

    if(da->selectVisibles() == 0)
        return Action::Skip;
    
    return Action::Continue;
}
Пример #6
0
Action::ResultE ShadingCallbacks::spotlightRenderEnter(CNodePtr &pNode, 
                                                       Action   *action)
{
    SpotLight *pSp = dynamic_cast<SpotLight *>(pNode.getCPtr());

    if(pSp->getOn() == false)
        return Action::Continue;

    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);

    da->getStatistics()->getElem(SpotLight::statNSpotLights)->inc();

    return pointlightRenderEnter(pNode, action);
}
Пример #7
0
Action::ResultE SpotLight::renderEnter(Action *action)
{
    if(getOn() == false)
        return Action::Continue;

    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);

    if(da->getStatCollector() != NULL)
    {
        da->getStatCollector()->getElem(SpotLight::statNSpotLights)->inc();
    }

    return PointLight::renderEnter(action);
}
Пример #8
0
Action::ResultE ShadingCallbacks::dirlightRenderEnter(CNodePtr &pNode, 
                                                      Action   *action)
{
    DirectionalLight *pDl = dynamic_cast<DirectionalLight *>(pNode.getCPtr());

    if(pDl->getOn() == false)
        return Action::Continue;

    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);

    da->getStatistics()->getElem(
        DirectionalLight::statNDirectionalLights)->inc();
    
    return lightRenderEnter(pDl, action);
}
Пример #9
0
Action::ResultE ProxyGroup::render(Action *action)
{
    DrawActionBase *da        = dynamic_cast<DrawActionBase *>(action);

    if(getEnabled() == false)
        return Action::Continue;

    if(getState() == NOT_LOADED)
        startLoading();

    if(getState() == LOAD_THREAD_FINISHED)
    {
        if(_loadedRoot != NULL)
        {
            _loadThread = NULL;

            setRoot(_loadedRoot);

            getRoot()->invalidateVolume();
            getRoot()->updateVolume();


            setState(LOADED);

            da->getActNode()->invalidateVolume();
            da->getActNode()->updateVolume    ();
        }
        else
        {
            SWARNING << "failed to load " << getAbsoluteUrl() << std::endl;

            setState(LOAD_ERROR);
        }
    }

    if(getState() == LOADED)
    {
        da->useNodeList();

        if(da->isVisible(getCPtr(getRoot())))
            da->addNode(getRoot());
    }
    else
    {
        if(da->getActNode()->getNChildren() == 0)
        {
            Color3f col;
            col.setValuesRGB(.5,.3,0);            

            dropVolume(da, da->getActNode(), col);
        }
    }

    // thread cleanup
    if(_loadThread && _loadQueue.empty())
    {
        printf("join\n");
        BaseThread::join(_loadThread);
        _loadThread = NULL;
    }

    return Action::Continue;
}
Пример #10
0
Action::ResultE ShadingCallbacks::distanceLODRender(CNodePtr &pNode, 
                                                    Action   *action)
{
    DrawActionBase *da    = dynamic_cast<DrawActionBase *>(action);
    ShadingAction  *ra    = dynamic_cast<ShadingAction  *>(action);

    DistanceLOD    *pDLOD = dynamic_cast<DistanceLOD    *>(pNode.getCPtr());


    UInt32 numLevels = action->getNNodes ();
    UInt32 numRanges = pDLOD ->getMFRange()->size();

    UInt32 limit     = osgMin(numLevels, numRanges); 
    
    Int32  index     = -1;

    Pnt3f  eyepos(0.f, 0.f, 0.f);
    Pnt3f  objpos;

    da->getCameraToWorld().mult(eyepos);

    if(ra != NULL)
    {
        ra->top_matrix()              .mult(pDLOD->getCenter(), objpos);
    }
    else
    {
        da->getActNode()->getToWorld().mult(pDLOD->getCenter(), objpos);
    }
        
    Real32 dist = osgsqrt((eyepos[0] - objpos[0])*(eyepos[0] - objpos[0]) +
                          (eyepos[1] - objpos[1])*(eyepos[1] - objpos[1]) +
                          (eyepos[2] - objpos[2])*(eyepos[2] - objpos[2]));
    
    da->useNodeList();
    
    if(numRanges != 0 && numLevels!=0 )
    {
        if(dist < (*(pDLOD->getMFRange()))[0])
        {
            index = 0;
        } 
        else if(dist >= (*(pDLOD->getMFRange()))[numRanges-1])
        {
	    index = (numLevels > numRanges) ? numRanges : (limit-1); 
        }
        else
        {
            UInt32 i = 1;

            while( (i < numRanges) && 
                  !( ((*(pDLOD->getMFRange()))[i-1] <= dist) && 
                     (dist < (*(pDLOD->getMFRange()))[i]   )   ) )
            {
                i++;
            }
            
            index = osgMin(i, limit-1);
        } 
        
        if(da->isVisible(action->getNode(index).getCPtr()))
        {
            da->addNode(action->getNode(index));
        }
    }

    return Action::Continue;
}
Пример #11
0
Action::ResultE DistanceLOD::draw(Action *action)
{
	DrawActionBase *da = dynamic_cast<DrawActionBase *>(action);
	RenderAction   *ra = dynamic_cast<RenderAction *>  (action);
	
    action->useNodeList();

    UInt32 numLevels = action->getNNodes();
    Int32 index = -1;
    
    if (numLevels == 0)
    {
    	// update index field for being externally accessible
    	if (index != getIndex() && (!ra || !ra->getEffectsPass()))
    	{
			beginEditCP(getPtr(), IndexFieldMask);
				setIndex(index);
			endEditCP  (getPtr(), IndexFieldMask);
		}
		
        return Action::Continue;
    }

    const MFReal32 &range = (*getMFRange());
    UInt32 numRanges = range.size();
	
    if (numRanges == 0)
    {
        index = 0;
    }
    else
    {
        Real32 dist = 0;
		
        if (ra != NULL)
		{
			if (!ra->getEffectsPass())
				dist = calcDistance(da, ra->top_matrix());
			else
				dist = _lastDist;
		}
        else
            dist = calcDistance(da, da->getActNode()->getToWorld());

        if (numRanges >= numLevels)
            numRanges = numLevels - 1;

        if(numRanges == 0)
        {
            index = 0;
        }
        else if (dist >= range[numRanges - 1])
        {
            index = numRanges;
        }
        else
        {
            for (index = 0; index < numRanges; ++index)
            {
                if (dist < range[index])
                    break;
            }
        }
    }
    
    // update index field for being externally accessible
	if (index != getIndex() && (!ra || !ra->getEffectsPass()))
	{
		beginEditCP(getPtr(), IndexFieldMask);
			setIndex(index);
		endEditCP  (getPtr(), IndexFieldMask);
	}

    const NodePtr nodePtr = action->getNode(index);
    
    if(da->isVisible(getCPtr(nodePtr)))
    {
        da->addNode(nodePtr);
    }

    return Action::Continue;
}