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


C++ NodeUnrecPtr类代码示例

本文整理汇总了C++中NodeUnrecPtr的典型用法代码示例。如果您正苦于以下问题:C++ NodeUnrecPtr类的具体用法?C++ NodeUnrecPtr怎么用?C++ NodeUnrecPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: OSG_COLLADA_LOG

void
ColladaLight::createAmbientLight(ColladaLightAmbientInstInfo *colInstInfo)
{
    OSG_COLLADA_LOG(("ColladaLight::createAmbientLight\n"));

    LightLoaderState *state =
        getGlobal()->getLoaderStateAs<LightLoaderState>(_loaderStateName);
    OSG_ASSERT(state != NULL);

    ChunkOverrideGroupUnrecPtr coGroup  = ChunkOverrideGroup::create();
    NodeUnrecPtr               coGroupN = makeNodeFor(coGroup);

    coGroup->addChunk(state->getLightModelChunk());

    Node *rootN = getGlobal()->getRoot();

    while(rootN->getNChildren() > 0)
    {
        coGroupN->addChild(rootN->getChild(0));
    }

    if(getGlobal()->getOptions()->getCreateNameAttachments() == true)
    {
        setName(coGroupN, "OpenSG_AmbientLight");
    }

    rootN->addChild(coGroupN);
}
开发者ID:DaveHarrison,项目名称:OpenSGDevMaster,代码行数:28,代码来源:OSGColladaLight.cpp

示例2: doMain

