Learning OSG programing---osgScribe
Learning OSG programing---osgScribe
Scribe可以翻译为素描,抄写等。本例通过在模型表面添加一层素描,来显示模型的骨架。
关键代码:
- osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
- osg::ref_ptr<osg::PolygonOffset> polyoffset = new osg::PolygonOffset;
- polyoffset->setFactor(-1.0f);
- polyoffset->setUnits(5.0f);
- osg::ref_ptr<osg::PolygonMode> polymode = new osg::PolygonMode;
- polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
- stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
- stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
- osg::ref_ptr<osg::Material> material = new osg::Material;
- material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4f(1.0,0.0,1.0,1.0));
- stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
13 stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
14 decorator->setStateSet(stateset);
这段代码主要设置用于绘制素描效果的属性集stateset。属性集的设置主要是三个方面:
PolygonOffest polyoffset用于设置素描模型和加载模型之间的偏移,避免深度检测过小,出现的闪烁现象。这个类主要是封装了OpenGL中的glPolygonOffset函数,其成员函数和说明可见于这里。关于OpenGL中的glPolygonOffset函数的使用说明可见这里。分析这个例程的对象关系图,如下所示:
这个例程的对象关系还是很清晰的,通过对Scribe装饰对象decorator设置其状态集,设置PolygonOffset避免闪烁,设置PolygonMode将装饰器设置为线模型,通过设置materal可更改线框的颜色,材质,纹理,各种光照反射效果等。最后将装饰器节点和加载模型共同添加到根节点,显示线框效果:
Learning OSG programing---osgScribe的更多相关文章
- Learning OSG programing---Multi Camera in Multi window 在多窗口中创建多相机
这个例子演示了在多个窗口中创建多个相机,函数的代码如下: void multiWindowMultipleCameras(osgViewer::Viewer& viewer,bool mult ...
- Learning OSG programing---Multi Camera in one window 在单窗口中创建多相机
在学习OSG提供的例子osgCamera中,由于例子很长,涉及很多细节,考虑将其分解为几个小例子.本文介绍实现在一个窗口中添加多个相机的功能. 此函数接受一个Viewer引用类型参数,设置图形上下文的 ...
- Learning OSG programing---osgAnimation(3)
接下来是用createModel函数创建模型: osg::ref_ptr<osg::Group> createModel(bool overlay, osgSim::OverlayNode ...
- Learning OSG programing---osgAnimation(2)
osg::Node* createBase(const osg::Vec3& center,float radius) { ; ; *radius; *radius; osg::Vec3 v0 ...
- Learning OSG programing---osgAnimation(1)
osg::AnimationPath* createAnimationPath(const osg::Vec3& center,float radius,double looptime) { ...
- Learning OSG programing---osgShape
本例示范了osg中Shape ---- 基本几何元素的绘制过程.参照osg官方文档,Shape 类包含以下子类: 在示例程序中,函数createShapes函数用于生成需要绘制的几何形状. osg:: ...
- Learning OSG programing---osgClip
OSG Clip例程剖析 首先是创建剪切节点的函数代码: osg::ref_ptr<osg::Node> decorate_with_clip_node(const osg::ref_pt ...
- Learning OSG programing---osgwindows
/* OpenSceneGraph example, osgwindows. * * Permission is hereby granted, free of charge, to any pers ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week3, Hyperparameter tuning, Batch Normalization and Programming Frameworks
Tuning process 下图中的需要tune的parameter的先后顺序, 红色>黄色>紫色,其他基本不会tune. 先讲到怎么选hyperparameter, 需要随机选取(sa ...
随机推荐
- 最小割树(Gomory-Hu Tree)求无向图最小割详解 附 BZOJ2229,BZOJ4519题解
最小割树(Gomory-Hu Tree) 前置知识 Gomory-Hu Tree是用来解决无向图最小割的问题的,所以我们需要了解无向图最小割的定义 和有向图类似,无向图上两点(x,y)的割定义为一个边 ...
- k8s 组件介绍-kube-schedule
kubernetes scheduler 基本原理 kubernetes scheduler 作为一个单独的进程部署在 master 节点上,它会 watch kube-apiserver 进程去发现 ...
- springcloud费话之配置中心基础(SVN)
目录: springcloud费话之Eureka基础 springcloud费话之Eureka集群 springcloud费话之Eureka服务访问(restTemplate) springcloud ...
- web笔记全
1.项目流程与数据库 1.课程体系 阶段1(服务器开发): 项目导入/数据库/JS基础/NodeJS 阶段2(前端核心技术): HTML/AJAX/CSS/bootstrap 阶段3(前端进阶技术): ...
- elasticsearch 基础 —— ReIndex
Reindex会将一个索引的数据复制到另一个已存在的索引,但是并不会复制原索引的mapping(映射).shard(分片).replicas(副本)等配置信息. 一.reindex的常用操作 1.re ...
- shell变量的声明和使用
- django允许外部访问 项目后台不挂断运行
1关闭防火墙 1 service iptables stop 2设置django 1 2 3 4 5 6 7 8 9 10 11 开开启django时,使用0.0.0.0:xxxx,作为ip和端口例如 ...
- 8.xpath(dom4j支持的jar)
1.使用dom4j支持xpath的操作(xpath可以直接获取到某个元素) (1)第一种形式 /AAA/DDD/BBB:表示一层一层的,AAA下面DDD下面的BBB元素 (2)第二种形式 //BBB: ...
- sql 中 exists用法
SQL中EXISTS的用法 比如在Northwind数据库中有一个查询为SELECT c.CustomerId,CompanyName FROM Customers cWHERE EXISTS(S ...
- List和Tuple的中的method对比