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

使用Quick3D粒子的雨效果

Rain effect with Quick3D Particles

使用Quick3D粒子的雨效果

February 16, 2026 by Antti Määttä | Comments

​2026年2月16日由Antti Mäattä发表|评论

Here is an overview on the new features added to the Quick3D.Particles module for Qt 6.10 and 6.11. The goal was to support effects that look like they are interacting with the scene and to do this without expensive simulations/calculations. Specifically we'll be using rain effect as an example when going trough the new features.

以下是Qt 6.10和6.11的Quick3D.Particles模块新增功能的概述。目标是支持看起来与场景交互的效果,并且不需要昂贵的模拟/计算。具体来说,在浏览新功能时,我们将使用雨效应作为示例。

The rain effect consists of the rain particles hitting the scene and a splash particle effect after they hitting the scene models.

雨效果由撞击场景的雨粒子和撞击场景模型后的飞溅粒子效果组成。

So how are we going to get the particles to hit a model without expensive ray-model intersection calculations? Well there is a type called ParticleModelShape3D, which emits particles in a shape of the specified model. It can emit them to a specific direction by setting the velocity in the emitter. If one then set the velocity towards the sky and runs the particle system time in reverse, it appears as if the particles are hitting the model.

​那么,在不进行昂贵的射线模型交点计算的情况下,我们如何让粒子撞击模型呢?有一种称为ParticleModelShape3D的类型,它以指定模型的形状发射粒子。通过设置发射器中的速度,它可以将它们发射到特定方向。如果然后将速度设置为朝向天空,并反向运行粒子系统时间,则粒子似乎正在撞击模型。

Snow accumulation using trail emitter with zero velocity.

使用零速度的尾部发射器进行积雪。

ParticleEmitter3D.reversed property

ParticleEmitter3D.reversed属性

Running the whole system in reverse makes it cumbersome to add other particle effects to the same system so we added a new property to the emitter: reversed. This allows only this one emitter to run in reverse, while the other particle emitters can run forward in time.

​反向运行整个系统会使向同一系统添加其他粒子效果变得很麻烦,因此我们向发射器添加了一个新属性:reversed。这只允许这一个发射器反向运行,而其他粒子发射器可以在时间上向前运行。

Here is how we implement the rain with line particles, model shape and trail emitter to implement the splash effect.

以下是我们如何使用线粒子、模型形状和轨迹发射器来实现雨,以实现飞溅效果。

// Rain particle LineParticle3D { id: rainParticle ... } Component { id: modelComponent Model { // The mesh containing only the top parts of the sphere source: "meshes/sphere_top.mesh" } } // Rain particle emitter ParticleEmitter3D { id: emitter particle: rainParticle reversed: true shape: ParticleModelShape3D { model: modelComponent fill: false } velocity: VectorDirection3D { direction: Qt.vector3d(0, 800, 0) directionVariation: Qt.vector3d(2, 0, 2) } } // Splash particle SpriteParticle3D { id: splashParticle ... } // Splash particle trail emitter following the rain particle TrailEmitter3D { follow: rainParticle DynamicBurst3D { id: splashBurst amount: 20 amountVariation: 2 triggerMode: DynamicBurst3D.TriggerEnd } emitBursts: splashBurst particle: splashParticle velocity: VectorDirection3D { direction: Qt.vector3d(0, 0, 10) directionVariation: Qt.vector3d(50, 50, 1) } }

So now we can have rain that can hit a model and create splashes to a specific direction, but wouldn't it be nice if the splash would follow the shape of the model i.e. when the rain particle hits a surface with a certain angle, it would then splash towards the reflected angle.

所以现在我们可以让雨水撞击模型,并在特定方向上产生飞溅,但如果飞溅物遵循模型的形状,那岂不是很好?也就是说,当雨水粒子以一定角度撞击表面时,它会朝反射角度飞溅。

ParticleEmitter3D.EmitMode

The emit mode of the emitter allows more fine grained control of the emitted particles. It adds two modes of controlling the direction based on the model shape(in addition to the default).

发射器的发射模式允许对发射的粒子进行更精细的控制。它添加了两种基于模型形状控制方向的模式(除了默认模式)。

ParticleEmitter3D.SurfaceNormalchanges the emit direction to follow the surface normal. When the emit velocity is towards the z-axis, the particles are emitted to the direction of the surface normal.

ParticleEmitter3D.SurfaceNormal更改发射方向以遵循曲面法线。当发射速度朝向z轴时,粒子被发射到表面法线的方向。

ParticleEmitter3D.SurfaceReflectedis used with trail emitters and the emit directions is towards the reflected vector calculated from surface normal and the velocity of the followed particle.

ParticleEmitter3D.SurfaceReflected与轨迹发射器一起使用,发射方向朝向根据表面法线和所跟踪粒子的速度计算的反射矢量。

Default and SurfaceNormal emit modes on suzanne mesh.

suzanne网格上的默认和SurfaceNormal发射模式。

Setting the emit mode of the trail emitter toParticleEmitter3D.SurfaceReflected, the splash particles are now reflected from the surface.

将尾部发射器的发射模式设置为ParticleEmitter3D.SurfaceReflected后,飞溅粒子现在从表面反射。

TrailEmitter3D { ... emitMode: ParticleEmitter3D.SurfaceReflected }

Particles bouncing off of a sphere using SurfaceReflected mode.

使用“SurfaceReflected”模式从球体反弹的粒子。