//
// setup scene
//
static int doMain(int argc, char *argv[])
{
    preloadSharedObject("OSGFileIO");
    preloadSharedObject("OSGImageFileIO");

    osgInit(argc,argv);

    int winid = setupGLUT(&argc, argv);

    win = GLUTWindow::create();
    win->setGlutId(winid);
    win->init();

    if(argc < 2)
    {
        FWARNING(("No file given!\n"));
        FWARNING(("Supported file formats:\n"));

        std::list<const char*> suffixes;
        SceneFileHandler::the()->getSuffixList(suffixes);

        for(std::list<const char*>::iterator it  = suffixes.begin();
                                            it != suffixes.end();
                                        ++it)
        {
            FWARNING(("%s\n", *it));
        }

        staticScene = createStaticScene();
    }
    else
    {
        staticScene = SceneFileHandler::the()->read(argv[1]);
    }

    dynamicScene = createDynamicScene();

    commitChanges();

    mgr = SimpleSceneManager::create();

    NodeUnrecPtr root = makeCoredNode<Group>();
    root->addChild(staticScene);

    mgr->setWindow(win);
    mgr->setRoot  (root);

    GradientBackgroundUnrecPtr background = GradientBackground::create();
    background->addLine(Color3f(0,0,0), 0);
    background->addLine(Color3f(1,1,1), 1);

    staticVp = win->getPort(0);
    staticVp->setBackground(background);

    camera = staticVp->getCamera();

    mgr->showAll();

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

示例3: getTreeComponent

ComponentTransitPtr SceneNodeTreeComponentGenerator::getTreeComponent(Tree* const Parent, 
                                                                            const boost::any& Value, 
                                                                            bool IsSelected, 
                                                                            bool Expanded, 
                                                                            bool Leaf, 
                                                                            UInt32 Row, 
                                                                            bool HasFocus)
{
    NodeUnrecPtr TheNode;
    try
    {
        TheNode = boost::any_cast<NodeUnrecPtr>(Value);
    }
    catch (boost::bad_any_cast &)
    {
        //Could not convert to FieldContinerFieldPath
        return ComponentTransitPtr(NULL);
    }

    //Get the text for the label
    std::string LabelText("");
    if(TheNode != NULL)
    {
        const Char8* name(getName(TheNode));
        if(name)
        {
            LabelText += std::string(name) + " ";
        }
        if(TheNode->getCore() != NULL)
        {
            LabelText += std::string("[") + TheNode->getCore()->getType().getCName() + "]";
        }
        else
        {
            LabelText += "[NULL core]";
        }
    }
    else
    {
        LabelText += "NULL";
    }

    ComponentRecPtr GenComp = getTreeComponentText(Parent, LabelText, IsSelected, Expanded, Leaf, Row, HasFocus);
    if(TheNode != NULL &&
       !(TheNode->getTravMask() & getTravMask()))
    {
        GenComp->setEnabled(false);
    }

    return ComponentTransitPtr(GenComp);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:51,代码来源:OSGSceneNodeTreeComponentGenerator.cpp

示例4: enableStaticScene

static void enableStaticScene()
{
    win->subPortByObj(dynamicVp);
    dynamicVp = nullptr;

    NodeUnrecPtr root = makeCoredNode<Group>();
    root->addChild(staticScene);
    mgr->setRoot(root);

    mgr->getNavigator()->setViewport(staticVp);

    staticVp->setCamera(camera);

    win->addPort(staticVp);
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:15,代码来源:dyndrawing1.cpp

示例5: createPath

void SceneGraphTreeModel::removeNode(NodeUnrecPtr nodeToBeRemoved)
{

    NodeRefPtr parent = nodeToBeRemoved->getParent();

    TreePath pathOfNode = createPath(nodeToBeRemoved);
    if(parent!=NULL)
    {
        UInt32 ChildIndex(parent->findChild(nodeToBeRemoved));


        produceTreeNodesWillBeRemoved(pathOfNode.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, nodeToBeRemoved));
        parent->subChild(nodeToBeRemoved);
        produceTreeNodesRemoved(pathOfNode.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, nodeToBeRemoved));

        if(parent->getNChildren() == 0)
        {
            if(parent->getParent() != NULL)
            {
                std::vector<UInt32> childIndices;
                childIndices.push_back(parent->getParent()->findChild(parent));
                std::vector<boost::any> ChildUserObjects;
                for(UInt32 i(0) ; i< childIndices.size() ; ++i)
                {
                    ChildUserObjects.push_back(boost::any(NodeUnrecPtr(parent->getParent()->getChild(childIndices[i]))));
                }
                produceTreeNodesChanged(createPath(parent->getParent()), childIndices, ChildUserObjects);
            }
        }
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:31,代码来源:OSGSceneGraphTreeModel.cpp

示例6: createStaticScene

//
// create an arbitrarly complex render scene
//
static NodeTransitPtr createStaticScene()
{
    NodeUnrecPtr root = makeCoredNode<Group>();

    typedef boost::mt19937 base_generator_type;
    static base_generator_type generator(0);
    static boost::uniform_01<float> value;
    static boost::variate_generator< base_generator_type, boost::uniform_01<float> > die(generator, value);

    for (int i = 0; i < max_tori; ++i) {
        NodeUnrecPtr scene = makeTorus(.5, 2, 32, 32);

        TransformUnrecPtr transformCore = Transform::create();
        Matrix mat;

        mat.setIdentity();

        float x = 500.f * die();
        float y = 500.f * die();
        float z = 500.f * die();

        float e1 = die();
        float e2 = die();
        float e3 = die();

        Vec3f v(e1,e2,e3);
        v.normalize();

        float a = TwoPi * die();

        Quaternion q(v, a);

        mat.setTranslate(x,y,z);
        mat.setRotate(q);

        transformCore->setMatrix(mat);

        NodeUnrecPtr trafo = makeNodeFor(transformCore);

        trafo->addChild(scene);

        root->addChild(trafo);
    }
    
    return NodeTransitPtr(root);
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:49,代码来源:dyndrawing1.cpp

示例7: buildScene

NodeTransitPtr buildScene(void)
{
    NodeUnrecPtr geoN = makeBox(1.f, 1.f, 1.f, 1, 1, 1);

    ComponentTransformUnrecPtr xform  = ComponentTransform::create();
    NodeUnrecPtr               xformN = makeNodeFor(xform);
    
    setTargetId(xform, "xform0");

    gXForm = xform;

    NodeUnrecPtr      groupN = makeCoredNode<Group>();

    xformN->addChild(geoN  );
    groupN->addChild(xformN);

    return NodeTransitPtr(groupN);
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:18,代码来源:testTrivialAnim3.cpp

示例8: dropPhysicsBody

void dropPhysicsBody(RenderAction* action,const NodeUnrecPtr node, MaterialUnrecPtr mat)
{
    //Get the Physics Body object attached to this node, if there is one
    AttachmentUnrecPtr TheBodyAttachment(node->findAttachment(PhysicsBody::getClassType()));

    if(TheBodyAttachment != NULL)
    {
        PhysicsBodyDrawWrapper::drop(action, node, dynamic_pointer_cast<PhysicsBody>(TheBodyAttachment), mat);
    }
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:10,代码来源:OSGPhysicsBodyDrawFuncs.cpp

示例9: getChildCount

UInt32 SceneGraphTreeModel::getChildCount(const boost::any& parent) const
{
    try
    {
        NodeUnrecPtr TheNode = boost::any_cast<NodeUnrecPtr>(parent);
        if(TheNode != NULL)
        {
            return TheNode->getNChildren();
        }
        else
        {
            return 0;
        }
    }
    catch(boost::bad_any_cast &ex)
    {
        SWARNING << "Bad any cast: " << ex.what() << std::endl;
        return 0;
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:20,代码来源:OSGSceneGraphTreeModel.cpp

示例10: getChild

boost::any SceneGraphTreeModel::getChild(const boost::any& parent, const UInt32& index) const
{
    try
    {
        NodeUnrecPtr TheNode = boost::any_cast<NodeUnrecPtr>(parent);
        if(TheNode != NULL &&
           TheNode->getNChildren() > index)
        {
            return boost::any(NodeUnrecPtr(TheNode->getChild(index)));
        }
        else
        {
            return boost::any();
        }
    }
    catch(boost::bad_any_cast &ex)
    {
        SWARNING << "Bad any cast: " << ex.what() << std::endl;
        return boost::any();
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:21,代码来源:OSGSceneGraphTreeModel.cpp

示例11: getIndexOfChild

UInt32 SceneGraphTreeModel::getIndexOfChild(const boost::any& parent, const boost::any& child) const
{
    try
    {
        NodeUnrecPtr ParentNode = boost::any_cast<NodeUnrecPtr>(parent);
        NodeUnrecPtr ChildNode = boost::any_cast<NodeUnrecPtr>(child);
        if(ParentNode != NULL &&
           ChildNode  != NULL)
        {
            return ParentNode->findChild(ChildNode);
        }
        else
        {
            return 0;
        }
    }
    catch(boost::bad_any_cast &ex)
    {
        SWARNING << "Bad any cast: " << ex.what() << std::endl;
        return 0;
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:22,代码来源:OSGSceneGraphTreeModel.cpp

示例12: NodeRefPtr

void SceneGraphTreeModel::insertNode(NodeUnrecPtr parent,
                                     NodeUnrecPtr nodeToBeAdded,
                                     UInt32 Index)
{
    NodeRefPtr(parent)->insertChild(Index, nodeToBeAdded);
    produceTreeNodesInserted(createPath(parent),std::vector<UInt32>(1, Index),std::vector<boost::any>(1, nodeToBeAdded));

    if(parent->getNChildren() == 1)
    {
        if(parent->getParent() != NULL)
        {
            std::vector<UInt32> childIndices;
            childIndices.push_back(parent->getParent()->findChild(parent));
            std::vector<boost::any> ChildUserObjects;
            for(UInt32 i(0) ; i< childIndices.size() ; ++i)
            {
                ChildUserObjects.push_back(boost::any(NodeUnrecPtr(parent->getParent()->getChild(childIndices[i]))));
            }
            produceTreeNodesChanged(createPath(NodeUnrecPtr(parent->getParent())), childIndices, ChildUserObjects);
        }
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:22,代码来源:OSGSceneGraphTreeModel.cpp

示例13: ParentNode

void SceneGraphTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue)
{
    try
    {
        NodeUnrecPtr NewNode = boost::any_cast<NodeUnrecPtr>(newValue);
        NodeUnrecPtr OldNode = boost::any_cast<NodeUnrecPtr>(path.getLastPathComponent());
        if(NewNode != NULL &&
           OldNode  != NULL &&
           NewNode != OldNode &&
           OldNode->getParent() != NULL)
        {
            NodeUnrecPtr ParentNode(OldNode->getParent());
            if(ParentNode->replaceChildBy(OldNode, NewNode))
            {
                UInt32 ChildIndex(ParentNode->findChild(NewNode));
                produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue));
            }
        }
    }
    catch(boost::bad_any_cast &ex)
    {
        SWARNING << "Bad any cast: " << ex.what() << std::endl;
    }
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:24,代码来源:OSGSceneGraphTreeModel.cpp

示例14: createDynamicViewport

static void createDynamicViewport()
{
    win->subPortByObj(staticVp);

    FBOBackgroundUnrecPtr fboBckgnd = FBOBackground::create();
    fboBckgnd->setFrameBufferObject(spSimpleFBO->fbo());

    NodeUnrecPtr root = makeCoredNode<Group>();
    root->addChild(dynamicScene);

    mgr->setRoot(root);

    dynamicVp = Viewport::create();
    dynamicVp->setRoot      (rootNode(root));
    dynamicVp->setBackground(fboBckgnd);
    dynamicVp->setCamera    (camera);
    dynamicVp->setSize      (0,0, 1,1);

    mgr->getNavigator()->setViewport(dynamicVp);
    
    win->addPort(dynamicVp);

    mgr->update();
}
开发者ID:jondo2010,项目名称:OpenSG,代码行数:24,代码来源:dyndrawing1.cpp

示例15: buildSphere

//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
PhysicsBodyUnrecPtr buildSphere(void)
{
    Real32 Radius((Real32)(rand()%2)*0.5+0.5);
    Matrix m;
    //create OpenSG mesh
    GeometryUnrecPtr sphere;
    NodeUnrecPtr sphereNode = makeSphere(2, Radius);
    sphere = dynamic_cast<Geometry*>(sphereNode->getCore());
    SimpleMaterialUnrecPtr sphere_mat = SimpleMaterial::create();
    sphere_mat->setAmbient(Color3f(0.0,0.0,0.0));
    sphere_mat->setDiffuse(Color3f(0.0,0.0,1.0));
    sphere->setMaterial(sphere_mat);
    TransformUnrecPtr sphereTrans;
    NodeUnrecPtr sphereTransNode = makeCoredNode<Transform>(&sphereTrans);
    m.setIdentity();
    Real32 randX = (Real32)(rand()%10)-5.0;
    Real32 randY = (Real32)(rand()%10)-5.0;
    m.setTranslate(randX, randY, 10.0);
    sphereTrans->setMatrix(m);
    //create ODE data
    PhysicsBodyUnrecPtr sphereBody = PhysicsBody::create(physicsWorld);
        sphereBody->setPosition(Vec3f(randX, randY, 10.0));
        sphereBody->setLinearDamping(0.0001);
        sphereBody->setAngularDamping(0.0001);
    sphereBody->setSphereMass(1.0,Radius);

    PhysicsSphereGeomUnrecPtr sphereGeom = PhysicsSphereGeom::create();
        sphereGeom->setBody(sphereBody);
        sphereGeom->setSpace(physicsSpace);
        sphereGeom->setRadius(Radius);
    
    //add attachments
    sphereNode->addAttachment(sphereGeom);
    sphereTransNode->addAttachment(sphereBody);
    sphereTransNode->addChild(sphereNode);
    //add to SceneGraph
    spaceGroupNode->addChild(sphereTransNode);

    commitChanges();

    return sphereBody;
}
开发者ID:danguilliams,项目名称:OpenSGToolbox,代码行数:45,代码来源:05Explosion.cpp


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