OSG_BEGIN_NAMESPACE

#if 0
/*! Return a sphere containing a given box */
void SphereVolume::circumscribe(const BoxVolume &box)
{
    float radius = 0.5 * (box.getMax() - box.getMin()).length();
    Vec3f center;

    box.getCenter(center);

    setValue(center, radius);
}
Пример #2
0
void selectedNodeChanged(void)
{
    mgr->setHighlight(SelectedNode);


    //Update Details Panel
    if(SelectedNode == NULL)
    {
        NodeNameValueLabel->setText("");

        NodeCoreTypeValueLabel->setText("");

        NodeMinValueLabel->setText("");

        NodeMaxValueLabel->setText("");

        NodeCenterValueLabel->setText("");

        NodeTriCountValueLabel->setText("");

        NodeTravMaskValueLabel->setText("");

        NodeOcclusionMaskValueLabel->setText("");

        NodeActiveValueLabel->setText("");

    }
    else
    {
        const Char8 *NodeName = getName(SelectedNode);
        if(NodeName == NULL)
        {
            NodeNameValueLabel->setText("Unnamed Node");
        }
        else
        {
            NodeNameValueLabel->setText(NodeName);
        }

        NodeCoreTypeValueLabel->setText(SelectedNode->getCore()->getType().getCName());

        BoxVolume DyVol;
        SelectedNode->getWorldVolume(DyVol);
        Pnt3f Min,Max,Center;
        DyVol.getBounds(Min,Max);
        DyVol.getCenter(Center);

        std::string TempText("");

        TempText = boost::lexical_cast<std::string>(Min.x()) + ", " +boost::lexical_cast<std::string>(Min.x()) + ", " + boost::lexical_cast<std::string>(Min.x());
        NodeMinValueLabel->setText(TempText);

        TempText = boost::lexical_cast<std::string>(Max.x()) + ", " +boost::lexical_cast<std::string>(Max.x()) + ", " + boost::lexical_cast<std::string>(Max.x());
        NodeMaxValueLabel->setText(TempText);

        TempText = boost::lexical_cast<std::string>(Center.x()) + ", " +boost::lexical_cast<std::string>(Center.x()) + ", " + boost::lexical_cast<std::string>(Center.x());
        NodeCenterValueLabel->setText(TempText);

        //GeometryPrimitivesCounter PrimCounter;
        //PrimCounter(SelectedNode);
        //NodeTriCountValueLabel->setText(boost::lexical_cast<std::string>(PrimCounter.getTriCount()));

        //NodeTravMaskValueLabel->setText(boost::lexical_cast<std::string>(SelectedNode->getTravMask()));

        //NodeOcclusionMaskValueLabel->setText(boost::lexical_cast<std::string>(SelectedNode->getOcclusionMask()));

        //NodeActiveValueLabel->setText(boost::lexical_cast<std::string>(SelectedNode->getActive()));
    }


}
ActionBase::ResultE CubeMapGenerator::renderEnter(Action *action)
{
    static Matrix transforms[] = 
    { 
        Matrix( 1,  0,  0,  0,
                0, -1,  0,  0,
                0,  0, -1,  0,
                0,  0,  0,  1),
        
        Matrix(-1,  0,  0,  0,
                0, -1,  0,  0,
                0,  0,  1,  0,
                0,  0,  0,  1),
        
        Matrix( 1,  0,  0,  0,
                0,  0, -1,  0,
                0,  1,  0,  0,
                0,  0,  0,  1),
        
        Matrix( 1,  0,  0,  0,
                0,  0,  1,  0,
                0, -1,  0,  0,
                0,  0,  0,  1),
        
        Matrix( 0,  0, -1,  0,
                0, -1,  0,  0,
               -1,  0,  0,  0,
                0,  0,  0,  1),
        
        Matrix( 0,  0,  1,  0,
                0, -1,  0,  0,
                1,  0,  0,  0,
                0,  0,  0,  1)
    };

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

    Action::ResultE  returnValue = Action::Continue;

    Background      *pBack    = a->getBackground();

    Viewport        *pPort    = a->getViewport();

    Node            *pActNode = a->getActNode();

    CubeMapGeneratorStageData *pData = 
        a->getData<CubeMapGeneratorStageData *>(_iDataSlotId);

    if(pData == NULL)
    {
        pData = this->initData(a);
    }

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

    if(eStatus == TraversalValidator::Run)
    {
        this->beginPartitionGroup(a);
        {
            FrameBufferObject *pTarget  = this->getRenderTarget();
                
            if(pTarget == NULL)
            {
                pTarget  = pData->getRenderTarget();
            }

            Pnt3f oOrigin;

            if(this->getOriginMode() == CubeMapGenerator::UseStoredValue)
            {
                oOrigin = this->getOrigin();
            }
            else if(this->getOriginMode() == CubeMapGenerator::UseBeacon)
            {
                fprintf(stderr, "CubemapGen::UseBeacon NYI\n");
            }
            else if(this->getOriginMode() == 
                                       CubeMapGenerator::UseCurrentVolumeCenter)
            {
                BoxVolume oWorldVol;

                commitChanges();

                pActNode->updateVolume();
                
                pActNode->getWorldVolume(oWorldVol);
                
                oWorldVol.getCenter(oOrigin);
            }
            else if(this->getOriginMode() == 
                                       CubeMapGenerator::UseParentsVolumeCenter)
            {
                fprintf(stderr, "CubemapGen::UseParentsCenter NYI\n");
            }

            Camera *pCam = pData->getCamera();

            pActNode->setTravMask(0);

            for(UInt32 i = 0; i < 6; ++i)
            {
                this->pushPartition(a);
                {
                    RenderPartition   *pPart    = a->getActivePartition();
                
                    pPart->setVolumeDrawing(false);

                    pPart->setRenderTarget(pTarget       );
                    pPart->setWindow      (a->getWindow());

                    pPart->calcViewportDimension(0,
                                                 0,
                                                 1,
                                                 1,
                                                 this->getWidth (),
                                                 this->getHeight());
                
                    Matrix m, t;
            
                    // set the projection
                    pCam->getProjection          (m, 
                                                  pPart->getViewportWidth (), 
                                                  pPart->getViewportHeight());
                
                    pCam->getProjectionTranslation(t, 
                                                   pPart->getViewportWidth (), 
                                                   pPart->getViewportHeight());
                
                    pPart->setupProjection(m, t);
            
                    m = transforms[i];
            
                    m[3][0] = oOrigin[0];
                    m[3][1] = oOrigin[1];
                    m[3][2] = oOrigin[2];

                    m.invert();

                    pPart->setupViewing(m);
            
                    pPart->setNear     (pCam->getNear());
                    pPart->setFar      (pCam->getFar ());
                    
                    pPart->calcFrustum();
                
                    if(this->getBackground() == NULL)
                    {
                        pPart->setBackground(pBack);
                    }
                    else
                    {
                        pPart->setBackground(this->getBackground());
                    }
                
                    if(this->getRoot() != NULL)
                    {
                        this->recurse(a, this->getRoot());
                    }
                    else
                    {
                        this->recurse(a, pPort->getRoot());
                    }

                    pPart->setDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + i);

#ifdef OSG_DEBUGX
                    std::string szMessage("CubeX\n");
                    pPart->setDebugString(szMessage          );
#endif
                }
                this->popPartition(a);
            }

            pActNode->setTravMask(~0);
        }
        this->endPartitionGroup(a);
    }

    OSG_ASSERT(pActNode == a->getActNode());

    returnValue = Inherited::renderEnter(action);

    action->useNodeList(false);

    return returnValue;
}
Пример #4
0
    void selectedNodeChanged(void)
    {
        _mgr->setHighlight(_SelectedNode);


        //Update Details Panel
        if(_SelectedNode == NULL)
        {
            _NodeNameValueLabel->setText("");

            _NodeCoreTypeValueLabel->setText("");

            _NodeMinValueLabel->setText("");

            _NodeMaxValueLabel->setText("");

            _NodeCenterValueLabel->setText("");

            _NodeTriCountValueLabel->setText("");

            _NodeTravMaskValueLabel->setText("");
        }
        else
        {
            const Char8 *NodeName = getName(_SelectedNode);
            if(NodeName == NULL)
            {
                _NodeNameValueLabel->setText("Unnamed Node");
            }
            else
            {
                _NodeNameValueLabel->setText(NodeName);
            }

            _NodeCoreTypeValueLabel->setText(_SelectedNode->getCore()->getType().getCName());

            BoxVolume DyVol;
            _SelectedNode->getWorldVolume(DyVol);
            Pnt3f Min,Max,Center;
            DyVol.getBounds(Min,Max);
            DyVol.getCenter(Center);

            std::string TempText("");

            TempText = boost::lexical_cast<std::string>(Min.x())
                + ", " +boost::lexical_cast<std::string>(Min.x())
                + ", " + boost::lexical_cast<std::string>(Min.x());
            _NodeMinValueLabel->setText(TempText);

            TempText = boost::lexical_cast<std::string>(Max.x())
                + ", " +boost::lexical_cast<std::string>(Max.x())
                + ", " + boost::lexical_cast<std::string>(Max.x());
            _NodeMaxValueLabel->setText(TempText);

            TempText = boost::lexical_cast<std::string>(Center.x())
                + ", " +boost::lexical_cast<std::string>(Center.x())
                + ", " + boost::lexical_cast<std::string>(Center.x());
            _NodeCenterValueLabel->setText(TempText);

            _NodeTravMaskValueLabel->setText(boost::lexical_cast<std::string>(_SelectedNode->getTravMask()));

            //Tri Cound
            TriCountGraphOpRefPtr TheTriGraphOp = TriCountGraphOp::create();
            TheTriGraphOp->traverse(_SelectedNode);

            _NodeTriCountValueLabel->setText(boost::lexical_cast<std::string>(TheTriGraphOp->getNumTri()));
        }
    }