コード例 #1
0
Action::ResultE ChunkOverrideGroup::renderEnter(Action *action)
{
    RenderAction *pAction = dynamic_cast<RenderAction *>(action);

    if(pAction != NULL)
    {
        pAction->pushState();

        ChunkBlock *pBlock = this->finalize(pAction->getRenderProperties());

        if(pBlock == NULL)
            return Inherited::renderEnter(action);

        MFUnrecStateChunkPtr::const_iterator chIt   = pBlock->beginChunks();
        MFUnrecStateChunkPtr::const_iterator chEnd  = pBlock->endChunks  ();
        UInt32                               uiSlot = 0;

        while(chIt != chEnd)
        {
            if(*chIt != NULL && (*chIt)->getIgnore() == false)
                pAction->addOverride(uiSlot, *chIt);
            
            ++uiSlot;
            ++chIt;
        }
    }

    return Inherited::renderEnter(action);
}
コード例 #2
0
ActionBase::ResultE MaterialChunkOverrideGroup::renderLeave(Action *action)
{
    RenderAction *pAction   = dynamic_cast<RenderAction *>(action);
    Material     *pMaterial = this->getMaterial();

    if(pAction != NULL && pMaterial != NULL)
    {
        pMaterial = pMaterial->finalize(pAction->getRenderProperties(),
                                        pAction->getWindow          ());

        if(pMaterial != NULL) 
        {
            ChunkMaterial *pChunkMaterial = 
                dynamic_cast<ChunkMaterial*>(pMaterial);

            if(pChunkMaterial != NULL) 
            {
                ChunkBlockUnrecPtr pBlock = this->finalize(0x0000);

                if(pBlock != NULL)
                    pBlock->clearChunks();
            }

            return Inherited::renderLeave(action);
        } 
        else 
        {
            pAction->overrideMaterial(NULL, pAction->getActNode());
        }
    }

    return Group::renderLeave(action);
}
コード例 #3
0
ファイル: testFboVP.cpp プロジェクト: mlimper/OpenSG1x
// redraw the window
void display(void)
{
    WindowPtr win = mgr->getWindow();
    
    //mgr->redraw();
    win->activate();
    win->frameInit();
    
    //RenderAction *rAct = (RenderAction*)mgr->getAction();
    
    if (multipass)
    {
        RenderAction *rAct = RenderAction::create();
        
        fbo_vp->setParent(win);
        
        rAct->setWindow(get_pointer(win));
        
        fbo_vp->render(rAct);
        
        fbo_vp->setParent(NullFC);
        
        delete rAct;
        
        //multipass = false;
    }

    win->getPort(0)->render(dynamic_cast<RenderAction *>(mgr->getAction()));
    //win->renderAllViewports(rAct);

    win->swap();
    win->frameExit();
    win->deactivate();
}
コード例 #4
0
ActionBase::ResultE TestMultiPartitionStage::renderLeave(Action *action)
{
#ifdef OSG_DUMP_TRAVERSAL
    FDEBUG_GV(("Leave TestMultiPartStage %p\n", &(*pCore)));
#endif

    RenderAction      *a      = 
        dynamic_cast<RenderAction *>(action);

#ifdef OSG_DEBUGX
    if(this != NULL && this->getMessage().size() != 0)
    {
        fprintf(stderr, "StartLeave MPTS %s\n",
                this->getMessage().c_str());
    }
#endif

    /*StageValidator::ValidationStatus eStatus = */ this->validateOnLeave(a);

#ifdef OSG_DEBUGX
    a->dumpPartitionList();
#endif
    
    return ActionBase::Continue;
}
コード例 #5
0
Action::ResultE MaterialDrawable::renderActionEnterHandler(Action *action)
{
    RenderAction  *a = dynamic_cast<RenderAction *>(action);

    Material      *m         = a->getMaterial();
    PrimeMaterial *pPrimeMat = NULL;

    if(m == NULL)
    {
        if(this->getMaterial() != NULL)
        {
            pPrimeMat =
                this->getMaterial()->finalize(a->getRenderProperties(),
                                              a->getWindow()          );
        }
    }
    else
    {
        pPrimeMat = m->finalize(a->getRenderProperties(),
                                a->getWindow          ());
    }

    if(pPrimeMat == NULL)
    {
        pPrimeMat = getDefaultMaterial();

        FNOTICE(("MaterialDrawable::render: no Material!?!\n"));
    }

    UInt32 uiNPasses = pPrimeMat->getNPasses();

    for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass)
    {
        State *st = pPrimeMat->getState(uiPass);

        if(st != NULL)
        {
            a->dropFunctor(_drawFunc,
                           st,
                           pPrimeMat->getSortKey() + uiPass);
        }
        else
        {
            FINFO(("%s: Material %p has NULL state for pass %d\n",
                   OSG_FUNCNAME_MACRO, pPrimeMat, uiPass));
        }
    }

    if(a->pushVisibility())
    {
        if(a->selectVisibles() == 0)
        {
            a->popVisibility();
            return Action::Skip;
        }
    }

    return Action::Continue;
}
コード例 #6
0
Action::ResultE MaterialDrawable::renderActionLeaveHandler(Action *action)
{
    RenderAction *a = dynamic_cast<RenderAction *>(action);

    a->popVisibility();

    return Action::Continue;
}
コード例 #7
0
Action::ResultE ScreenGroup::renderLeave(Action *action)
{
    RenderAction *pAction = dynamic_cast<RenderAction *>(action);

    pAction->popMatrix();

    return Action::Continue;
}
コード例 #8
0
ファイル: OSGGroup.cpp プロジェクト: mlimper/OpenSG1x
Action::ResultE Group::renderLeave(Action *action)
{
    RenderAction *ra = dynamic_cast<RenderAction *>(action);

    ra->popVisibility();
    
    return Action::Continue;
}
コード例 #9
0
ファイル: OSGIconLabel.cpp プロジェクト: vossg/OSGAddOnsGV
Action::ResultE IconLabel::renderLeave(Action *action)
{
    RenderAction *pAction =
        dynamic_cast<RenderAction *>(action);

    pAction->popVisibility();

    return Action::Continue;
}
コード例 #10
0
ファイル: OSGTextLabel.cpp プロジェクト: chengzg/OSGAddOnsGV
Action::ResultE TextLabel::renderEnter(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    pAction->pushVisibility();

    return Action::Continue;
}
コード例 #11
0
Action::ResultE StackedTransform::renderEnter(Action *action)
{
    RenderAction *pAction = dynamic_cast<RenderAction *>(action);

    pAction->pushVisibility();

    pAction->pushMatrix(this->_mTransformation);

    return Action::Continue;
}
コード例 #12
0
Action::ResultE StackedTransform::renderLeave(Action *action)
{
    RenderAction *pAction = dynamic_cast<RenderAction *>(action);

    pAction->popVisibility();

    pAction->popMatrix();

    return Action::Continue;
}
コード例 #13
0
ActionBase::ResultE MaterialChunkOverrideGroup::renderEnter(Action *action)
{
    RenderAction *pAction   = dynamic_cast<RenderAction *>(action);
    Material     *pMaterial = this->getMaterial();

    if(pAction != NULL && pMaterial != NULL)
    {
        pMaterial = pMaterial->finalize(pAction->getRenderProperties(),
                                        pAction->getWindow          ());

        if(pMaterial) 
        {
            ChunkMaterial *pChunkMaterial = 
                dynamic_cast<ChunkMaterial*>(pMaterial);

            if(pChunkMaterial != NULL) 
            {
                const MFUnrecStateChunkPtr *chunks = 
                    pChunkMaterial->getMFChunks();

                const MFInt32              *slots  = 
                    pChunkMaterial->getMFSlots();

                for(unsigned int i = 0; i < chunks->size(); ++i) 
                {
                    int slot = i < slots->size() ? 
                        (*slots)[i] : 
                        State::AutoSlotReplace;
                    
                    StateChunk *chunk = (*chunks)[i];
                    
                    if(chunk != NULL)
                        this->addChunk(chunk, slot);
                }

                return Inherited::renderEnter(action);
            } 
            else 
            {
                Action::ResultE r = Group::renderEnter(action);

                // ok all children are culled away so we leave
                // immediately and don't set the material!
                if(r == Action::Skip)
                    return r;

                pAction->overrideMaterial(pMaterial, pAction->getActNode());

                return r;
            }
        }
    }

    return Group::renderEnter(action);
}
コード例 #14
0
ファイル: OSGJoint.cpp プロジェクト: msteners/OpenSGToolbox
ActionBase::ResultE Joint::renderLeave(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    pAction->popVisibility();

    pAction->popMatrix();

    return ActionBase::Continue;
}
コード例 #15
0
ファイル: OSGVolumeDraw.cpp プロジェクト: mlimper/OpenSG1x
    static void drop(DrawActionBase *action, const BoxVolume     &volume, Color3f col)