So now we have building blocks for the rain effect for one model, how do we add it for the scene with multiple models. If we add it separately for each model, this would have side effects: the models that have rain effect would have their own rain density so the scene wouldn't have uniform rain. The rain would also pass trough models that are above each other e.g. ground would have rain underneath a model on top of it. To workaround there issues one could precalculate a mesh for the whole scene, but this would be static mesh so models couldn't move in the scene.

所以现在我们有了一个模型的雨效果的构建块,我们如何为多个模型的场景添加它。如果我们为每个模型单独添加它,这将产生副作用:具有雨效应的模型将有自己的雨密度,这样场景就不会有均匀的雨。雨水也会穿过彼此上方的模型,例如,地面上的模型下方会有雨水。为了解决这些问题,可以为整个场景预先计算网格,但这将是静态网格,因此模型无法在场景中移动。

ParticleSceneShape3D

The scene shape dynamically calculates a shape for the whole scene based on the models in the scene.
The shape is calculated as a grid placed on top of the scene, where each vertex in the grid is on the top-most point on it's models polygons. Holes are created to the grid when the height between neighboring vertices is too great or if there are no model polygons below the grid vertex.
The shape is recalculated when models move in the scene so it can also be used with dynamic scenes. One can set the resolution of the grid, the extents of the grid to set the size of the shape, it's center and also specify nodes that should be excluded in the calculation of the shape. One can also get the geometry as a property to use e.g. for debugging purposes.

​场景形状基于场景中的模型动态计算整个场景的形状。
形状被计算为放置在场景顶部的网格,网格中的每个顶点都位于其模型多边形的最顶部。当相邻顶点之间的高度太大或网格顶点下方没有模型多边形时,会在网格上创建孔。
当模型在场景中移动时,形状会重新计算,因此它也可以用于动态场景。可以设置网格的分辨率、网格的范围以设置形状的大小、中心,还可以指定在计算形状时应排除的节点。还可以将几何体作为属性使用,例如用于调试目的。

ParticleEmitter3D { id: emitter shape: ParticleSceneShape3D { id: sceneShape scene: sceneRoot sceneCenter: Qt.vector3d(0, 0, 0) sceneExtents: Qt.vector3d(1000, 500, 1000) excludedNodes: [debugNode] shapeResolution: 50 } } Model { id: debugNode geometry: sceneShape.geometry }

Rain effect in car-configurator demo.

汽车配置器中的雨效果演示。

The rain effect has been added to the car-configurator demo in Qt 6.11 along with a snow effect.

​Qt 6.11中的汽车配置器演示中添加了雨效果和雪效果。

http://www.jsqmd.com/news/421931/

相关文章:

  • 基于flask和python框架的求职招聘网站-vue pycharm django
  • 2D渲染-介绍Qt Canvas Painter
  • 基于flask和python框架的热门车型汽车推荐网站-vue pycharm django
  • 2026年2月拱形拼装钢波纹管供货厂家,涵洞工程资质案例解析 - 品牌鉴赏师
  • 保姆级AI编程提示词教学!前端开发专属,粘贴即用高效提效
  • 2026银狐(SilverFox)病毒防护服务公司推荐排行 品质臻选榜 智能预警/全周期运维/跨国适配 - 极欧测评
  • Qt Quick认证测试已发布
  • RAG、Agent、MCP、Skill一句话讲清_AI_底层
  • KingbaseES 共享锁(SHARE)与排他锁(EXCLUSIVE)详解及测试复现
  • Redis 分布式锁:原理、实现与高并发场景下的坑
  • 新鲜出炉!2026银狐(SilverFox)病毒防护服务公司推荐排行 全周期防护/漏洞预警/多行业适配 - 极欧测评
  • 【Azure App Service】记录App Service Kudu站点的File Manger中无法查看文件列表的原因
  • 企业Agent落地避坑指南:从无效堆砌到精准实战(非常详细),收藏这一篇就够了!
  • 1654161
  • 题解:洛谷 B2149 求三角形面积
  • 2026年2月袖口式热收缩膜包装机厂家推荐,防尘防潮包装实力工厂 - 品牌鉴赏师
  • 2026年2月冷拉伸套膜机工厂推荐,无需加热节能型套膜设备 - 品牌鉴赏师
  • 2026银狐(SilverFox)病毒防护服务公司推荐排行 高口碑榜 智能监测/应急处置/全场景防护 - 极欧测评
  • 书店“书籍推荐数字海报”,自动更新每日新书。
  • 从零部署交易所核心源码:完整实操指南(附避坑手册)
  • 计算机毕业设计springboot固定线路往返公益平台 SpringBoot框架下的社区通勤拼车与共享出行服务平台 基于SpringBoot的定制化公交线路与公益合乘管理系统
  • IDEA启动SpringBoot项目时使用mvn exec:exec启动的解决办法
  • TypeScript - 类型断言 Type Assertion(通俗易懂的详细教程)
  • 政企优选!2026银狐(SilverFox)病毒防护服务公司推荐排行 重保级防护/漏洞溯源/全球化服务 - 极欧测评
  • 计算机毕业设计springboot古镇旅游路线规划网站 SpringBoot框架下的历史文化名镇智能导览与行程定制平台 基于SpringBoot的传统村落文化旅游数字化服务系统
  • 2026银狐(SilverFox)病毒防护服务公司推荐排行 实力优选榜 精准查杀/智能防御/全行业适配 - 极欧测评
  • Typescript - type 类型别名(通俗易懂教程)
  • 2026年2月切角热收缩包装机工厂推荐,实力品牌深度解析采购无忧之选 - 品牌鉴赏师
  • 【咕咕咕】CF2200
  • 2026银狐(SilverFox)病毒防护服务公司推荐排行 技术标杆榜 AI溯源/全链防护/多终端适配 - 极欧测评