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


C++ NodePtr::addChild方法代码示例

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


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

示例1: updateScene

void updateScene()
{
    NodePtr roseNodePtr = createRose();

    NodePtr topNodePtr = createTag("top", Vec3f(0, 1, 0));
    NodePtr bottomNodePtr = createTag("bottom", Vec3f(0, -1, 0));
    NodePtr leftNodePtr = createTag("left", Vec3f(-1, 0, 0));
    NodePtr rightNodePtr = createTag("right", Vec3f(1, 0, 0));
    NodePtr frontNodePtr = createTag("front", Vec3f(0, 0, 1));
    NodePtr backNodePtr = createTag("back", Vec3f(0, 0, -1));

    beginEditCP(scene, Node::ChildrenFieldMask);
    {
        scene->addChild(topNodePtr);
        scene->addChild(bottomNodePtr);
        scene->addChild(leftNodePtr);
        scene->addChild(rightNodePtr);
        scene->addChild(frontNodePtr);
        scene->addChild(backNodePtr);
        scene->addChild(roseNodePtr);
    }
    endEditCP(scene, Node::ChildrenFieldMask);

    mgr->showAll();
    glutPostRedisplay();
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:26,代码来源:testScreenGroup.cpp

示例2: createScene

NodePtr createScene(void)
{
    //Make Main Scene Node
    NodePtr scene = osg::Node::create();
    osg::ComponentTransformPtr Trans;
    Trans = osg::ComponentTransform::create();
    osg::setName(Trans, std::string("MainTransformationCore"));
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
        scene->setCore(Trans);

        for (int i(0); i < SkeletonNodes.size(); ++i)
        {
            scene->addChild(SkeletonNodes[i]);
        }

        for (int i(0); i < UnboundGeometries.size(); ++i)
        {
            scene->addChild(UnboundGeometries[i]);
        }

        for (int i(0); i < MeshNodes.size(); ++i)
        {
            scene->addChild(MeshNodes[i]);
        }

    endEditCP  (scene, Node::CoreFieldMask | Node::ChildrenFieldMask);

    return scene;
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:29,代码来源:23BlendXMLAnimations.cpp

示例3: started

    virtual void started(const DialogEventPtr e)
    {
        if(DialogPtr::dcast(e->getSource()) == BDialogChildB)
        {
            NodePtr s = makeSphere(1,2);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == BDialogChildA)
        {
            NodePtr s = makeBox(3,3,3,2,2,2);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == ADialogChildA)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(0.0,0.0,1.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == ADialogChildB)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(1.0,0.0,0.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
        }
        if(DialogPtr::dcast(e->getSource()) == End1 || DialogPtr::dcast(e->getSource()) == End2 || DialogPtr::dcast(e->getSource()) == End3 || DialogPtr::dcast(e->getSource()) == End4 )
        {
            TutorialWindowEventProducer->closeWindow();
        }
        if(DialogPtr::dcast(e->getSource()) == Restart1 || DialogPtr::dcast(e->getSource()) == Restart2 || DialogPtr::dcast(e->getSource()) == Restart3 || DialogPtr::dcast(e->getSource()) == Restart4)
        {
            beginEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);
                MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5));
            endEditCP(MainInternalWindowBackground, ColorLayer::ColorFieldMask);

            NodePtr s = makeTorus(.5, 2, 16, 16);
            beginEditCP(scene, Node::ChildrenFieldMask);
                while(scene->getNChildren() > 0)
                {
                    scene->subChild(scene->getNChildren()-1);
                }
                scene->addChild(s);
            endEditCP(scene, Node::ChildrenFieldMask);
        }
    }
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:56,代码来源:07DialogTypeTwo.cpp

示例4: buildBox

