正在加载图片...
/Declare and initialize a transform node. osg:PositionAttitudeTransform*pyramidTwoXForm new osg:PositionAttitudeTransform(); /Use the 'addChild'method of the osg:Group class to /add the transform as a child of the root node and the /pyramid node as a child of the transform. root->addChild(pyramidTwoXForm): pyramidTwoXForm->addChild(pyramidGeode); /Declare and initialize a Vec3 instance to change the /position of the tank model in the scene osg:Vec3 pyramidTwoPosition(15,0,0); pyramidTwoXForm->setPosition(pyramidTwoPosition ) 既然我们生成了一个geometry节点并将它加到了场景中,我们就可以重用这个geometry。.例如, 如果我们想让另一个pyramid在第一个的右侧l5个单位处,我们就可以在我们的scene graph中 将这个geode加到transform节点的子节点上。 最后一步,建立并进入一个仿真循环。 viewer.setUpViewer(osgProducer:Viewer:STANDARD_SETTINGS); viewer.setSceneData(root ) viewer.realize(); while(!viewer.done()) { viewer.sync(); viewer.update(); viewer.frame(); 2.使用StateSet产生有纹理的几何体 2.1本章目标 为教程1中介绍的由OpenGL基本绘制单位定义的几何体添加纹理。 2.2背景 前一节教程介绍了包含由OpenGL基本单位产生的基本形状的视景。本节讲解如何为这些形状 添加纹理。为了使代码更方便使用,我们将pyramid的代码放到一个函数中,产生geode并返回它 的指针。下面的代码来自教程1。 osg:Geode*createPyramid()4 // Declare and initialize a transform node. osg::PositionAttitudeTransform* pyramidTwoXForm = new osg::PositionAttitudeTransform(); // Use the 'addChild' method of the osg::Group class to // add the transform as a child of the root node and the // pyramid node as a child of the transform. root->addChild(pyramidTwoXForm); pyramidTwoXForm->addChild(pyramidGeode); // Declare and initialize a Vec3 instance to change the // position of the tank model in the scene osg::Vec3 pyramidTwoPosition(15,0,0); pyramidTwoXForm->setPosition( pyramidTwoPosition ); 既然我们生成了一个 geometry 节点并将它加到了场景中,我们就可以重用这个 geometry。例如, 如果我们想让另一个 pyramid 在第一个的右侧 15 个单位处,我们就可以在我们的 scene graph 中 将这个 geode 加到 transform 节点的子节点上。 最后一步,建立并进入一个仿真循环。 viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); viewer.setSceneData( root ); viewer.realize(); while( !viewer.done() ) { viewer.sync(); viewer.update(); viewer.frame(); } 2.使用 StateSet 产生有纹理的几何体 2.1 本章目标 为教程 1 中介绍的由 OpenGL 基本绘制单位定义的几何体添加纹理。 2.2 背景 前一节教程介绍了包含由 OpenGL 基本单位产生的基本形状的视景。本节讲解如何为这些形状 添加纹理。为了使代码更方便使用,我们将 pyramid 的代码放到一个函数中,产生 geode 并返回它 的指针。下面的代码来自教程 1。 osg::Geode* createPyramid() {
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有