|
发表于 2010-8-26 16:27:05
|
显示全部楼层
可能您的程序设置的问题,给您一段代码,,您对比下:
- #include <osg/Node>
- #include <osg/Group>
- #include <osg/Geode>
- #include <osg/Geometry>
- #include <osg/Texture2D>
- #include <osgDB/ReadFile>
- #include <osgViewer/Viewer>
- #include <osg/PositionAttitudeTransform>
- #include <osgGA/TrackballManipulator>
- int main()
- {
- osgViewer::Viewer viewer;
- osg::Group* root = new osg::Group();
- osg::Geode* pyramidGeode = new osg::Geode();
- osg::Geometry* pyramidGeometry = new osg::Geometry();
- pyramidGeode->addDrawable(pyramidGeometry);
- root->addChild(pyramidGeode);
- osg::Vec3Array* pyramidVertices = new osg::Vec3Array;
- pyramidVertices->push_back( osg::Vec3( 0, 0, 0) );
- pyramidVertices->push_back( osg::Vec3(10, 0, 0) );
- pyramidVertices->push_back( osg::Vec3(10,10, 0) );
- pyramidVertices->push_back( osg::Vec3( 0,10, 0) );
- pyramidVertices->push_back( osg::Vec3( 5, 5,10) );
- pyramidGeometry->setVertexArray( pyramidVertices );
- osg::DrawElementsUShort* pyramidBase =
- new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_FAN);
- pyramidBase->push_back(4);
- pyramidBase->push_back(3);
- pyramidBase->push_back(2);
- pyramidBase->push_back(1);
- pyramidBase->push_back(0);
- pyramidGeometry->addPrimitiveSet(pyramidBase);
- viewer.setSceneData( root );;
- viewer.setCameraManipulator(new osgGA::TrackballManipulator());
- viewer.realize();
- while( !viewer.done() )
- {
- viewer.frame();
- }
- return 0;
- }
复制代码 |
|