|
楼主 |
发表于 2010-8-12 15:13:03
|
显示全部楼层
本帖最后由 Phoenix 于 2010-8-12 16:22 编辑
麻烦你给看一下!还是报这个错误!
代码如下:
class SequenceEventHandler : public osgGA::GUIEventHandler
{
public:
SequenceEventHandler(osg::Sequence* seq)
{
_seq = seq;
}
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
osg::Sequence::SequenceMode mode = _seq->getMode();
if (ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN)
{
switch (ea.getKey())
{
case 'p':
{
mode = osg::SequenceAUSE ;
_seq->setMode(mode);
}
break ;
case 's':
{
mode = osg::Sequence::START ;
_seq->setMode(mode);
}
break ;
default:
break;
}
}
return false;
}
private:
osg::ref_ptr<osg::Sequence> _seq;
};
int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("_T_An24.osg");
FindNodeVisitor seq("OSG_Sequence01");
node->accept(seq);
root->addChild(seq.getFirst());
viewer->addEventHandler(new SequenceEventHandler(seq.getFirst()));
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
} |
|