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


C++ SimpleSceneManagerRefPtr::showAll方法代码示例

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


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

示例1: keyboard

// react to keys
void keyboard(unsigned char k, int x, int y)
{
    switch(k)
    {
        case 27:    
        {
            _mgr         = NULL;

            _client_win  = NULL;
            _cluster_win = NULL;
            _root        = NULL;

            OSG::osgExit();
            exit(0);
        }
        case 'n':
            while(_root->getNChildren() > 0)
                _root->subChild(_root->getChild(0));

            glutPostRedisplay();
        break;
        case 'l':
        {
            OSG::NodeUnrecPtr scene = 
                OSG::SceneFileHandler::the()->read("tie.wrl", NULL);

            if(scene != NULL)
            {
                _root->addChild(scene);

                _mgr->showAll();

                glutPostRedisplay();
            }
        }
        break;
        case 't':
        {
            OSG::NodeUnrecPtr scene = OSG::makeTorus(.5, 2, 16, 16);

            _root->addChild(scene);

            _mgr->showAll();

            glutPostRedisplay();
        }
        break;
        case 'c':
            connectCluster();
        break;
        case 'd':
            disconnectCluster();
        break;
    }
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:56,代码来源:testDynamicClusterClient.cpp

示例2: 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);

    // the connection between GLUT and OpenSG
    g_win= OSG::GLUTWindow::create();
    g_win->setGlutId(winid);
    g_win->init();

    g_scene = createScene();

    // create the SimpleSceneManager helper
    g_mgr = OSG::SimpleSceneManager::create();
    g_mgr->setUseTraversalAction(true);

    // tell the manager what to manage
    g_mgr->setWindow(g_win );
    g_mgr->setRoot  (g_scene);

    // add LabelForeground!!!
    g_labelForeground = OSG::LabelForeground::create();
    g_mgr->addForeground(g_labelForeground);

    // show the whole scene
    g_mgr->showAll();

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:chengzg,项目名称:OSGAddOnsGV,代码行数:36,代码来源:testLabeling.cpp

示例3: doMain

// Initialize GLUT & OpenSG and set up the scene
int doMain(int argc, char **argv)
{
    std::cout << "start a cluster server with './testClusterServer -w pipe0'\n"
                 "press 'c' to connect to the servers.\n"
                 "press 'd' to disconnect from the servers.\n"
                 "press 'n' to delete current scene.\n"
                 "press 't' to create a torus.\n"
                 "press 'l' to load scene 'tie.wrl'.\n"
              << std::endl;
    
    // OSG init
    OSG::osgInit(argc,argv);

    OSG::VTKPolyDataMapper::getClassType().dump();

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

    // the connection between GLUT and OpenSG

    _client_win = OSG::GLUTWindow::create();

    _client_win->setGlutId(winid);
    _client_win->init();
    _client_win->setSize(300,300);
    
    for(OSG::Int32 i=0;i<argc-1;++i)
    {
        if(argv[i+1] != NULL)
            _pipenames.push_back(argv[i+1]);
    }

    if(_pipenames.empty())
        _pipenames.push_back("pipe0");
    
    _root = OSG::Node::create();
    
    _root->setCore(OSG::Group::create());
    
    // create default scene
//    NodePtr scene = makeTorus(.5, 2, 16, 16);
    OSG::NodeUnrecPtr scene = initVTK();

    _root->addChild(scene);

    // create the SimpleSceneManager helper
    _mgr = OSG::SimpleSceneManager::create();

    // tell the manager what to manage
    _mgr->setWindow(_client_win );
    _mgr->setRoot  (_root);

    // show the whole scene
    _mgr->showAll();
    

    return 0;
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:59,代码来源:testVTKClusterConnect.cpp

示例4: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
	//sortNumbers function
	int numberArray[] = {2, 13, 56, 8, 22, 16, 24, 89, 11, 90}; 
	sortNumbers(numberArray,10);

    // OSG init
    OSG::osgInit(argc,argv);

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

    // open a new scope, because the pointers gwin and scene 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();
    
        // create the scene
        OSG::NodeRefPtr scene = OSG::makeBox(1,1,1,2,2,2);
    
        OSG::commitChanges();
    
        // create the SimpleSceneManager helper
        mgr = OSG::SimpleSceneManager::create();
    
        // tell the manager what to manage
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
    
        // show the whole scene
        mgr->showAll();
    }
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:karinarodriguez,项目名称:CI312Tutorials14,代码行数:43,代码来源:01SimpleExample.cpp

