|
int main( int argc, char **argv )
{
osgViewer::Viewer viewer;
osg::Switch* switchForYin = new osg::Switch();
osg::Group* group = new osg::Group();
// switchForYin->addEventCallback();
switchForYin->setValue(0,true);
// group->addChild(runGroup->getGroup());
//group->addChild(switchForYin);
//显示模型
osg::MatrixTransform* position1 = new osg::MatrixTransform();
position1->setMatrix(osg::Matrix::scale(1,1,1));
osg::Node* crh = osgDB::readNodeFile("cow.osg");
position1->addChild(crh);
position1->getOrCreateStateSet()->setMode(GL_LIGHTING ,osg::StateAttribute::ON);
//group->addChild(position1);
switchForYin->addChild(position1);
//switchForYin->addEventCallback(new switchCallback(switchForYin));
switchForYin->addEventCallback(new groupCallback(position1));
group->addChild(switchForYin);
/*osgUtil::Optimizer optimzer;
optimzer.optimize(group);*/
viewer.setSceneData(group);
//viewer.getCamera()->setClearColor(osg::Vec4(1.0,1.0,1.0,0.0));
viewer.run();
return 0;
} |
|