正在加载图片...
osg:Geode*pyramidGeode new osg:Geode(); osg:Geometry*pyramidGeometry new osg:Geometry(); pyramidGeode->addDrawable(pyramidGeometry); //Specify the vertices: osg:Vec3Array*pyramidVertices new osg:Vec3Array: pyramidVertices->push_back(osg:Vec3(0,0,0));//front left pyramidVertices->push_back(osg:Vec3(2,0,0))://front right pyramidVertices->push_back(osg:Vec3(2,2,0));//back right pyramidVertices->push_back(osg:Vec3(0,2,0))://back left pyramidVertices->push_back(osg:Vec3(1,1,2))://peak /Associate this set of vertices with the geometry associated with the /geode we added to the scene. pyramidGeometry->setVertexArray(pyramidVertices ) /Create a QUAD primitive for the base by specifying the /vertices from our vertex list that make up this QUAD: osg:DrawElementsUInt*pyramidBase new osg:DrawElementsUInt (osg:PrimitiveSet:QUADS,0); pyramidBase->push_back(3); pyramidBase->push_back(2); pyramidBase->push_back(1); pyramidBase->push_back(0); //Add this primitive to the geometry: pyramidGeometry->addPrimitiveSet(pyramidBase); /code to create other faces goes here! //(removed to save space,see tutorial two) osg:Vec4Array*colors new osg:Vec4Array; colors->push_back(osg:Vec4(1.0f,0.Of,0.0f,1.0f));//index 0 red colors->push_back(osg:Vec4(0.Of,1.0f,0.Of,1.0f));//index 1 green colors->push_back (osg:Vec4(0.0f,0.Of,1.0f,1.0f));//index 2 blue colors->push_back(osg:Vec4(1.Of,1.0f,1.Of,1.0f));//index 3 white osg:TemplatelndexArray <unsigned int,osg:Array:UIntArrayType,4,4>*colorIndexArray; colorIndexArray new osg:TemplateIndexArray<unsigned int,osg:Array:UIntArrayType,4,4>; colorIndexArray->push_back(0);//vertex 0 assigned color array element 05 osg::Geode* pyramidGeode = new osg::Geode(); osg::Geometry* pyramidGeometry = new osg::Geometry(); pyramidGeode->addDrawable(pyramidGeometry); // Specify the vertices: osg::Vec3Array* pyramidVertices = new osg::Vec3Array; pyramidVertices->push_back( osg::Vec3(0, 0, 0) ); // front left pyramidVertices->push_back( osg::Vec3(2, 0, 0) ); // front right pyramidVertices->push_back( osg::Vec3(2, 2, 0) ); // back right pyramidVertices->push_back( osg::Vec3( 0,2, 0) ); // back left pyramidVertices->push_back( osg::Vec3( 1, 1,2) ); // peak // Associate this set of vertices with the geometry associated with the // geode we added to the scene. pyramidGeometry->setVertexArray( pyramidVertices ); // Create a QUAD primitive for the base by specifying the // vertices from our vertex list that make up this QUAD: osg::DrawElementsUInt* pyramidBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0); pyramidBase->push_back(3); pyramidBase->push_back(2); pyramidBase->push_back(1); pyramidBase->push_back(0); //Add this primitive to the geometry: pyramidGeometry->addPrimitiveSet(pyramidBase); // code to create other faces goes here! // (removed to save space, see tutorial two) osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white osg::TemplateIndexArray <unsigned int, osg::Array::UIntArrayType,4,4> *colorIndexArray; colorIndexArray = new osg::TemplateIndexArray<unsigned int, osg::Array::UIntArrayType,4,4>; colorIndexArray->push_back(0); // vertex 0 assigned color array element 0
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有