示例5: main

int main(int argc, char* argv[])
{
    std::cerr << argv[0] << ". Press 'h' for keys" << std::endl;
    
    // Init OSG and glut.
    OSG::osgInit(argc,argv);
    {
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
        
        printFontFamilies();
        
        // load the scene
        OSG::NodeRefPtr scene = OSG::Node::create();
        scene->setCore(OSG::Group::create());
        
        // Setup text sample
        gTextStuff = new TextStuff();
        gTextStuff->initialize();
        gTextStuff->updateFace();
        gTextStuff->updateScene();
        scene->addChild(gTextStuff->mRootNode);
        
        mgr = OSG::SimpleSceneManager::create();
        
        // Tell the manager about the window and scene
        mgr->setWindow(gwin );
        mgr->setRoot(scene);
        
        // Start it up
        mgr->showAll();
    }
    
    glutMainLoop();

    return 0;
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:39,代码来源:testTextParams.cpp

示例6: main

int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);
    
    {
        int winid = setupGLUT(&argc, argv);
        OSG::GLUTWindowRecPtr gwin= OSG::GLUTWindow::create();
        gwin->setGlutId(winid);
        gwin->init();
        
        scene = createScenegraph();
        
        mgr = OSG::SimpleSceneManager::create();
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
        mgr->showAll();
        
        OSG::commitChanges();
    }
    
    glutMainLoop();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:24,代码来源:05loading.cpp

示例7: main