#endif
    {
        VolumeDrawWrapper * vdw = new VolumeDrawWrapper(volume, col);

        Material::DrawFunctor func;
        func = osgTypedMethodFunctor1ObjPtr(vdw, &VolumeDrawWrapper::draw);
    
        RenderAction *ra = dynamic_cast<RenderAction*>(action);
        
        ra->dropFunctor(func, getCPtr(getDefaultUnlitMaterial()));
    }
コード例 #16
0
ActionBase::ResultE ReplicateTransform::renderEnter(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    calcMatrix(pAction->topMatrix());

    pAction->pushVisibility();

    pAction->pushMatrix(_invWorld);

    return Action::Continue;
}
コード例 #17
0
Action::ResultE SkeletonBlendedGeometry::renderLeave(Action *action)
{
    Action::ResultE Result(Inherited::renderLeave(action));

    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    pAction->popVisibility();

    pAction->popMatrix();

    return Action::Continue;
}
コード例 #18
0
Action::ResultE ChunkOverrideGroup::renderLeave(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    if(pAction != NULL)
    {
        pAction->popState();
    }


    return Inherited::renderLeave(action);
}
コード例 #19
0
Action::ResultE SpotLight::renderEnter(Action *action)
{
    RenderAction *a = dynamic_cast<RenderAction *>(action);

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

    return Light::renderEnter(LightEngine::Spot,
                                  a);
}
コード例 #20
0
ファイル: OSGJoint.cpp プロジェクト: msteners/OpenSGToolbox
ActionBase::ResultE Joint::renderEnter(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    pAction->pushVisibility();

    Matrix Transform(this->getMatrix());
    Transform.mult(this->getJointTransformation());
    pAction->pushMatrix(Transform);

    return ActionBase::Continue;
}
コード例 #21
0
ファイル: OSGDVRVolume.cpp プロジェクト: mlimper/OpenSG1x
//! generate draw tree
Action::ResultE DVRVolume::render(Action *action)
{
    FDEBUG(("DVRVolume::render\n"));

    RenderAction *a = dynamic_cast<RenderAction *>(action);

    Material::DrawFunctor func;

    func = osgTypedMethodFunctor1ObjPtr(this, &DVRVolume::draw);

    a->dropFunctor(func, &(*getRenderMaterial()));

    return Action::Continue;
}
コード例 #22
0
ファイル: OSGGroup.cpp プロジェクト: mlimper/OpenSG1x
Action::ResultE Group::renderEnter(Action *action)
{
    RenderAction *ra = dynamic_cast<RenderAction *>(action);

    if (ra->pushVisibility())
    {
        if(ra->selectVisibles() == 0)
        {
            ra->popVisibility();
            return Action::Skip;
        }
    }

    return Action::Continue;
}
コード例 #23
0
Action::ResultE InverseTransform::renderEnter(Action *action)
{
    RenderAction *pAction = 
        dynamic_cast<RenderAction *>(action);

    Matrix mMat;    // will be set to World^-1

    calcMatrix(pAction->topMatrix(), mMat);

    pAction->pushVisibility();

    pAction->pushMatrix(mMat);

    return Action::Continue;
}
コード例 #24
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;
}
コード例 #25
0
ActionBase::ResultE VTKPolyDataMapper::renderEnter(Action *action)
{
    RenderAction *pAction = dynamic_cast<RenderAction *>(action);
    
    this->execute();


    if(pAction == NULL)
        return ActionBase::Skip;

    if(pAction!= NULL)
    {
        pAction->useNodeList();

//    if(pAction->isVisible(getCPtr(_sfRoot.getValue())))
        {
            pAction->addNode(_sfRoot.getValue());
        }
    }

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

    Matrix mMat;

#if 0
    if(!pAction->getEffectsPass())
		calcMatrix(pAction, pAction->top_matrix(), mMat);
	else
		mMat = _camTransform;
#else
    calcMatrix(pAction, pAction->topMatrix(), mMat);
#endif

    pAction->pushMatrix(mMat);

// !!! can't use visibles, as ToWorld gives garbage leading to wrong culling
//    pAction->selectVisibles();

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

    a->disableDefaultPartition();

    Int32 iVPWidth  = a->getActivePartition()->getViewportWidth ();
    Int32 iVPHeight = a->getActivePartition()->getViewportHeight();

    //Initial stage (fill depth buffer)
    this->beginPartitionGroup(a);
    {
        setupRenderScene(a, iVPWidth, iVPHeight, IS_INITIAL, DONTCARE);

        //Peel & Blend Stage
        Int32 numLayers = (getNumPasses() - 1) * 2;

        for (Int32 i=0; i < numLayers; ++i)
        {
            if (i % 2 == 0)
            {
                setupRenderScene(a, iVPWidth, iVPHeight, !IS_INITIAL, IS_PONG);
                setupPostProcess(a, !IS_FINAL, IS_PONG);
            }
            else
            {
                setupRenderScene(a, iVPWidth, iVPHeight, !IS_INITIAL, IS_PING);
                setupPostProcess(a, !IS_FINAL, IS_PING);
            }
        }
        //Final stage: draw quad to default framebuffer
        setupPostProcess(a, IS_FINAL, DONTCARE);
    }
    this->endPartitionGroup(a);

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

    Matrix mMat;    // will be set to World^-1

    calcMatrix(pAction->topMatrix(), mMat);

    pAction->pushVisibility();

    pAction->pushMatrix(mMat);

    Action::ResultE Result(Inherited::renderEnter(action));
    if(Result != Action::Continue)
    {
        pAction->popVisibility();
        pAction->popMatrix();
    }
    return Result;
}
コード例 #29
0
ActionBase::ResultE TestMultiPartitionStage::renderEnter(Action *action)
{
#ifdef OSG_DUMP_TRAVERSAL
    FDEBUG_GV(("Enter TestMultiPartStage %p\n", &(*pCore)));
#endif

    RenderAction *a = dynamic_cast<RenderAction *>(action);

#ifdef OSG_DEBUGX
    if(this != NULL && this->getMessage().size() != 0)
    {
        fprintf(stderr, "StartEnter MPTS %s\n",
                this->getMessage().c_str());
    }
#endif

    TraversalValidator::ValidationStatus eStatus = this->validateOnEnter(a);

    if(eStatus == TraversalValidator::Run)
    {
        if(this->getUseGroup() == true)
        {
            this->beginPartitionGroup(a);
        }
        else
        {
            this->beginPartitions(a);
        }

        for(Int32 i = 0; i < this->getNumPartitions(); ++i)
        {
            this->pushPartition(a);
            {
#ifdef OSG_DEBUG
                RenderPartition *pPart  = a->getActivePartition();
            
                if(this != NULL && this->getMessage().size() != 0)
                {
                    char szNum[16];
                    
                    std::string szMessage = this->getMessage();
                    
                    sprintf(szNum, "%d", i);
                    
                    szMessage += " | Partition ";
                    szMessage += szNum;
                    
                    pPart->setDebugString(szMessage);
                }
#endif

                this->recurseFromThis(a);
            }
            this->popPartition(a);
        }
        
        if(this->getUseGroup() == true)
        {
            this->endPartitionGroup(a);
        }
        else
        {
            this->endPartitions(a);
        }
    }

#ifdef OSG_DEBUGX
    if(this != NULL && this->getMessage().size() != 0)
    {
        fprintf(stderr, "FinishedEnter MPTS %s\n",
                this->getMessage().c_str());
    }
#endif

    return ActionBase::Continue;
}
コード例 #30
0
Action::ResultE
SkeletonSkinningAlgorithm::renderEnter(Action *action)
{
    Action::ResultE  res  = Action::Continue;
    RenderAction    *ract =
        boost::polymorphic_downcast<RenderAction *>(action);

    SkinnedGeometry *skinGeo = getSkin();
    Skeleton        *skel    = skinGeo->getSkeleton();

    skel->renderEnter(action, skinGeo);

    const Skeleton::MFJointsType        *joints       = skel->getMFJoints();
    const Skeleton::MFParentJointsType  *parentJoints =
        skel->getMFParentJoints();
    const Skeleton::MFJointMatricesType *jointMats    =
        skel->getMFJointMatrices();

    UInt32 numJoints = joints->size32();

#ifndef OSG_SKELETON_SKINNING_ALGO_DRAW_AXIS
    _mfDrawPositions.resize(numJoints);
    _mfDrawIndex    .clear (         );

    for(UInt32 i = 0; i < numJoints; ++i)
    {
        (*jointMats)[i].mult(Pnt3f(0.f, 0.f, 0.f),
                             _mfDrawPositions[i]  );

        if((*parentJoints)[i] != NULL)
        {
            _mfDrawIndex.push_back(i                               );
            _mfDrawIndex.push_back((*parentJoints)[i]->getJointId());
        }
    }

#else
    Real32 axisLen = 1.f;

    _mfDrawPositions.resize(4 * numJoints);
    _mfDrawIndex    .clear (             );

    for(UInt32 i = 0; i < numJoints; ++i)
    {
        (*jointMats)[i].mult(Pnt3f(0.f, 0.f, 0.f),
                             _mfDrawPositions[4 * i + 0]);

        if((*parentJoints)[i] != NULL)
        {
            _mfDrawIndex.push_back(4 * i                                + 0);
            _mfDrawIndex.push_back(4 * (*parentJoints)[i]->getJointId() + 0);

            Vec3f vec =
                _mfDrawPositions[4 * i                                + 0] -
                _mfDrawPositions[4 * (*parentJoints)[i]->getJointId() + 0];

            axisLen = 0.2f * vec.length();
            axisLen = 1.f;
        }
        else
        {
            axisLen = 1.f;
        }

        (*jointMats)[i].mult(
            Pnt3f(axisLen, 0.f,     0.f    ), _mfDrawPositions[4 * i + 1]);
        (*jointMats)[i].mult(
            Pnt3f(0.f,     axisLen, 0.f    ), _mfDrawPositions[4 * i + 2]);
        (*jointMats)[i].mult(
            Pnt3f(0.f,     0.f,     axisLen), _mfDrawPositions[4 * i + 3]);

        _mfDrawIndex.push_back(4 * i + 0);
        _mfDrawIndex.push_back(4 * i + 1);
        _mfDrawIndex.push_back(4 * i + 0);
        _mfDrawIndex.push_back(4 * i + 2);
        _mfDrawIndex.push_back(4 * i + 0);
        _mfDrawIndex.push_back(4 * i + 3);
    }
#endif // #ifndef OSG_SKELETON_SKINNING_ALGO_DRAW_AXIS

    DrawEnv::DrawFunctor   drawFuncSkinAlgo =
        boost::bind(&SkeletonSkinningAlgorithm::drawFunc, this, _1);
    PrimeMaterial         *skelMat          = getDefaultUnlitMaterial();
    State                 *state            = skelMat->getState      ();

    ract->dropFunctor(drawFuncSkinAlgo, state, skelMat->getSortKey());

    return res;
}