osg学习函数用法addPrimitiveSet +模型操作
来源:互联网 发布:cassandra数据库登录 编辑:程序博客网 时间:2024/04/30 06:39
addPrimitiveSet函数用来设置绘制的几何图形。
DrawArrays 类的构造函数为osg::DrawArrays::DrawArrays ( GLenum mode, GLint first, GLsizei count ) ,mode是几何图形的类型,
有:osg::Box[盒子],
osg::Capsule[胶囊形],
osg::CompositeShape[组合型],
osg::Cone[圆锥形],
osg::Cylinder[圆柱形],
osg::HeightField[高程形],
osg::InfinitePlane[有限面],
osg::Sphere[球形],o
sg::TriangleMesh[三角蒙皮]等;
osg::PrimitiveSet::GLenum mode, GLint first, GLsizei count ) );//基础类型,顶点的关联方式
。总共有这么些方式:
POINTS ,LINES ,LINE_STRIP ,LINE_LOOP, TRIANGLES ,TRIANGLE_STRIP, TRIANGLE_FAN ,QUADS ,QUAD_STRIP ,POLYGON 。
____________________first是顶点数组中的起始数据的数组下标,count是数据的个数\——————————————————————————————————————————————————————————
//模型操作 右是X轴,向里的是Y轴,而向上是Z轴
//移动
// osg::MatrixTransform*trans=new osg::MatrixTransform;//生成矩阵变换函数指针
osg::ref_ptr < osg::MatrixTransform> trans = new osg::MatrixTransform;
//trans->setMatrix(osg::Matrix::translate(0,0,50));//向上
trans->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(90.0),0,0,-1)*
osg::Matrix::scale(3,3,3)*osg::Matrix::translate(0,0,50));//向移单位+放大 ,,,注意顺序问题
trans->addChild(cow);
//缩放
osg::ref_ptr < osg::MatrixTransform> scale = new osg::MatrixTransform;
//scale->setMatrix(osg::Matrix::scale(25,25,25));//放大25
scale->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(90.0),0,0,1)*
osg::Matrix::scale(25,25,25)*osg::Matrix::translate(-80, 0, -2));//大5+向下,乘号,
scale->addChild(glider);
//旋转
osg::ref_ptr < osg::MatrixTransform> rot = new osg::MatrixTransform;
rot->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(45.0),1, 0, 0)*
osg::Matrix::scale(0.5,0.5,0.5)*osg::Matrix::translate(80, 0, -2)) ;//向右单位,缩0.5且平躺45度 x,y,z轴
rot->addChild(Cessna);
root->addChild(Cessna);//原模型
root->addChild(trans);
root->addChild(scale);
root->addChild(rot);
//移动
// osg::MatrixTransform*trans=new osg::MatrixTransform;//生成矩阵变换函数指针
osg::ref_ptr < osg::MatrixTransform> trans = new osg::MatrixTransform;
//trans->setMatrix(osg::Matrix::translate(0,0,50));//向上
trans->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(90.0),0,0,-1)*
osg::Matrix::scale(3,3,3)*osg::Matrix::translate(0,0,50));//向移单位+放大 ,,,注意顺序问题
trans->addChild(cow);
//缩放
osg::ref_ptr < osg::MatrixTransform> scale = new osg::MatrixTransform;
//scale->setMatrix(osg::Matrix::scale(25,25,25));//放大25
scale->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(90.0),0,0,1)*
osg::Matrix::scale(25,25,25)*osg::Matrix::translate(-80, 0, -2));//大5+向下,乘号,
scale->addChild(glider);
//旋转
osg::ref_ptr < osg::MatrixTransform> rot = new osg::MatrixTransform;
rot->setMatrix(osg::Matrix::rotate(osg::DegreesToRadians(45.0),1, 0, 0)*
osg::Matrix::scale(0.5,0.5,0.5)*osg::Matrix::translate(80, 0, -2)) ;//向右单位,缩0.5且平躺45度 x,y,z轴
rot->addChild(Cessna);
root->addChild(Cessna);//原模型
root->addChild(trans);
root->addChild(scale);
root->addChild(rot);
0 0
- osg学习函数用法addPrimitiveSet +模型操作
- OSG学习:移动/缩放/旋转模型
- stl格式模型导入osg后旋转操作
- 自定义回调控制OSG模型进行移动操作
- OSG学习笔记0——解决OSG读obj模型问题
- CityMaker学习教程12 osg模型的创建
- CityMaker学习教程13 osg模型的移动
- OSG学习笔记2:地形构建和模型加载
- osg学习
- OSG学习
- OSG模型简单控制
- osg模型重写
- osg模型透明代码
- osg添加骨骼模型
- OSG模型控制
- osg模型发黑
- OSG-简单模型控制
- OSG学习:osgViewer命令行参数和常用操作
- C++编译连接总结(二)--自己的静态库动态库的编译与引用
- SSH框架总结(框架分析+环境搭建+实例源码下载)
- 2016.6.24笔记(4)-集合类的一些面试题
- 打印机驱动特殊安装步骤
- 通过一个接口获取json数据并展示
- osg学习函数用法addPrimitiveSet +模型操作
- #pragma mark /*邮箱验证 /手机验证 HELENSONG*/
- C++编译连接总结(三)--cmake
- 静态类 抽象类 静态方法等等
- 杀毒引擎的原理
- ffmpeg源码分析之媒体打开过程
- oracle : shared memory realm does not exist 故障解决
- xmppFramework框架的导入和介绍
- WindowsXP下安装IntelliJ IDEA Ultimate Edition