int main(int argc, char **argv)
{
    OSG::osgInit(argc,argv);
    
    if(argc > 1 && !strcmp(argv[1],"-s"))
    {
        show = false;
        argv++;
        argc--;
    }
    
    if(argc > 1 && !strcmp(argv[1],"-d"))
    {
        debug = true;
        argv++;
        argc--;
    }

    
    if(argc > 1)
    {
        scene = OSG::Node::create();
        OSG::GroupUnrecPtr g = OSG::Group::create();
        
        scene->setCore(g);
        
        for(OSG::UInt16 i = 1; i < argc; ++i)
            scene->addChild(OSG::SceneFileHandler::the()->read(argv[i]));
    }
    else
    {
        scene = OSG::makeTorus(.5, 3, 16, 16);
    }

    // GLUT init
    glutInit(&argc, argv);
    
    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

    glutInitWindowSize(1024, 768);
    mainwinid = glutCreateWindow("OpenSG");
    
    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(idle);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    OSG::GLUTWindowUnrecPtr mainwin=OSG::GLUTWindow::create();
    mainwin->setGlutId(mainwinid);
    mainwin->init();
    
    // create the SimpleSceneManager helper
    mgr = OSG::SimpleSceneManager::create();

    // create the window and initial camera/viewport
    mgr->setWindow(mainwin);
    // tell the manager what to manage
    mgr->setRoot  (scene);

    OSG::commitChanges();

    // show the whole scene
    mgr->showAll();

    mgr->setUseTraversalAction(true);

    tact      = OSG::RenderAction::create();
#ifdef OSG_OLD_RENDER_ACTION
    act       = OSG::RenderAction::create();
#endif
    debugact  = OSG::RenderAction::create();
    tact->setOcclusionCulling(true);


    // Open the debug window
    if(debug)
    {
        OSG::traverse(scene, initMask);

        glutInitWindowSize(800, 400);
        debugwinid = glutCreateWindow("OpenSG Occlusion Debugging");

        glutReshapeFunc(reshape);
        glutDisplayFunc(display);
        glutIdleFunc(display);
        glutKeyboardFunc(keyboard);

        debugwin=OSG::GLUTWindow::create();
        debugwin->setGlutId(debugwinid);
        debugwin->init();       
        
        OSG::ViewportUnrecPtr vp = mainwin->getPort(0);
        
        OSG::ViewportUnrecPtr newvp = OSG::Viewport::create();        
        newvp->setLeft(0);
        newvp->setRight(0.5);
        newvp->setBottom(0);
        newvp->setTop(1);
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:101,代码来源:testOcclusionCulling.cpp

示例8: keyboard


//.........这里部分代码省略.........
        std::cout << "Volume drawing: "
                  << (mgr->getRenderAction()->getVolumeDrawing() ? "enabled" : "disabled")
                  << std::endl;
    }
    break;
    case 'p':
    {
        OSG::SceneGraphPrinter sgp(mgr->getRoot());
        sgp.addPrintFunc(OSG::SkinnedGeometry::getClassType(),
                         &printVolume                         );
        sgp.printDownTree(std::cout);

        NodeStore::const_iterator nIt  = skinnedGeoN.begin();
        NodeStore::const_iterator nEnd = skinnedGeoN.end  ();

        for(OSG::UInt32 i = 0; nIt != nEnd; ++nIt, ++i)
        {
            OSG::SkinnedGeometry *sgeo = dynamic_cast<OSG::SkinnedGeometry *>(
                (*nIt)->getCore());

            std::cout << "Skeleton:\n";
            OSG::SceneGraphPrinter skelPrinter(sgeo->getSkeleton()->getRoots(0));
            skelPrinter.addPrintFunc(OSG::Transform    ::getClassType(),
                                     &printXForm                        );
            //skelPrinter.addPrintFunc(OSG::SkeletonJoint::getClassType(),
            //                         &printJoint                        );
            skelPrinter.printDownTree(std::cout);
        }
    }
    break;

    case 'a':
    {
        mgr->showAll();

        std::cout << "Showing all of scene." << std::endl;
    }
    break;

    case '[':
    {
        if(anims.empty() == false)
        {
            currAnim -= 1;
            if(currAnim < 0)
                currAnim = anims.size() - 1;

            std::cout << "Current anim [" << currAnim << "] - ["
                      << anims[currAnim].anim->getTemplate()->getName()
                      << "]" << std::endl;
        }
    }
    break;
    case ']':
    {
        if(anims.empty() == false)
        {
            currAnim += 1;
            if(currAnim >= OSG::Int32(anims.size()))
                currAnim = 0;

            std::cout << "Current anim [" << currAnim << "] - ["
                      << anims[currAnim].anim->getTemplate()->getName()
                      << "]" << std::endl;
        }
    }
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:67,代码来源:testColladaLoader.cpp

示例9: main


//.........这里部分代码省略.........
    
                    light_core = l;
                }
                break;
                
                /*
                    The SpotLight adds a direction to the PointLight and a
                    spotCutOff angle to define the area that's lit. To define the
                    light intensity fallof within that area the spotExponent field
                    is used.
    
                    Spot lights are very expensive to compute, use them sparingly.
                */
                case 2:
                {
                    OSG::SpotLightRefPtr l = OSG::SpotLight::create();
                    
                    l->setPosition             (OSG::Pnt3f(0,  0, 0));
                    l->setDirection            (OSG::Vec3f(0, -1, 0));
                    l->setSpotExponent         (2);
                    l->setSpotCutOff           (OSG::osgDegree2Rad(45));
                    l->setConstantAttenuation  (1);
                    l->setLinearAttenuation    (0);
                    l->setQuadraticAttenuation (3);
                    
                    // a little cone to show where the light is
                    geo_node = OSG::makeCone(.2f, .2f, 8, true, true);
    
                    OSG::GeometryRefPtr       geo =
                        dynamic_cast<OSG::Geometry *>(geo_node->getCore());
                    OSG::SimpleMaterialRefPtr sm  = 
                        OSG::SimpleMaterial::create();
    
                    sm->setLit(false);
                    sm->setDiffuse(OSG::Color3f( colors[i][0], 
                                                 colors[i][1],
                                                 colors[i][2] ));
    
                    geo->setMaterial(sm);
    
                    light_core = l;
                }
                break;
            }
            
            // create the beacon and attach it to the scene
            OSG::NodeRefPtr         beacon      = OSG::Node::create();
            OSG::TransformRefPtr    beacon_core = OSG::Transform::create();
            
            lightBeacons[i] = beacon_core;
            
            beacon->setCore(beacon_core);
            beacon->addChild(geo_node);
        
            scene->addChild(beacon);
                
            light_core->setAmbient (colors[i][0] / scale,
                                    colors[i][1] / scale,
                                    colors[i][2] / scale,
                                    1);
            light_core->setDiffuse (colors[i][0] / scale,
                                    colors[i][1] / scale,
                                    colors[i][2] / scale,
                                    1);
            light_core->setSpecular(1 / scale,
                                    1 / scale,
                                    1 / scale,
                                    1);
            light_core->setBeacon  (beacon);
    
            light->setCore(light_core);
            light->addChild(lastnode);
            
            lights[i] = light_core;
            lastnode = light;
        }
    
        scene->addChild(lastnode);
    
        OSG::commitChanges();
    
        // create the SimpleSceneManager helper
        mgr = OSG::SimpleSceneManager::create();
    
        // tell the manager what to manage
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
        
        // switch the headlight off, we have enough lights as is
        mgr->setHeadlight(false);
    
        // show the whole scene
        mgr->showAll();
    }
    
    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:101,代码来源:lights.cpp

