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 ...
随机推荐
- UVAlive 6756 Increasing Shortest Path
We all love short and direct problems, it is easier to write, read and understand the problem statem ...
- 65.Longest Increasing Subsequence(最长增长子序列)
Level: Medium 题目描述: Given an unsorted array of integers, find the length of longest increasing sub ...
- Vue小白篇 - Vue介绍
Vue ?啥是Vue?能干嘛? vue 的介绍 Vue 是一套用于构建用户界面的 渐进式框架 ,与其它大型框架不同的是, Vue 被设计为可以自底向上逐层应用.Vue 的核心库只关注视图层 前端三大框 ...
- postman 上一个接口的返回值作为下一个接口的入参
在使用postman做接口测试的时候,在多个接口的测试中,如果需要上一个接口的返回值作为下一个接口的入参,其基本思路是: 1.获取上一个接口的返回值 2.将返回值设置成环境变量或者全局变量 3.设置下 ...
- 98-基于FPGA Spartan6 的双路光纤PCIe采集卡(2路光纤卡) 光纤PCIe卡
1.板卡概述 板卡采用xilinx Spartan6系列芯片,支持 PCI Express Base Specification 1.1 x1.内含丰富的逻辑资源和存储单元,板卡FPGA外接双片32M ...
- 一、小程序内嵌Html示例
小程序内嵌Html 1.下载wxParse:https://github.com/icindy/wxParse 2.下载完成后将插件目录下的wxParse文件夹拷贝到项目目录下 (文件夹明细) 3.全 ...
- ElasticSearch(java) 创建索引
搜索]ElasticSearch Java Api(一) -创建索引 标签: elasticsearchapijavaes 2016-06-19 23:25 33925人阅读 评论(30) 收藏 举报 ...
- MySQLdb-python安装
安装很简单,步骤如下: 前期:yum -y install python-setuptools,或者自己网上找源码包安装 1. 下载安装包: #wget https://pypi.python.or ...
- loj6177 「美团 CodeM 初赛 Round B」送外卖2 最短路+状压dp
题目传送门 https://loj.ac/problem/6177 题解 一直不知道允不允许这样的情况:取了第一的任务的货物后前往配送的时候,顺路取了第二个货物. 然后发现如果不可以这样的话,那么原题 ...
- 通过注释查找mysql的表名
通过注释查找mysql的表名 select * from INFORMATION_SCHEMA.columns where COLUMN_NAME Like '%placement%';