当前位置: 首页>>代码示例>>C++>>正文


C++ NodeRefPtr::getWorldVolume方法代码示例

本文整理汇总了C++中osg::NodeRefPtr::getWorldVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeRefPtr::getWorldVolume方法的具体用法?C++ NodeRefPtr::getWorldVolume怎么用?C++ NodeRefPtr::getWorldVolume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osg::NodeRefPtr的用法示例。


在下文中一共展示了NodeRefPtr::getWorldVolume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    OSG::osgInit(argc,argv);

    // GLUT init
    int winid = setupGLUT(&argc, argv);

    // open a new scope, because the pointers below should go out of scope
    // before entering glutMainLoop.
    // Otherwise OpenSG will complain about objects being alive after shutdown.
    {
        // the connection between GLUT and OpenSG
        OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
    
        // load the scene
        OSG::NodeRefPtr scene;
        
        if(argc < 2)
        {
            FWARNING(("No file given!\n"));
            FWARNING(("Supported file formats:\n"));
            
            std::list<const char*> suffixes;
            OSG::SceneFileHandler::the()->getSuffixList(suffixes, OSG::SceneFileType::OSG_READ_SUPPORTED);
            
            for(std::list<const char*>::iterator it  = suffixes.begin();
                                                 it != suffixes.end();
                                               ++it)
            {
                FWARNING(("%s\n", *it));
            }
    
            scene = OSG::makeTorus(.5, 2, 16, 16);
        }
        else
        {
            /*
                All scene file loading is handled via the SceneFileHandler.
            */
            scene = OSG::SceneFileHandler::the()->read(argv[1]);
        }
        
        OSG::commitChanges();
        
        // calc size of the scene
        OSG::Vec3f min, max;
        OSG::BoxVolume vol;
        scene->getWorldVolume(vol);
        vol.getBounds(min, max);
    
        OSG::Vec3f  d      = max - min;
        OSG::Real32 offset = d.length() / 2.0f;
        
        // now create a deep clone
        OSG::NodeRefPtr sceneClone = OSG::deepCloneTree(scene);
        
        // this clones all nodes but the cores of type Material and Transform are shared.
        //NodePtr sceneClone = deepCloneTree(scene, "Material, Transform");
        
        // now change all geometries from the cloned scene just to show
        // that it is a real deep copy.
        traverse(sceneClone, &changeGeo);
        
        // create a small scene graph with two transformation nodes.
        OSG::NodeRefPtr               root = OSG::makeCoredNode<OSG::Group>();
        OSG::ComponentTransformRefPtr t1;
        OSG::NodeRefPtr               tn1 = 
            OSG::makeCoredNode<OSG::ComponentTransform>(&t1);
        OSG::ComponentTransformRefPtr t2;
        OSG::NodeRefPtr               tn2 = 
            OSG::makeCoredNode<OSG::ComponentTransform>(&t2);
        
        t1->setTranslation(OSG::Vec3f(- offset, 0.0f, 0.0f));
        t2->setTranslation(OSG::Vec3f(offset, 0.0f, 0.0f));
        
        tn1->addChild(scene);
        tn2->addChild(sceneClone);
        
        root->addChild(tn1);
        root->addChild(tn2);
        
        OSG::commitChanges();
        
        // create the SimpleSceneManager helper
        mgr = new OSG::SimpleSceneManager;
    
        // tell the manager what to manage
        mgr->setWindow(gwin );
        mgr->setRoot  (root);
    
        // show the whole scene
        mgr->showAll();
    }
    
    // GLUT main loop
    glutMainLoop();
//.........这里部分代码省略.........
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:101,代码来源:deepclone.cpp


注:本文中的osg::NodeRefPtr::getWorldVolume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。