//////////////////////////////////////////////////////////////////////////
//! build a box
//////////////////////////////////////////////////////////////////////////
void buildBox(void)
{
    Vec3f Lengths(frand()*2.0+0.5, frand()*2.0+0.5, frand()*2.0+0.5);
    Matrix m;
    //create OpenSG mesh
    GeometryPtr box;
    NodePtr boxNode = makeBox(Lengths.x(), Lengths.y(), Lengths.z(), 1, 1, 1);
    box = GeometryPtr::dcast(boxNode->getCore());
    SimpleMaterialPtr box_mat = SimpleMaterial::create();
    beginEditCP(box_mat);
        box_mat->setAmbient(Color3f(0.0,0.0,0.0));
        box_mat->setDiffuse(Color3f(0.0,1.0 ,0.0));
    endEditCP(box_mat);
    beginEditCP(box, Geometry::MaterialFieldMask);
        box->setMaterial(box_mat);
    endEditCP(box, Geometry::MaterialFieldMask);
    TransformPtr boxTrans;
    NodePtr boxTransNode = makeCoredNode<Transform>(&boxTrans);
    m.setIdentity();
    Real32 randX = frand()*10.0-5.0;
    Real32 randY = frand()*10.0-5.0;
    m.setTranslate(randX, randY, 10.0);
    beginEditCP(boxTrans, Transform::MatrixFieldMask);
        boxTrans->setMatrix(m);
    endEditCP(boxTrans, Transform::MatrixFieldMask);

    //create ODE data
    PhysicsBodyPtr boxBody = PhysicsBody::create(physicsWorld);
    beginEditCP(boxBody, PhysicsBody::PositionFieldMask);
        boxBody->setPosition(Vec3f(randX, randY, 10.0));
    endEditCP(boxBody, PhysicsBody::PositionFieldMask);
    boxBody->setBoxMass(1.0, Lengths.x(), Lengths.y(), Lengths.z());

    PhysicsBoxGeomPtr boxGeom = PhysicsBoxGeom::create();
    beginEditCP(boxGeom, PhysicsBoxGeom::BodyFieldMask | PhysicsBoxGeom::SpaceFieldMask  | PhysicsBoxGeom::LengthsFieldMask | PhysicsBoxGeom::CategoryBitsFieldMask);
        boxGeom->setBody(boxBody);
        boxGeom->setSpace(physicsSpace);
        boxGeom->setLengths(Lengths);
        boxGeom->setCategoryBits(BoxCategory);
    endEditCP(boxGeom, PhysicsBoxGeom::BodyFieldMask | PhysicsBoxGeom::SpaceFieldMask | PhysicsBoxGeom::LengthsFieldMask | PhysicsBoxGeom::CategoryBitsFieldMask);

    //add attachments
    beginEditCP(boxNode, Node::AttachmentsFieldMask);
        boxNode->addAttachment(boxGeom);
    endEditCP(boxNode, Node::AttachmentsFieldMask);
    beginEditCP(boxTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);
        boxTransNode->addAttachment(boxBody);
        boxTransNode->addChild(boxNode);
    endEditCP(boxTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);

    //add to SceneGraph
    beginEditCP(spaceGroupNode, Node::ChildrenFieldMask);
        spaceGroupNode->addChild(boxTransNode);
    endEditCP(spaceGroupNode, Node::ChildrenFieldMask);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:58,代码来源:21Collisions.cpp

示例5: buildSphere

//////////////////////////////////////////////////////////////////////////
//! build a sphere
//////////////////////////////////////////////////////////////////////////
void buildSphere(void)
{
    Real32 Radius(frand()*1.5+0.2);
    Matrix m;
    //create OpenSG mesh
    GeometryPtr sphere;
    NodePtr sphereNode = makeSphere(2, Radius);
    sphere = GeometryPtr::dcast(sphereNode->getCore());
    SimpleMaterialPtr sphere_mat = SimpleMaterial::create();
    beginEditCP(sphere_mat);
    sphere_mat->setAmbient(Color3f(0.0,0.0,0.0));
    sphere_mat->setDiffuse(Color3f(0.0,0.0,1.0));
    endEditCP(sphere_mat);
    beginEditCP(sphere, Geometry::MaterialFieldMask);
    sphere->setMaterial(sphere_mat);
    endEditCP(sphere);
    TransformPtr sphereTrans;
    NodePtr sphereTransNode = makeCoredNode<Transform>(&sphereTrans);
    m.setIdentity();
    Real32 randX = frand()*10.0-5.0;
    Real32 randY = frand()*10.0-5.0;
    m.setTranslate(randX, randY, 10.0);
    beginEditCP(sphereTrans, Transform::MatrixFieldMask);
    sphereTrans->setMatrix(m);
    endEditCP(sphereTrans);
    //create ODE data
    PhysicsBodyPtr sphereBody = PhysicsBody::create(physicsWorld);
    beginEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
        sphereBody->setPosition(Vec3f(randX, randY, 10.0));
        sphereBody->setAngularDamping(0.0001);
    endEditCP(sphereBody, PhysicsBody::PositionFieldMask | PhysicsBody::AngularDampingFieldMask);
    sphereBody->setSphereMass(0.4,Radius);

    PhysicsSphereGeomPtr sphereGeom = PhysicsSphereGeom::create();
    beginEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
        sphereGeom->setBody(sphereBody);
        sphereGeom->setSpace(physicsSpace);
        sphereGeom->setRadius(Radius);
        sphereGeom->setCategoryBits(SphereCategory);
    endEditCP(sphereGeom, PhysicsSphereGeom::BodyFieldMask | PhysicsSphereGeom::SpaceFieldMask | PhysicsSphereGeom::RadiusFieldMask | PhysicsSphereGeom::CategoryBitsFieldMask);
    
    //add attachments
    beginEditCP(sphereNode, Node::AttachmentsFieldMask);
    sphereNode->addAttachment(sphereGeom);
    endEditCP(sphereNode);
    beginEditCP(sphereTransNode, Node::AttachmentsFieldMask | Node::ChildrenFieldMask);
    sphereTransNode->addAttachment(sphereBody);
    sphereTransNode->addChild(sphereNode);
    endEditCP(sphereTransNode);
    //add to SceneGraph
    beginEditCP(spaceGroupNode, Node::ChildrenFieldMask);
    spaceGroupNode->addChild(sphereTransNode);
    endEditCP(spaceGroupNode);
}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:57,代码来源:21Collisions.cpp

示例6: Element

void
IceXML::DocumentBuilder::startElement(const string& name, const Attributes& attributes, int line, int column)
{
    NodePtr parent = _nodeStack.front();

    Element* element = new Element(parent, name, attributes, line, column);
#ifdef NDEBUG
    parent->addChild(element);
#else
    assert(parent->addChild(element));
#endif

    _nodeStack.push_front(element);
}
开发者ID:hu19891110,项目名称:ice,代码行数:14,代码来源:Parser.cpp

示例7: makePerturbedUniform

static NodePtr makePerturbedUniform (UInt16 numSubdiv, 
				     Real32 radius,
				     Real32 rate = 0.1f)
{
   static Real32 factor = 1.1f;

   NodePtr         sphereNode = makeSphere(numSubdiv, radius);
   GeometryPtr     sphere = GeometryPtr::dcast(sphereNode->getCore());
   GeoPositionsPtr points = sphere->getPositions();
   beginEditCP(points);
   for (UInt32 i=0; i<points->size(); ++i) {
      Real32 random = (rand()/Real32(RAND_MAX));
      if (random <= rate) {
	 points->setValue(factor*points->getValue(i), i);
      }
   }
   endEditCP(points);

   NodePtr node = Node::create();
   beginEditCP(node);
   node->setCore(Transform::create());
   node->addChild(sphereNode);
   endEditCP(node);

   return node;
}
开发者ID:BackupTheBerlios,项目名称:opensgplus,代码行数:26,代码来源:testRapidCollision.cpp

示例8: Text

void
IceXML::DocumentBuilder::characters(const string& data, int line, int column)
{
    NodePtr parent = _nodeStack.front();
    TextPtr text = new Text(parent, data, line, column);
    parent->addChild(text);
}
开发者ID:hu19891110,项目名称:ice,代码行数:7,代码来源:Parser.cpp

示例9: makeTransformedCube

NodePtr makeTransformedCube (Real32 xsize,
			     Real32 ysize,
			     Real32 zsize,
			     UInt16 hor,
			     UInt16 vert,
			     UInt16 depth,
			     const Color3f& c)
{
   GeoColors3fPtr color = GeoColors3f::create();
   beginEditCP(color);
   color->addValue(c);
   endEditCP(color);
   GeometryPtr box = makeBoxGeo(xsize, ysize, zsize, hor, vert, depth);
   beginEditCP(box);
   box->setColors(color);
   endEditCP(box);
   NodePtr boxNode = Node::create();
   beginEditCP(boxNode);
   boxNode->setCore(box);
   endEditCP(boxNode);
   NodePtr node = Node::create();
   beginEditCP(node);
   node->setCore(Transform::create());
   node->addChild(boxNode);
   endEditCP(node);
   return node;
}
开发者ID:BackupTheBerlios,项目名称:opensgplus,代码行数:27,代码来源:testRapidCollision.cpp

示例10:

	virtual void  setRoot          ( NodePtr root )
	{
		if(_internalRoot == NullFC)
		{
			initialize();
		}

		if(_root != root)
		{
			if(_root != NullFC)
			{
				beginEditCP(_internalRoot, Node::ChildrenFieldMask);
				_internalRoot->subChild(_root);
				endEditCP(_internalRoot, Node::ChildrenFieldMask);
			}

			_root = root;
			if(_root != NullFC)
			{
				beginEditCP(_internalRoot, Node::ChildrenFieldMask);
				_internalRoot->addChild(_root);
				endEditCP(_internalRoot, Node::ChildrenFieldMask);
			}
		}
	}
开发者ID:Himbeertoni,项目名称:OpenSGToolbox,代码行数:25,代码来源:01RubberBandCamera.cpp

示例11: createScene

 NodePtr createScene(void)
 {
     endEditCP(_pos);
     
     std::map<UInt32, GeoIndicesPtr>::iterator it, end;
     end = _ind.end();
     
     NodePtr scene;
     
     if(_ind.size() == 1)
     {
         scene = makeNodeFor(createGeo(_ind.begin()->first));
     }
     else
     {
         scene = makeNodeFor(Group::create());
         beginEditCP(scene);
         
         for(it = _ind.begin(); it != end; ++it)
         {
             scene->addChild(makeNodeFor(createGeo(it->first)));
         }
         
         endEditCP(scene);
     }
     
     return scene;
 }
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:28,代码来源:oocproxybuilder.cpp

示例12: makeScene

NodePtr makeScene()
{
    g_fb_chunk = FatBorderChunk::create();
    beginEditCP(g_fb_chunk);
    g_fb_chunk->activateWithStandardLighting();
    g_fb_chunk->setIgnore(true);
    endEditCP(g_fb_chunk);

    NodePtr root = makeCoredNode<Switch>();
    beginEditCP(root);
    root->addChild(makeTeapot());
    root->addChild(makeTorus());
    root->addChild(makeTrimmedCylinder());
    endEditCP(root);
    return root;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例13: main

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

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

    // the connection between GLUT and OpenSG
    GLUTWindowPtr gwin= GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();

    // create the scene

    NodePtr torus = makeTorus( .5, 2, 16, 32 );

    // create the transformation node
    // scenegraph nodes are split into 2 parts: the node and its core
    
    // 1. create the Node
    NodePtr scene = Node::create();
    
    // 2. create the core
    trans = Transform::create();
    
    // 3. associate the core with the node
 
    // OpenSG objects need to be informed when they are being changed, 
    // that's what beginEditCP() and endEditCP() do
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
    {
        scene->setCore(trans);
 
        // add the torus as a child
        scene->addChild(torus);
    }
    endEditCP  (scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
    

    // create the SimpleSceneManager helper
    mgr = new SimpleSceneManager;

    // 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:mlimper,项目名称:OpenSG1x,代码行数:56,代码来源:02move.cpp

示例14: readTopNodes

SceneFileHandler::FCPtrStore SceneFileHandler::readTopNodes(
    const  Char8  *fileName,
    GraphOpSeq *graphOpSeq)
{
    std::vector<FieldContainerPtr> nodeVec;

    if(!fileName)
    {
        SWARNING << "cannot read NULL file" << std::endl;
        return nodeVec;
    }

    std::string fullFilePath = initPathHandler(fileName);
    if(fullFilePath.empty())
    {
        SWARNING << "Couldn't open file " << fileName << std::endl;
        return nodeVec;
    }

    std::ifstream in(fullFilePath.c_str(), std::ios::binary);

    if(in)
    {
        nodeVec = readTopNodes(in, fullFilePath.c_str(), graphOpSeq);
        in.close();
    }
    else
    {
        SWARNING << "Couldn't open input stream for file " << fullFilePath << std::endl;
    }

    // Ok stream interface didn't work try via filename
    if(nodeVec.empty())
    {
        NodePtr scene = read(fullFilePath.c_str());
        if(scene == NullFC)
            return nodeVec;

        while(scene->getNChildren() > 0)
        {
            NodePtr child = scene->getChild(0);
            NodePtr newChild = Node::create();
            while(child->getNChildren() > 0)
                newChild->addChild(child->getChild(0));
            newChild->setCore(child->getCore());
            if(graphOpSeq != NULL)
                graphOpSeq->run(newChild);
            nodeVec.push_back(newChild);
            scene->subChild(child);
        }
    }

    return nodeVec;
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例15: addLevel

void VRMLLODBinder::addLevel(NodePtr pLevel)
{
    NodePtr pNode = NodePtr::dcast(_pFieldContainer);

    if(pNode != NullFC && pLevel != NullFC)
    {
        beginEditCP(pNode, Node::ChildrenFieldMask);
        {
            pNode->addChild(pLevel);
        }
        endEditCP  (pNode, Node::ChildrenFieldMask);
    }
}
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:13,代码来源:OSGVRMLLOD.cpp


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