// select all visible nodes
UInt32 RenderAction::selectVisibles(void)
{
    if(getFrustumCulling() == false)
        return getNNodes();

    useNodeList();

    Color3f col;

    UInt32 count = 0;

    for(UInt32 i = 0; i < getNNodes(); i++)
    {
        if(isVisible(getNode(i)))
        {
            col.setValuesRGB(0,1,0);

            addNode(getNode(i));

            ++count;
        }
        else
        {
            col.setValuesRGB(1,0,0);
        }

        if(getVolumeDrawing())
        {
            dropVolume(this, getNode(i), col);
        }
    }

    return count;
}
Exemplo n.º 2
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;
}
// visibility levels
bool RenderPartition::pushVisibility(Node * const pNode)
{
    if(getFrustumCulling() == false)
        return true;

    FrustumVolume::PlaneSet inplanes = _visibilityStack.back();

    if(inplanes == FrustumVolume::P_ALL)
    {
        _visibilityStack.push_back(inplanes);

        return true;
    }

    Color3f col;
    bool result = true;

    FrustumVolume frustum = _oFrustum;
    BoxVolume     vol     = pNode->getVolume();

    // don't mess with infinite volumes
    if(vol.isInfinite() == false)
    {
        pNode->updateVolume();

        vol = pNode->getVolume();

#if 1
        vol.transform(topMatrix());
#else
    // not quite working
        Matrix m = topMatrix();
        m.invert();

        frustum.transform(m);
#endif
    }

    if(_oDrawEnv.getStatCollector() != NULL)
    {
        _oDrawEnv.getStatCollector()->getElem(statCullTestedNodes)->inc();
    }

    if(intersect(frustum, vol, inplanes) == false)
    {
         result = false;

         col.setValuesRGB(1,0,0);

         if(_oDrawEnv.getStatCollector() != NULL)
         {
             _oDrawEnv.getStatCollector()->getElem(statCulledNodes)->inc();
         }
    }
    else
    {
        if(inplanes == FrustumVolume::P_ALL)
        {
            col.setValuesRGB(0,1,0);
        }
        else
        {
            col.setValuesRGB(0,0,1);
        }
    }

    if(getVolumeDrawing())
    {
        dropVolume(this, pNode, col);
    }

    _visibilityStack.push_back(inplanes);

    return result;
}