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


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

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


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

示例1: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    printf("Press key '1' or '2' to switch between one and two light sources.\n");
    // OSG init
    OSG::osgInit(argc,argv);

    globals = new GlobalObjects;
    
    // 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.
    {
        // GLUT init
        int winid = setupGLUT(&argc, argv);
        globals->gwin = OSG::GLUTWindow::create();
    
        /*
            Construct a scene with a ground plane, some objects and two lights.
            Nothing very interesting at this point.
            See further down for the part relevant to shadows.
        */
        
        globals->rootNode      = OSG::makeCoredNode<OSG::Group>();
        OSG::NodeRefPtr  scene = OSG::makeCoredNode<OSG::Group>();
    
        // create lights
        OSG::TransformRefPtr point1_trans;
        OSG::NodeRefPtr point1        = OSG::makeCoredNode<OSG::PointLight>(&globals->point1_core);
        OSG::NodeRefPtr point1_beacon = OSG::makeCoredNode<OSG::Transform >(&point1_trans);
        
        point1_trans->editMatrix().setTranslate(0.0, 0.0, 15.0);
        
        globals->point1_core->setAmbient(0.15f,0.15f,0.15f,1);
        globals->point1_core->setDiffuse(0.4f,0.4f,0.4f,1);
        globals->point1_core->setSpecular(0.0f,0.0f,0.0f,1);
        globals->point1_core->setBeacon(point1_beacon);
        globals->point1_core->setOn(true);
        
        OSG::TransformRefPtr point2_trans;
        OSG::NodeRefPtr point2        = OSG::makeCoredNode<OSG::PointLight>(&globals->point2_core);
        OSG::NodeRefPtr point2_beacon = OSG::makeCoredNode<OSG::Transform >(&point2_trans);
        
        point2_trans->editMatrix().setTranslate(2.5, 2.5, 15.0);
        
        globals->point2_core->setAmbient(0.15f,0.15f,0.15f,1);
        globals->point2_core->setDiffuse(0.4f,0.4f,0.4f,1);
        globals->point2_core->setSpecular(0.0f,0.0f,0.0f,1);
        globals->point2_core->setBeacon(point2_beacon);
        globals->point2_core->setOn(true);
        
        point1->addChild(point2);
        point2->addChild(scene );
        
        // create scene
        
        // bottom
        OSG::NodeRefPtr plane = OSG::makePlane(25.0, 25.0, 128, 128);
    
        OSG::UChar8 imgdata[] =
            {  255,0,0,  0,255,0,  0,0,255, 255,255,0 };
        OSG::ImageRefPtr plane_img = OSG::Image::create();
        plane_img->set(OSG::Image::OSG_RGB_PF, 2, 2, 1, 1, 1, 0, imgdata);
    
        OSG::TextureObjChunkRefPtr plane_tex = OSG::TextureObjChunk::create();
        plane_tex->setImage(plane_img);
        plane_tex->setMinFilter(GL_LINEAR);
        plane_tex->setMagFilter(GL_LINEAR);
        plane_tex->setWrapS(GL_REPEAT);
        plane_tex->setWrapT(GL_REPEAT);
        
        OSG::TextureEnvChunkRefPtr plane_tex_env = OSG::TextureEnvChunk::create();
        plane_tex_env->setEnvMode(GL_MODULATE);
    
        OSG::SimpleMaterialRefPtr plane_mat = OSG::SimpleMaterial::create();
        plane_mat->setAmbient(OSG::Color3f(0.3f,0.3f,0.3f));
        plane_mat->setDiffuse(OSG::Color3f(1.0f,1.0f,1.0f));
        plane_mat->addChunk(plane_tex);
        plane_mat->addChunk(plane_tex_env);
    
        OSG::GeometryRefPtr plane_geo = dynamic_cast<OSG::Geometry *>(plane->getCore());
        plane_geo->setMaterial(plane_mat);
        
        // box
        OSG::NodeRefPtr box_trans_node = OSG::makeCoredNode<OSG::Transform>(&globals->box_trans);
        globals->box_trans->editMatrix().setTranslate(0.0, 0.0, 2.0);
        
        OSG::NodeRefPtr box = OSG::makeBox(8.0f, 8.0f, 0.8f, 10, 10 , 10);
        box_trans_node->addChild(box);
    
        OSG::SimpleMaterialRefPtr box_mat = OSG::SimpleMaterial::create();
        box_mat->setAmbient(OSG::Color3f(0.0f,0.0f,0.0f));
        box_mat->setDiffuse(OSG::Color3f(0.0f,0.0f,1.0f));
    
        OSG::GeometryRefPtr box_geo = dynamic_cast<OSG::Geometry *>(box->getCore());
        box_geo->setMaterial(box_mat);
    
        // cylinder1
        OSG::NodeRefPtr cylinder1_trans_node = OSG::makeCoredNode<OSG::Transform>(&globals->cylinder1_trans);
        globals->cylinder1_trans->editMatrix().setTranslate(0.0, 0.0, 5.0);
//.........这里部分代码省略.........
开发者ID:jondo2010,项目名称:OpenSG,代码行数:101,代码来源:shadows.cpp


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