示例10: main


//.........这里部分代码省略.........
        
        // The torus and its transformation
        OSG::NodeRefPtr     torus    = OSG::Node::create();
        OSG::GeometryRefPtr torusgeo = OSG::makeTorusGeo( .2f, 1, 24, 36 );
        
        torus->setCore(torusgeo);
            
        tortrans = OSG::Transform::create();
    
        OSG::NodeRefPtr tortransnode = OSG::Node::create();
        tortransnode->setCore (tortrans);
        tortransnode->addChild(torus   );
        
        // add it to the scene
        scene->addChild(tortransnode);

        //
        // create the shader program
        //
        OSG::ShaderProgramChunkRefPtr prog_chunk = OSG::ShaderProgramChunk::create();
        OSG::ShaderProgramRefPtr      vertShader = OSG::ShaderProgram::createVertexShader();
        OSG::ShaderProgramRefPtr      fragShader = OSG::ShaderProgram::createFragmentShader();

        vertShader->setProgram(get_vp_program());
        fragShader->setProgram(get_fp_program());

        //
        // binding the unifrom block to a buffer binding point can be performed 
        // either by calling the shaders's addUniformBlock method or by
        // adding a 'uniform block' variable to a ShaderProgramVariableChunk.
        // In the following we use both variants for illustration.
        //
        fragShader->addUniformBlock("Materials", 1);    // block binding point
        fragShader->addUniformBlock("Lights",    2);    // block binding point

        //
        // The following is replaced by adding ShaderProgramVariableChunk objects
        // to the chunk material. See below...
        //
        // fragShader->addUniformBlock("GeomState", 3);    // block binding point

        prog_chunk->addShader(vertShader);
        prog_chunk->addShader(fragShader);

        //
        // create uniform buffer objects and corresponding materials
        //
        OSG::UniformBufferObjChunkRefPtr ubo_material_database = create_material_database_state(materials);
                                         ubo_light_state       = create_light_state(lights);

        OSG::PolygonChunkRefPtr polygon_chunk = OSG::PolygonChunk::create();
        polygon_chunk->setFrontMode(GL_FILL);
        polygon_chunk->setBackMode(GL_FILL);
        polygon_chunk->setCullFace(GL_NONE);

        OSG::DepthChunkRefPtr depth_chunk = OSG::DepthChunk::create();
        depth_chunk->setEnable(true);

        OSG::ChunkMaterialRefPtr prog_state = OSG::ChunkMaterial::create();
        prog_state->addChunk(ubo_material_database, 1);  // buffer binding point 1
        prog_state->addChunk(ubo_light_state,       2);  // buffer binding point 2
        prog_state->addChunk(prog_chunk);
        prog_state->addChunk(polygon_chunk);
        prog_state->addChunk(depth_chunk);

        OSG::ShaderProgramVariableChunkRefPtr shader_var_chunk = OSG::ShaderProgramVariableChunk::create();
        shader_var_chunk->addUniformBlock("GeomState", 3);

        GeomState geom1; geom1.material_index = dist(generator);
        OSG::ChunkMaterialRefPtr geom1_state = OSG::ChunkMaterial::create();
        ubo_geom_state_1 = create_geometry_material_state(geom1);
        geom1_state->addChunk(ubo_geom_state_1, 3);     // buffer binding point 3
        geom1_state->addChunk(shader_var_chunk);        // block binding point

        GeomState geom2; geom2.material_index = dist(generator);
        OSG::ChunkMaterialRefPtr geom2_state = OSG::ChunkMaterial::create();
        ubo_geom_state_2 = create_geometry_material_state(geom2);
        geom2_state->addChunk(ubo_geom_state_2, 3);     // buffer binding point 3
        geom1_state->addChunk(shader_var_chunk);        // block binding point
       
        cylgeo  ->setMaterial(geom1_state);
        torusgeo->setMaterial(geom2_state);

        OSG::MaterialChunkOverrideGroupRefPtr mgrp = OSG::MaterialChunkOverrideGroup::create();
        mgrp->setMaterial(prog_state);
        scene->setCore(mgrp);

        OSG::commitChanges();
    
        mgr->setRoot(scene);
    
        // show the whole scene
        mgr->showAll();
    }

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:marcusl,项目名称:OpenSG,代码行数:101,代码来源:shaderstoragebufferobject.cpp

