|
楼主 |
发表于 2015-12-7 22:25:31
|
显示全部楼层
出了想要的结果,附上源码
#include "osg/Node"
#include "osg/Drawable"
#include "osgViewer/Viewer"
#include "osgDB/ReadFile"
#include "osg/Geode"
#include "osg/Group"
#include "osg/ShapeDrawable"
#include <stdio.h>
class mycallback :public osg::NodeCallback
{
public:
mycallback()
{
i=1;
};
~mycallback(){};
virtual void operator()(osg::Node*node,osg::NodeVisitor* nv)
{
osg::Geode* g1=dynamic_cast<osg::Geode*>(node);
g1->setDrawable(0,new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),i)));
i=i+0.01;
}
protected:
float i;
};
int main()
{
osg::Group* root1=new osg::Group;
osgViewer::Viewer viewer;
osg::Geode* geode=new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),3)));
viewer.setSceneData(root1);
root1->addChild(geode);
mycallback* cb=new mycallback;
geode->setUpdateCallback(cb);
viewer.realize();
viewer.run();
//cout<<
return 0;
} |
|