NeHe OpenGL Lesson19 – Particle Engine Using Triangle Strips(粒子引擎)

本文介绍了一种简单的粒子引擎,粒子效果在游戏中至关重要,可用于模拟爆炸、水泉、燃烧的星星等。粒子由一组三角形广告牌组成,每个粒子具有位置、运动方向与速度、颜色等属性。文章探讨了粒子初始化、生命周期内更新(包括颜色渐变)、重新激活等关键点,并提出改进方案,如在3D场景中任意位置生成粒子、基于规则生成、沿曲线改变属性等。

screen_shot1-300x238 Here is a simple particle engine. The particle effect is a very important element in game. It could be used simulate an explosion, water fountain, flaming star and so on.
Generally speaking, a particle is a group of triangle billboards.  Each triangle has position, moving direction & speed, moving accelerate direction & speed, gravity, life time, whether active or not, color attributes and so on. During their life time, their color attribute will fade in and fade out.  And those triangles will always face to the view camera no matter how the camera set up.

 

Something Further

This program covers almost all key points of a particle engine. Some thing like initialize the particle triangle attributes, update them during their life time (include fade in & fade out the color), then de-active or re-active them if they run out of their life time. Well, but still some thing more we could improve:
1) The particle engine spawn triangle strip billboards in the fixed z-axes. We could make the particle billboards be spawned at any location in the 3D scene. And at the same time, we will make those triangles face toward the view camera.
2) We could make particle billboards be spawned based on some rules. Like, spawn them in a box, among a sphere, along a circle, cylinder or even a quadrics surface. This will make them more real, more cool.
3) Those attributes that change along the time-line could be linear as this program does. Or even more complicated, how about changing along a curve?
4) More attributes works with more complicated material could be changing along time-line. Like texture coordinates, vertex color, scale size and so on.
5) A better solution to design a particle engine is separate those attributes that need to change as time goes. That means you need to design two vertex array: dynamic one for those vertex attribute that need to change, and a static one for other stuff. This ways is called un-rolled data structure. It is deserved as you strong feel that the particle engine part become the bottle neck of the program. But as the same time, you need to think carefully before you apply this solution into your project. Because this will break object-oriented rule, and make the source code not so easy to understand. This may involved a big change in code, and break the stable version. Think twice! The other way could be reducing the number of the particles.

 

The following code(particle attributes updating) are the core of this particle engine. You could modify them based on your plan here.

particle[loop].x+=particle[loop].xi/(slowdown*1000);// Move On The X Axis By X Speed
particle[loop].y+=particle[loop].yi/(slowdown*1000);// Move On The Y Axis By Y Speed
particle[loop].z+=particle[loop].zi/(slowdown*1000);// Move On The Z Axis By Z Speed
 
particle[loop].xi+=particle[loop].xg;            // Take Pull On X Axis Into Account
particle[loop].yi+=particle[loop].yg;            // Take Pull On Y Axis Into Account
particle[loop].zi+=particle[loop].zg;            // Take Pull On Z Axis Into Account
particle[loop].life-=particle[loop].fade;        // Reduce Particles Life By 'Fade'
 
if (particle[loop].life<0.0f)                    // If Particle Is Burned Out
{
  particle[loop].life=1.0f;                    // Give It New Life
  particle[loop].fade=float(rand()%100)/1000.0f+0.003f;    // Random Fade Value
  particle[loop].x=0.0f;                        // Center On X Axis
  particle[loop].y=0.0f;                        // Center On Y Axis
  particle[loop].z=0.0f;                        // Center On Z Axis
  particle[loop].xi=xspeed+float((rand()%60)-32.0f);    // X Axis Speed And Direction
  particle[loop].yi=yspeed+float((rand()%60)-30.0f);    // Y Axis Speed And Direction
  particle[loop].zi=float((rand()%60)-30.0f);    // Z Axis Speed And Direction
  particle[loop].r=colors[col][0];            // Select Red From Color Table
  particle[loop].g=colors[col][1];            // Select Green From Color Table
  particle[loop].b=colors[col][2];            // Select Blue From Color Table
}

 

The full source code could be downloaded from here.

转载于:https://www.cnblogs.com/open-coder/archive/2012/08/23/2653308.html

基于TROPOMI高光谱遥感仪器获取的大气成分观测资料,本研究聚焦于大气污染物一氧化氮(NO₂)的空间分布与浓度定量反演问题。NO₂作为影响空气质量的关键指标,其精确监测对环境保护与大气科学研究具有显著价值。当前,利用卫星遥感数据结合先进算法实现NO₂浓度的高精度反演已成为该领域的重要研究方向。 本研究构建了一套以深度学习为核心的技术框架,整合了来自TROPOMI仪器的光谱辐射信息、观测几何参数以及辅助气象数据,形成多维度特征数据集。该数据集充分融合了不同来源的观测信息,为深入解析大气中NO₂的时空变化规律提供了数据基础,有助于提升反演模型的准确性与环境预测的可靠性。 在模型架构方面,项目设计了一种多分支神经网络,用于分别处理光谱特征与气象特征等多模态数据。各分支通过独立学习提取代表性特征,并在深层网络中进行特征融合,从而综合利用不同数据的互补信息,显著提高了NO₂浓度反演的整体精度。这种多源信息融合策略有效增强了模型对复杂大气环境的表征能力。 研究过程涵盖了系统的数据处理流程。前期预处理包括辐射定标、噪声抑制及数据标准化等步骤,以保障输入特征的质量与一致性;后期处理则涉及模型输出的物理量转换与结果验证,确保反演结果符合实际大气浓度范围,提升数据的实用价值。 此外,本研究进一步对不同功能区域(如城市建成区、工业带、郊区及自然背景区)的NO₂浓度分布进行了对比分析,揭示了人类活动与污染物空间格局的关联性。相关结论可为区域环境规划、污染管控政策的制定提供科学依据,助力大气环境治理与公共健康保护。 综上所述,本研究通过融合TROPOMI高光谱数据与多模态特征深度学习技术,发展了一套高效、准确的大气NO₂浓度遥感反演方法,不仅提升了卫星大气监测的技术水平,也为环境管理与决策支持提供了重要的技术工具。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值