osg入门系列11- 预订义几何体
来源:互联网 发布:网络法制知识竞赛答题 编辑:程序博客网 时间:2024/04/30 13:21
#include <osgViewer/Viewer>
#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <iostream>
using namespace std;
osg::ref_ptr<osg::Geode> createShape()
{
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
float radius = 0.8f;
float height = 1.0f;
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
hints->setDetailRatio(0.8f);
geode->addDrawable(new osg::ShapeDrawable(
new osg::Sphere(
osg::Vec3(0.0f, 0.0f, 0.0f), radius), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Box(
osg::Vec3(2.0f, 0.0f, 0.0f), 2*radius), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Cone(
osg::Vec3(4.0f, 0.0f, 0.0f), radius, height), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Cylinder(
osg::Vec3(6.0f, 0.0f, 0.0f), radius, height), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Capsule(
osg::Vec3(8.0f, 0.0f, 0.0f), radius, height), hints.get()));
return geode.get();
}
int main()
{
//cout << "Hello World!" << endl;
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(createShape());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
}
#include <osg/Node>
#include <osg/Geode>
#include <osg/Group>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <iostream>
using namespace std;
osg::ref_ptr<osg::Geode> createShape()
{
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
float radius = 0.8f;
float height = 1.0f;
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
hints->setDetailRatio(0.8f);
geode->addDrawable(new osg::ShapeDrawable(
new osg::Sphere(
osg::Vec3(0.0f, 0.0f, 0.0f), radius), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Box(
osg::Vec3(2.0f, 0.0f, 0.0f), 2*radius), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Cone(
osg::Vec3(4.0f, 0.0f, 0.0f), radius, height), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Cylinder(
osg::Vec3(6.0f, 0.0f, 0.0f), radius, height), hints.get()));
geode->addDrawable(new osg::ShapeDrawable(
new osg::Capsule(
osg::Vec3(8.0f, 0.0f, 0.0f), radius, height), hints.get()));
return geode.get();
}
int main()
{
//cout << "Hello World!" << endl;
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
root->addChild(createShape());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
viewer->run();
return 0;
}
----
0 0
- osg入门系列11- 预订义几何体
- osg入门系列13-几何体简化
- osg入门系列10-以索引方式的几何体绘制
- osg预定义几何体设置颜色
- osg预定义几何体设置颜色
- OSG学习:使用OSG中预定义的几何体
- OSG简化几何体显示
- osg入门系列1 - 初识osg
- OSG MFC入门基础系列
- osg入门系列3 - 开关节点例子
- osg入门系列5-代替节点
- osg入门系列6- 遮挡查询节点
- osg入门系列7- 一个小房子
- osg入门系列8-一个地球
- osg入门系列9-一个正方形
- osg入门系列12-多边形分格
- osg入门系列14-狄落泥三角网
- osg入门系列-生成顶点法向量
- 贝护佳孕妇客户端,笔记
- vs2013运行c语言出现:无法查找或打开 PDB 文件
- 【内核研究】理解Context
- CF #266 (Div. 2) B
- libcurl multi接口分析
- osg入门系列11- 预订义几何体
- 1.VC6.0致命错误 RC1015: 无法打开包含文件 'afxres.h'.解决方案
- 《数据结构》实验一:VC编程环境灵活应用
- 图片压缩算法(宽高不变)
- 运行一个EXE文件时,出现下面的文字,但程序能正常跑,请问怎么查找哪地方出现内存溢出?
- 【Python Challenge-6】zip
- 抽象方法不能是static或native或synchroniz 原因及误解
- C语言_预处理命令
- osg入门系列12-多边形分格