|
楼主 |
发表于 2009-8-12 20:01:23
|
显示全部楼层
#include <osgViewer/Viewer>
#include <osg/Math>
#include <osgDB/ReadFile>
#include <osg/NodeCallback>
#include <osg/MatrixTransform>
class MyTransformCallback:public osg::NodeCallback
{
public:
MyTransformCallback(float angularVelocity)
{
m_angularVelocity = angularVelocity;
}
virtual void operator()(osg::Node *node,osg::NodeVisitor *nv)
{
osg::Group *root = new osg::Group;
root->setDataVariance(osg::Object:YNAMIC);
root->addChild(osgDB::readNodeFile("glider.osg"));
if(nv&&root&&nv->getFrameStamp())
{
double time = nv->getFrameStamp()->getReferenceTime();
}
traverse(node,nv);
}
protected:
float m_angularVelocity;
};
int main(int agrc,char**argv)
{
osgViewer::Viewer viewer;
osg::Group *root= new osg::Group;
root->setDataVariance(osg::Object::DYNAMIC);
osg::Node *node=osgDB::readNodeFile("glider.osg");
osg::Node *node1 =osgDB::readNodeFile("cow.osg");
osg::MatrixTransform *transform =new osg::MatrixTransform();
transform->setUpdateCallback(new MyTransformCallback(1.0));
transform->addChild(node);
//root->addChild(node1);
root->addChild(transform);
viewer.setSceneData(root);
viewer.realize();
viewer.run();
return 1;
}
回调中咋写删除节点 |
|