示例11: init

void init(int argc, char *argv[])
{
    OSG::osgInit(argc, argv);

    int glutWinId = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG
    OSG::GLUTWindowUnrecPtr gwin= OSG::GLUTWindow::create();
    gwin->setGlutId(glutWinId);
    gwin->init();
    
    // load the scene
    root  = OSG::ChunkOverrideGroup::create();
    rootN = OSG::makeNodeFor(root);
        
    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));
            
        OSG::SceneFileHandler::the()->print();
        sceneN = OSG::makeTorus(.5, 2, 16, 16);
    }
    else
    {
        /*
          All scene file loading is handled via the SceneFileHandler.
        */
        sceneN = OSG::SceneFileHandler::the()->read(argv[1]);
    }

    OSG::TransformUnrecPtr xform  = OSG::Transform::create();
    OSG::NodeUnrecPtr      xformN = OSG::makeNodeFor(xform);

    // xform->editMatrix().setTranslate(OSG::Vec3f(100.f, 0.f, 0.f));
    // xform->editMatrix().setRotate(OSG::Quaternion(OSG::Vec3f(0.f, 1.f, 0.f), 0.3f * OSG::Pi));

    OSG::NodeUnrecPtr     boxN    = OSG::makeBox(1.f, 1.f, 5.f, 1, 1, 1);

    xformN->addChild(sceneN);
    rootN ->addChild(xformN);
    rootN ->addChild(boxN  );

    OSG::commitChanges();
    
    // collect geometries in the scene
    collectGeometry(rootN);

    // construct skin shader
    vpSkin = OSG::ShaderProgram::createVertexShader  ();
    vpSkin->setProgram(vpCode);

    fpSkin = OSG::ShaderProgram::createFragmentShader();
    fpSkin->setProgram(fpCode);

    shSkin = OSG::ShaderProgramChunk::create();
    shSkin->addShader(vpSkin);
    shSkin->addShader(fpSkin);

    matSkin = OSG::ChunkMaterial::create();
    matSkin->addChunk(shSkin);

    // process animations
    processAnim(sceneN);

    // create the SimpleSceneManager helper
    mgr = OSG::SimpleSceneManager::create();
    
    // tell the manager what to manage
    mgr->setWindow(gwin );
    mgr->setRoot  (rootN);
    
    // show the whole scene
    mgr->showAll();
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:75,代码来源:testColladaLoader.cpp

