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


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

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


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

示例1: keyboard

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

        delete gTextStuff;
        
        OSG::commitChanges();
        OSG::osgExit();
        exit(0);
    }
    break;
    
    case '-':
        gTextStuff->incFaceSize(false);
        break;
    case '=':
        gTextStuff->incFaceSize(true);
        break;
    
    case '[':
        gTextStuff->incTextureSize(false);
        break;
    case ']':
        gTextStuff->incTextureSize(true);
        break;
    
    case '<':
        gTextStuff->incMaxExtent(false);
        break;
    case '>':
        gTextStuff->incMaxExtent(true);
        break;
    
    case ',':
        gTextStuff->incLineSpacing(false);
        break;
    case '.':
        gTextStuff->incLineSpacing(true);
        break;
    
    case '{':
        gTextStuff->incGeoScale(false);
        break;
    case '}':
        gTextStuff->incGeoScale(true);
        break;
    
    
    case 'f':
        gTextStuff->goToNextFamily();
        break;
    
    case 'd':
        OSG::SceneFileHandler::the()->write(mgr->getRoot(),"dump_scene.osb");
        std::cout << "Wrote out scene: dump_scene.osb" << std::endl;
        break;
    
    case 't':
        mgr->setNavigationMode(OSG::Navigator::TRACKBALL);
        break;
    
    case 'l':
        mgr->setHeadlight(!mgr->getHeadlightState());
        std::cout << "Set headlight: " << mgr->getHeadlightState() << std::endl;
        break;
    case 'z':
        glPolygonMode( GL_FRONT_AND_BACK, GL_POINT);
        std::cerr << "PolygonMode: Point." << std::endl;
        break;
    case 'x':   glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
        std::cerr << "PolygonMode: Line." << std::endl;
        break;
    case 'c':   glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
        std::cerr << "PolygonMode: Fill." << std::endl;
        break;
        
    case 'h':
        std::cerr << "Keys:" << std::endl;
        std::cerr << "- =: change face size" << std::endl;
        std::cerr << "{ }: change geo scale" << std::endl;
        std::cerr << "[ ]: change texture size" << std::endl;
        std::cerr << "< >: change max extend for 1st line" << std::endl;
        std::cerr << ", .: change line spacing" << std::endl;
        std::cerr << "f  : next font family" << std::endl;
        std::cerr << "d  : dump scene" << std::endl;
    }
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:92,代码来源:testTextParams.cpp

示例2: keyboard

// react to keys
void keyboard(unsigned char k, int , int )
{
    switch(k)
    {
    case 27:
    {
        cleanup();

        OSG::osgExit();
        std::exit(0);
    }
    break;
    case 'f':
    {
        mgr->setNavigationMode(OSG::Navigator::FLY);
        std::cout << "Fly mode" << std::endl;
    }
    break;
    case 't':
    {
        mgr->setNavigationMode(OSG::Navigator::TRACKBALL);
        std::cout << "Trackball mode" << std::endl;
    }
    break;
    case 'q':
    {
        mgr->setStatistics(!mgr->getStatistics());
        std::cout << "Statistics " 
                  << (mgr->getStatistics() ? "enabled" : "disabled")
                  << std::endl;
    }
    break;
    case 'h':
    {
        mgr->setHeadlight(!mgr->getHeadlightState());
        std::cout << "Headlight "
                  << (mgr->getHeadlightState() ? "enabled" : "disabled")
                  << std::endl;
    }
    break;
    case 'b':
    {
        if(polyChunk == NULL)
        {
            polyChunk = OSG::PolygonChunk::create();
            root->addChunk(polyChunk);
        }
  
        if(polyChunk->getCullFace() == GL_NONE)
        {
            polyChunk->setCullFace(GL_BACK);
            std::cout << "Backface culling enabled" << std::endl;
        }
        else
        {
            polyChunk->setCullFace(GL_NONE);
            std::cout << "Backface culling disabled" << std::endl;
        }
    }
    break;
    case 'w':
    {
        if(polyChunk == NULL)
        {
            polyChunk = OSG::PolygonChunk::create();
            root->addChunk(polyChunk);
        }

        if(polyChunk->getFrontMode() == GL_FILL)
        {
            polyChunk->setFrontMode(GL_LINE);
            polyChunk->setBackMode (GL_LINE);
            std::cout << "Wireframe enabled" << std::endl;
        }
        else
        {
            polyChunk->setFrontMode(GL_FILL);
            polyChunk->setBackMode (GL_FILL);
            std::cout << "Wireframe disabled" << std::endl;
        }
    }
    break;
    case 'n':
    {
        if(normalsActive == true)
        {
            normalsActive = false;

            NodeStore::const_iterator ngIt  = normalsGeoN.begin();
            NodeStore::const_iterator ngEnd = normalsGeoN.end  ();

            for(; ngIt != ngEnd; ++ngIt)
            {
                (*ngIt)->setTravMask(0);
            }
            
            std::cout << "Normals disabled" << std::endl;
        }
        else
//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:101,代码来源:testColladaLoader.cpp

示例3: 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


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