当前位置: 首页 > news >正文

芜湖 网站建设潍坊建公司网站

芜湖 网站建设,潍坊建公司网站,深圳做网页,wordpress如何登录后台自定义粒子系统示例(一) 自定义粒子系统示例(一)的代码如程序清单11-5所示&#xff1a; /* 自定义粒子系统示例1 */ void particleSystem_11_5(const string &strDataFolder) {osg::ref_ptr<osgViewer::Viewer> viewer new osgViewer::Viewer();osg::ref_ptr<os…

自定义粒子系统示例(一)

        自定义粒子系统示例(一)的代码如程序清单11-5所示:

/* 自定义粒子系统示例1 */
void particleSystem_11_5(const string &strDataFolder)
{osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;traits->x = 40;traits->y = 40;traits->width = 600;traits->height = 480;traits->windowDecoration = true;traits->doubleBuffer = true;traits->sharedContext = 0;osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());osg::ref_ptr<osg::Camera> camera = viewer->getCamera();camera->setGraphicsContext(gc.get());camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;camera->setDrawBuffer(buffer);camera->setReadBuffer(buffer);osg::ref_ptr<osg::Group> root = new osg::Group();// 自定义粒子系统加入场景root->addChild(createParticleScene(strDataFolder));// 优化场景数据osgUtil::Optimizer optimize;optimize.optimize(root.get());viewer->setSceneData(root.get());viewer->realize();viewer->run();
}// 创建自定义粒子系统
osg::ref_ptr<osg::Group> createParticleScene(const string &strDataFolder)
{osg::ref_ptr<osg::Group> root = new osg::Group();// 创建粒子系统模板osgParticle::Particle ptemplate;	ptemplate.setLifeTime(2);// 设置声明周期ptemplate.setSizeRange(osgParticle::rangef(0.75, 3.0));// 设置粒子大小变化范围	ptemplate.setAlphaRange(osgParticle::rangef(0.0, 1.0));// 设置粒子Alpha变化范围ptemplate.setColorRange(osgParticle::rangev4(osg::Vec4(1.0, 0.5, 0.3, 1.0),osg::Vec4(0.0, 0.7, 1.0, 0.0)));// 设置粒子颜色变化范围	ptemplate.setRadius(0.05);// 设置半径	ptemplate.setMass(0.05);// 设置重量// 创建粒子系统osg::ref_ptr<osgParticle::ParticleSystem> ps = new osgParticle::ParticleSystem();string strClrPath = strDataFolder + "Images\\smoke.rgb";ps->setDefaultAttributes(strClrPath, false, false);// 设置材质,是否放射粒子,是否添加光照	ps->setDefaultParticleTemplate(ptemplate);// 加入模板// 创建发射器和计数器,调整每一帧增加的粒子的数目osg::ref_ptr<osgParticle::RandomRateCounter> counter = new osgParticle::RandomRateCounter();counter->setRateRange(100.0,100.0);// 设置每秒增加的粒子的个数// 设置一个点放置器osg::ref_ptr<osgParticle::PointPlacer> placer = new osgParticle::PointPlacer();placer->setCenter(osg::Vec3(0.0, 0.0, 0.0));// 设置位置// 创建弧度发射器osg::ref_ptr<osgParticle::RadialShooter> shooter = new osgParticle::RadialShooter();shooter->setInitialSpeedRange(100, 0);// 设置发射器速度变化范围// 创建粒子放射器(包括计数器、放射器和发射器)osg::ref_ptr<osgParticle::ModularEmitter> emitter = new osgParticle::ModularEmitter();emitter->setParticleSystem(ps.get());// 关联粒子系统emitter->setCounter(counter.get());// 关联计数器emitter->setPlacer(placer.get());// 关联点放置器emitter->setShooter(shooter.get());// 关联发射器root->addChild(emitter.get());// 加入场景// 创建重力模拟对象osg::ref_ptr<osgParticle::AccelOperator> ap = new osgParticle::AccelOperator();ap->setToGravity(-1.0);// 设置重力加速度,默认值为9.80665// 创建空气阻力模拟osg::ref_ptr<osgParticle::FluidFrictionOperator> ffo = new osgParticle::FluidFrictionOperator();	// FluidViscosity为1.8e-5,FluidDensity为1.2929ffo->setFluidToAir();// 设置空气属性// 创建标准编程器对象,控制粒子在生命周期中的更新osg::ref_ptr<osgParticle::ModularProgram> program = new osgParticle::ModularProgram();program->setParticleSystem(ps.get());// 关联粒子系统program->addOperator(ap.get());// 关联重力	program->addOperator(ffo.get());// 关联空气阻力root->addChild(program.get());// 添加到场景// 添加更新器,实现每帧粒子的管理osg::ref_ptr<osgParticle::ParticleSystemUpdater> psu = new osgParticle::ParticleSystemUpdater();	psu->addParticleSystem(ps.get());// 关联粒子系统osg::ref_ptr<osg::Geode> geode = new osg::Geode;geode->addDrawable(ps.get());	root->addChild(geode.get());// 加入到场景中root->addChild(psu.get());return root.get();
}

        运行程序,截图如图11-7所示。

图11-7自定义粒子系统示例(一)截图

http://www.15wanjia.com/news/167072.html

相关文章:

  • 珠海在线网站制作公司家在深圳歌词
  • 如今做哪个网站致富网站的导航栏
  • 把网站提交谷歌郑州seo排名优化
  • 网站建设能做什么工作广州南沙网站建设公司
  • 设计师发布作品的网站网页怎么认证
  • 好的企业网站建设旅游网站名字
  • 威海外贸网站建设怎么样flash网站首页
  • asp源代码网站义乌跨境电商公司前十名
  • 前端开发做移动端的网站广州网站建设 骏域
  • 网站制作 客户刁难10个国内建筑网站
  • 哪个网站做系统设计公司装修
  • 广东建设执业资格注册管理中心网站做ppt的兼职网站有哪些
  • 青岛网站设计公司在哪找隆尧企业做网站
  • 化妆网站模板兖州网站建设哪家好
  • 锦州建设工程信息网站网页设计模板图片并排显示
  • 最简单的cms网站怎么做免费空间访客网站
  • 黄石网站建设推荐中国空间站设计在轨飞行多少年
  • 吴江住房建设局网站中国建设教育网站官方
  • 广州做网站信息什么是网站的根目录
  • 桂林网站制作哪家公司好网站部署 模板
  • 使用阿里云建网站wordpress怎么选择中文
  • 义乌企业网站建设网站权重0
  • 南宁京象建站公司怎么下载四川人社app
  • 物流公司怎么做网站加工网线
  • 南阳网站广告推广代理
  • 登陆中国建设银行网站我的账户密码怎么就有了?怎么清除西宁网站开发
  • 100个万能网站树形菜单网站
  • 公司官方网站建设需要多少钱国家城乡住房建设厅网站
  • 江苏工程建设信息网站wordpress utc时间差12个小时
  • 汕头网站制作专业软件下载网站制作