示例12: doMain

int doMain(int argc, char **argv)
{
    //
    // This might be necessary depending on the
    // used platform to ensure that the corresponding
    // libraries get loaded.
    //
    OSG::preloadSharedObject("OSGFileIO");
    OSG::preloadSharedObject("OSGImageFileIO");
    OSG::preloadSharedObject("OSGContribPLY");

    OSG::osgInit(argc,argv);

    // GLUT init
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL | GLUT_DOUBLE);

    glutCreateWindow("OpenSG");

    glutReshapeFunc(reshape);
    glutDisplayFunc(display);
    glutIdleFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutKeyboardFunc(keyboard);

    OSG::PassiveWindowRefPtr pwin=OSG::PassiveWindow::create();
    pwin->init();

    // create the SimpleSceneManager helper
    mgr = OSG::SimpleSceneManager::create();

    // create the window and initial camera/viewport
    mgr->setWindow(pwin);

    //
    // for storing clipplane beacon we use a container
    // collection attachment which we attach to the scene
    // node. Otherwise the scene could not be saved correctly,
    // as the beacons would be lost.
    //
    container = OSG::ContainerCollection::create();

    //
    // Implementation details:
    //      For each clip plane we provide a ClipPlaneChunk, the plane geometry,
    //      the plane transform core and at least a plane color conveniently in
    //      a vector of type VecClipPlaneDetailsT. The next function call
    //      initializes this data structure.
    //
    createClipPlaneDetails();

    //
    // The scene
    //
    scene = OSG::Node::create();
    scene->setCore(OSG::Group::create());
    scene->addAttachment(container);

    //
    // A place for accessing the box and torus.
    //
    vecGeometries.push_back(NULL);
    vecGeometries.push_back(NULL);

    //
    // Build concrete clipping planes and update the clip plane details.
    //
    ClipPlaneData data1;
    ClipPlaneData data2;

    data1._equation = OSG::Vec4f(0,0,1,0);
    data1._enabled  = true;

    data2._equation = OSG::Vec4f(1,0,0,0);
    data2._enabled  = false;

    vecClipPlaneData.push_back(data1);
    vecClipPlaneData.push_back(data2);

    updateClipPlanes(vecClipPlaneData);

    keyboard('3',-1,-1);
    keyboard('4',-1,-1);

    // tell the manager what to manage
    mgr->setRoot(scene);

    // show the whole scene
    mgr->showAll();
    mgr->redraw();

    pwin->dumpExtensions();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:97,代码来源:clipplanecaps.cpp

示例13: main


