您的位置:首页 > 编程语言 > C语言/C++

一个最简单的OSG例子源代码(C++)

2010-01-14 16:28 429 查看
#include <osg/Group>
#include <osg/Geode>
#include <osgViewer/Viewer>
#include <osg/ShapeDrawable>

int main()
{
//Creating the viewer
osgViewer::Viewer viewer;

//Creating the root node
osg::ref_ptr<osg::Group> root (new osg::Group);

//The geode containing our shape
osg::ref_ptr<osg::Geode> myshapegeode (new osg::Geode);

//Our shape: a capsule, it could have been any other geometry (a box, plane, cylinder etc.)
osg::ref_ptr<osg::Capsule> myCapsule (new osg::Capsule(osg::Vec3f(),1,2));

//Our shape drawable
osg::ref_ptr<osg::ShapeDrawable> capsuledrawable (new osg::ShapeDrawable(myCapsule.get()));

myshapegeode->addDrawable(capsuledrawable.get());

root->addChild(myshapegeode.get());

viewer.setSceneData( root.get() );

return (viewer.run());
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: