osg线框模式
問題的提出:
用如下代碼,加載一個osg文件
#include <osgViewer/Viewer> #include <osgViewer/CompositeViewer> #include <osg/Node> #include <osg/Geode> #include <osg/Group> #include <osg/Geometry> #include <osg/Camera> #include <osg/MatrixTransform> #include <osg/PositionAttitudeTransform> #include <osgDB/ReadFile> #include <osgDB/WriteFile> #include <osgUtil/Optimizer> #include<osg/PolygonMode> #include <iostream>int main() {osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;//初始化場景根節(jié)點osg::ref_ptr<osg::Group> root = new osg::Group;//場景數(shù)據(jù)osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("d:/gzbody.OSGB");root->addChild(node);//將場景數(shù)據(jù)加入視景器中viewer->setSceneData(root);viewer->run();return 0; }展示的模型如下所示:
用戶說有時需要提供線框模式,即像下圖那樣:
?
代碼如下:
#include <osgViewer/Viewer> #include <osgViewer/CompositeViewer> #include <osg/Node> #include <osg/Geode> #include <osg/Group> #include <osg/Geometry> #include <osg/Camera> #include <osg/MatrixTransform> #include <osg/PositionAttitudeTransform> #include <osgDB/ReadFile> #include <osgDB/WriteFile> #include <osgUtil/Optimizer> #include<osg/PolygonMode> #include <iostream>int main() {osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;// 初始化場景根節(jié)點osg::ref_ptr<osg::Group> root = new osg::Group;// 場景數(shù)據(jù)osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("d:/gzbody.OSGB");osg::ref_ptr<osg::StateSet>spStateSet = node->getOrCreateStateSet();osg::ref_ptr<osg::PolygonMode> polyMode = new osg::PolygonMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::POINT);spStateSet->setAttribute(polyMode);root->addChild(node);// 將場景數(shù)據(jù)加入視景器中viewer->setSceneData(root);viewer->run();return 0; }?
?
?
總結(jié)
- 上一篇: gta5线上赚钱攻略(萌新快速赚钱攻略)
- 下一篇: 710比855差多少