//.........这里部分代码省略.........
    
        // create the SimpleSceneManager helper
        mgr = OSG::SimpleSceneManager::create();
        mgr->setWindow(gwin);

        // create a pretty simple graph: a Group with two Transforms as children,
        // each of which carries a single Geometry.
        
        // The scene
        
        OSG::NodeRefPtr  scene = OSG::Node::create();
        
        // The cylinder and its transformation
        OSG::NodeRefPtr     cyl    = OSG::Node::create();
        OSG::GeometryRefPtr cylgeo = OSG::makeCylinderGeo( 1.4f, .3f, 24, 
                                                           true, true, true );
        
        cyl->setCore(cylgeo);
    
        cyltrans = OSG::Transform::create();
    
        OSG::NodeRefPtr cyltransnode = OSG::Node::create();
        cyltransnode->setCore (cyltrans);
        cyltransnode->addChild(cyl     );
        
        // add it to the scene
        scene->addChild(cyltransnode);
        
        // The torus and its transformation
        OSG::NodeRefPtr     torus    = OSG::Node::create();
        OSG::GeometryRefPtr torusgeo = OSG::makeTorusGeo( .2f, 1, 24, 36 );
        
        torus->setCore(torusgeo);
            
        tortrans = OSG::Transform::create();
    
        OSG::NodeRefPtr tortransnode = OSG::Node::create();
        tortransnode->setCore (tortrans);
        tortransnode->addChild(torus   );
        
        // add it to the scene
        scene->addChild(tortransnode);

        //
        // create the shader program
        //
        OSG::ShaderProgramChunkRefPtr prog_chunk = OSG::ShaderProgramChunk::create();
        OSG::ShaderProgramRefPtr      vertShader = OSG::ShaderProgram::createVertexShader();
        OSG::ShaderProgramRefPtr      fragShader = OSG::ShaderProgram::createFragmentShader();

        vertShader->setProgram(get_vp_program());
        fragShader->setProgram(get_fp_program());

        //
        // binding the shader storage block to a buffer binding point can be performed 
        // either by calling the shaders's addShaderStorageBlock method or by
        // adding a 'buffer block' variable to a ShaderProgramVariableChunk.
        // In the following we use both variants for illustration.
        //
        fragShader->addShaderStorageBlock("ExampleBlock", 1); // block binding point

        prog_chunk->addShader(vertShader);
        prog_chunk->addShader(fragShader);

        //
        // create shader storage buffer object for block 'ExampleBlock'
        //
        OSG::MultiPropertySSBOChunkRefPtr ssbo_example_block = create_example_block_state();

        OSG::PolygonChunkRefPtr polygon_chunk = OSG::PolygonChunk::create();
        polygon_chunk->setFrontMode(GL_FILL);
        polygon_chunk->setBackMode(GL_FILL);
        polygon_chunk->setCullFace(GL_NONE);

        OSG::DepthChunkRefPtr depth_chunk = OSG::DepthChunk::create();
        depth_chunk->setEnable(true);

        OSG::ChunkMaterialRefPtr prog_state = OSG::ChunkMaterial::create();
        prog_state->addChunk(ssbo_example_block, 1);      // buffer binding point 1
        prog_state->addChunk(prog_chunk);
        prog_state->addChunk(polygon_chunk);
        prog_state->addChunk(depth_chunk);

        OSG::MaterialChunkOverrideGroupRefPtr mgrp = OSG::MaterialChunkOverrideGroup::create();
        mgrp->setMaterial(prog_state);
        scene->setCore(mgrp);

        OSG::commitChanges();
    
        mgr->setRoot(scene);
    
        // show the whole scene
        mgr->showAll();
    }

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:vossg,项目名称:OpenSGDevMaster,代码行数:101,代码来源:multipropertyssbochunk_test.cpp

示例14: main


//.........这里部分代码省略.........
        OSG::GeoUInt32PropertyRefPtr ind2 = OSG::GeoUInt32Property::create();
        
        // fill first index (will be used for positions)
        ind1->push_back(0);     // polygon
        ind1->push_back(1);
        ind1->push_back(2);
        ind1->push_back(3);
        
        ind1->push_back(7);     // triangle 1
        ind1->push_back(4);
        ind1->push_back(8);
        ind1->push_back(5);     // triangle 2
        ind1->push_back(6);
        ind1->push_back(9);
        
        ind1->push_back(1);     // quad 1
        ind1->push_back(2);
        ind1->push_back(6);
        ind1->push_back(5);
        ind1->push_back(3);     // quad 2
        ind1->push_back(0);
        ind1->push_back(4);
        ind1->push_back(7);
        
        // fill second index (will be used for colors/normals)
        ind2->push_back(3);     // polygon
        ind2->push_back(3);
        ind2->push_back(3);
        ind2->push_back(3);
        
        ind2->push_back(4);     // triangle 1
        ind2->push_back(4);
        ind2->push_back(4);
        ind2->push_back(5);     // triangle 2
        ind2->push_back(5);
        ind2->push_back(5);
        
        ind2->push_back(5);     // quad 1
        ind2->push_back(5);
        ind2->push_back(5);
        ind2->push_back(5);
        ind2->push_back(4);     // quad 2
        ind2->push_back(4);
        ind2->push_back(4);
        ind2->push_back(4);
        

        /*
            Put it all together into a Geometry NodeCore.
        */
        OSG::GeometryRefPtr geo = OSG::Geometry::create();
        geo->setTypes    (type);
        geo->setLengths  (lens);
        
        /*
           Set the properties and indices used to index them.
           Calling geo->setProperty(pnts, Geometry::PositionsIndex) is the
           same as calling geo->setPositions(pnts), but this way it is
           more obvious which properties and indices go together.
        */
        
        geo->setProperty(pnts,   OSG::Geometry::PositionsIndex);
        geo->setIndex   (ind1,   OSG::Geometry::PositionsIndex);
        
        geo->setProperty(norms,  OSG::Geometry::NormalsIndex  );
        geo->setIndex   (ind2,   OSG::Geometry::NormalsIndex  );
        
        geo->setProperty(colors, OSG::Geometry::ColorsIndex   );
        geo->setIndex   (ind2,   OSG::Geometry::ColorsIndex   );
        
        geo->setMaterial (OSG::getDefaultMaterial());   
        
        // put the geometry core into a node
        OSG::NodeRefPtr n = OSG::Node::create();
        n->setCore(geo);
        
        // add a transformation to make it move     
        OSG::NodeRefPtr scene = OSG::Node::create();
        trans = OSG::Transform::create();
        scene->setCore(trans);
        scene->addChild(n);
    
        OSG::commitChanges();
    
        // create the SimpleSceneManager helper
        mgr = OSG::SimpleSceneManager::create();
    
        // tell the manager what to manage
        mgr->setWindow(gwin );
        mgr->setRoot  (scene);
    
        // show the whole scene
        mgr->showAll();
    }

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:101,代码来源:07multiindexgeometry.cpp

