コード例 #1
0
void RenderAction::popPartition(void)
{
    RenderPartition *pCurrPart = _pActivePartition;

    _pActivePartition    = _sRenderPartitionStack   .top();
    _iActivePartitionIdx = _sRenderPartitionIdxStack.top();
    _bInPartitionGroup   = _sRenderPartitionGrpStack.top();

    _actNode = _pActivePartition->getNode();

    _sRenderPartitionStack   .pop();
    _sRenderPartitionIdxStack.pop();
    _sRenderPartitionGrpStack.pop();

    if(_bDrawPartPar == true)
    {
        if(pCurrPart->getRenderTarget() == NULL  && 
           _bDefaultPartHandled         == false  )
        {
            _pActivePartition->setTaskType(RenderPartition::Setup);
            _pWindow->queueTaskFromDrawer(
                _vRenderPartitions[_currentBuffer][0]);

            _bDefaultPartHandled = true;
        }

        _pWindow->queueTaskFromDrawer(pCurrPart);

#ifdef OSG_RENPART_DUMP_PAR
        fprintf(stderr, "queue %p\n", pCurrPart);
        fflush(stderr);
#endif
    }
}
コード例 #2
0
ActionBase::ResultE DeferredShadingStage::renderEnter(Action *action)
{
    RenderAction *ract = dynamic_cast<RenderAction *>(action);

    if(ract == NULL)
        return Action::Continue;

    RenderPartition   *parentPart = ract->getActivePartition();
    FrameBufferObject *target     = this->getRenderTarget   ();

    if(target == NULL && this->getInheritedTarget() == true)
    {
        target = parentPart->getRenderTarget();
    }

    DSStageData *data = ract->getData<DSStageData *>(_iDataSlotId);

    if(data == NULL)
    {
        DSStageDataUnrecPtr newData = createStageData();
        data = newData;

        setData(newData, _iDataSlotId, ract);
    }

    updateStageData(data, target, parentPart);

    this->beginPartitionGroup(ract);
    {
        // render the tree below this to gBufferTarget using gBufferShader
        scheduleGBufferPass(ract);

        // render a quad to this stage's target using shadingShader
        scheduleShadingPass(ract);
    }
    this->endPartitionGroup(ract);

    commitChanges();

    return Action::Skip;
}
コード例 #3
0
Action::ResultE Stage::renderEnter(Action *action)
{
    RenderAction *a = dynamic_cast<RenderAction *>(action);

    if(a == NULL)
        return Action::Continue;

    RenderPartition   *pParentPart = a->getActivePartition();
    FrameBufferObject *pTarget     = this->getRenderTarget();

    if(pTarget == NULL && this->getInheritedTarget() == true)
    {
        pTarget = pParentPart->getRenderTarget();
    }

    this->pushPartition(a);

    RenderPartition   *pPart    = a->getActivePartition();
    Viewarea          *pArea    = a->getViewarea();
    Camera            *pCam     = a->getCamera  ();
    Background        *pBack    = a->getBackground();
    
    pPart->setRenderTarget(pTarget);

    if(pArea != NULL)
    {
        pPart->setWindow  (a->getWindow());
            
        if(pTarget != NULL)
        {
            pPart->calcViewportDimension(pArea->getLeft  (),
                                         pArea->getBottom(),
                                         pArea->getRight (),
                                         pArea->getTop   (),
                                         
                                         pTarget->getWidth    (),
                                         pTarget->getHeight   ());
        }
        else
        {
            pPart->calcViewportDimension(pArea->getLeft  (),
                                         pArea->getBottom(),
                                         pArea->getRight (),
                                         pArea->getTop   (),
                                         
                                         a->getWindow()->getWidth (),
                                         a->getWindow()->getHeight());
        }
        
        if(pCam != NULL)
        {
            Matrix m, t;
            
            // set the projection
            pCam->getProjection          (m, 
                                          pPart->getViewportWidth (), 
                                          pPart->getViewportHeight());
            
            pCam->getProjectionTranslation(t, 
                                           pPart->getViewportWidth (), 
                                           pPart->getViewportHeight());
                
            pPart->setupProjection(m, t);
            
            pCam->getViewing(m, 
                             pPart->getViewportWidth (),
                             pPart->getViewportHeight());
            
            
            pPart->setupViewing(m);
            
            pPart->setNear     (pCam->getNear());
            pPart->setFar      (pCam->getFar ());
            
            pPart->calcFrustum();
        }
    }

    pPart->setBackground(pBack);

    return Action::Continue;
}
コード例 #4
0
ActionBase::ResultE GroupingStage::renderEnter(Action *action)
{
    RenderAction *a = dynamic_cast<RenderAction *>(action);

    if(a == NULL)
        return ActionBase::Continue;

#if 0
    RenderPartition   *pParentPart = a   ->getActivePartition();
    FrameBufferObject *pTarget     = pParentPart->getRenderTarget();
#endif

    this->pushPartition(a, RenderPartition::CopyAll);

    RenderPartition   *pPart   = a->getActivePartition();

    Inherited::addCallbacks(pPart);

#if 0
    RenderPartition   *pParentPart = a   ->getActivePartition();
    FrameBufferObject *pTarget     = this->getRenderTarget();

    Background        *pBack   = this->getBackground();
    Viewport          *pPort   = a->getViewport();
    Window            *pWin    = a->getWindow  ();


    if(pTarget == NULL && this->getInheritedTarget() == true)
    {
        pTarget = pParentPart->getRenderTarget();
    }

    
    RenderPartition   *pPart   = a->getActivePartition();
    Camera            *pCam    = this->getCamera();
    
    pPart->setRenderTarget(pTarget);
    
//    pPart->setViewport(pPort);
    pPart->setWindow  (pWin );
    
    if(pTarget != NULL)
    {
        pPart->calcViewportDimension(this->getLeft  (),
                                     this->getBottom(),
                                     this->getRight (),
                                     this->getTop   (),
                                     
                                     pTarget->getWidth    (),
                                     pTarget->getHeight   ());
    }
    else if(pWin != NULL)
    {
        pPart->calcViewportDimension(this->getLeft  (),
                                     this->getBottom(),
                                     this->getRight (),
                                     this->getTop   (),
                                     
                                     pWin->getWidth   (),
                                     pWin->getHeight  ());
    }
    
    if(pCam != NULL)
    {
        Matrix m, t;
        
        // set the projection
        pCam->getProjection          (m, 
                                      pPart->getViewportWidth (), 
                                      pPart->getViewportHeight());
        
        pCam->getProjectionTranslation(t, 
                                       pPart->getViewportWidth (), 
                                       pPart->getViewportHeight());
        
        pPart->setupProjection(m, t);
        
        pCam->getViewing(m, 
                         pPart->getViewportWidth (),
                         pPart->getViewportHeight());
        
        
        pPart->setupViewing(m              );
        
        pPart->setNear     (pCam->getNear());
        pPart->setFar      (pCam->getFar ());
        
        pPart->calcFrustum (               );
        
    }
    
    this->fillPreRenderStore(vCallbackStore);

    GroupingStage::RenderFunctorStore::const_iterator cbIt  = 
        vCallbackStore.begin();

    GroupingStage::RenderFunctorStore::const_iterator cbEnd = 
        vCallbackStore.end  ();

    while(cbIt != cbEnd)
    {
        pPart->addPreRenderCallback(*cbIt);
        
        ++cbIt;
    }


    vCallbackStore.clear();

    this->fillPostRenderStore(vCallbackStore);

    cbIt  = vCallbackStore.begin();
    cbEnd = vCallbackStore.end  ();

    while(cbIt != cbEnd)
    {
        pPart->addPostRenderCallback(*cbIt);
        
        ++cbIt;
    }


    pPart->setBackground(pBack);
#endif

    return ActionBase::Continue;
}