示例15: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    printf("Usage: testCGShader <filename.vp> <filename.fp>\n");

    if( argc < 3 )
        return 0;
    
    // OSG init
    OSG::osgInit(argc,argv);

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

    // the connection between GLUT and OpenSG
    OSG::GLUTWindowUnrecPtr gwin= OSG::GLUTWindow::create();
    gwin->setGlutId(winid);
    gwin->setSize( 800, 800 );
    gwin->init();

    // Create the shader material
    OSG::ChunkMaterialUnrecPtr cmat = OSG::ChunkMaterial::create();

    OSG::MaterialChunkUnrecPtr matc = OSG::MaterialChunk::create();

    matc->setAmbient(OSG::Color4f(0.1, 0.1, 0.1, 1.0));
    matc->setDiffuse(OSG::Color4f(0.3, 0.3, 0.3, 1.0));
    matc->setSpecular(OSG::Color4f(0.8, 0.8, 0.8, 1.0));
    matc->setShininess(100);
    matc->setLit(true);

    OSG::SHLChunkUnrecPtr shl = OSG::SHLChunk::create();

    shl->readVertexProgram(argv[1]);
    shl->readFragmentProgram(argv[2]);

    cmat->addChunk(shl);


    // create root node
    _scene = OSG::Node::create();

    // create torus
    OSG::GeometryUnrecPtr geo = OSG::makeTorusGeo(.8, 1.8, 128, 128);
    geo->setMaterial(cmat);

    OSG::NodeUnrecPtr torus = OSG::Node::create();
    torus->setCore(geo);

    // add torus to scene
    OSG::GroupUnrecPtr group = OSG::Group::create();
    _scene->setCore(group);
    _scene->addChild(torus);

    // create the SimpleSceneManager helper
    _mgr = OSG::SimpleSceneManager::create();

    // tell the manager what to manage
    _mgr->setWindow(gwin );
    _mgr->setRoot(_scene);

    /*
    // create point headlight
    _mgr->turnHeadlightOff();
    NodePtr headlight = _mgr->getHighlight();
    PointLightPtr light    = PointLight::create();
    beginEditCP(light);
        light->setAmbient  (.3, .3, .3, 1);
        light->setDiffuse  ( 1,  1,  1, 1);
        light->setSpecular ( 1,  1,  1, 1);
        light->setBeacon   (_mgr->getCamera()->getBeacon());
    endEditCP(light);
    beginEditCP(_scene);
        _scene->setCore(light);
    endEditCP(_scene);
    */

    // show the whole scene
    _mgr->showAll();

    // GLUT main loop
    glutMainLoop();

    return 0;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:85,代码来源:testSHL_compat.cpp


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