Gamebryo—ParticalSystem

来源:互联网 发布:淘宝助理同步宝贝没用 编辑:程序博客网 时间:2024/05/04 20:08

一、程序中的粒子系统

1.NiPartical介绍

可以通过3DS Max来创建粒子系统NIF文件,程序在使用这些NIF文件来创建,并随着场景的更新产生动画效果。粒子系统还可以绑定在特点的动画序列上,从而粒子可以随着动画角色同步。粒子可以是由screen-faceing texture quads组成或隶属于特定的场景图。在粒子产生后可以受特定的力、碰撞影响。可以通过Programmatic来创建和控制粒子系统。NiParticle.lib提供了GB中的粒子系统功能。

Floodgate使得粒子系统的产生和模拟支持多线程处理。

2.粒子系统概览

粒子系统的渲染支持“standard material pipeline”和“custom shaders”两种方式。不同的算法可以使得粒子数据产生粒子的方式有很多种。

NiPSParticalSystem代表了一个粒子系统,它维护了一个粒子数据数组。它继承与NiMesh同时绑定了两个mesh modifiers。第一个就是NiPSSimulator:负责模拟粒子系统、更新粒子数组、向粒子施加力、粒子之间的碰撞,主要是操作Data Array。第二个modifiers是粒子产生器(generator)即根据粒子的数据创建可以渲染的粒子几何体。默认的generator是NiPSFacingQuadGenerator,它创建的粒子具有可旋转、拥有纹理、并且camera-facing quad。

粒子系统同时还具有时间控制功能。具有时间控制能力的“力”和“喷射器”都是继承NiPSForceCtr和NiPSEmitterCtr。如粒子的产生动画由于NiPSEmitterParticalesCtr。

粒子系统的组成:

· Main Object

· Simulator

o Simulator Steps

o Forces

o Colliders

· Emitters and Spawners

· Generators

· Controllers

· Bounding Volumes

· Programmatic Creation

3.粒子系统的主要对象(NiPSParticalSystem)

NiPSParticleSystem在场景中代表了一个粒子系统。由于是继承于NiMesh所以它代表了一个可渲染几何体。

以下是主要内容:

· Creating a Particle System

· Particle Data

· Simulator and Generator

· Resetting the System

· World-Space Particles vs. Model-Space Particles

· Emitters and Spawners

· Mesh Particles

· Running Up a Particle System

创建粒子系统—NiPSParticalSystem::Create:创建一个模拟器()

粒子数据 :Partical有位置、颜色、速度、半径等属性。一个粒子系统包含一个粒子数量的最大值,该数量在以后不会改变。在多线程处理时使用ForceSimulatorToComplet函数来防止粒子状态被修改。

重置系统

世界空间VS模型空间

默认情况下粒子系统中的粒子是放置在世界坐标系中,这样对粒子系统的任何变换不会影响到其中的粒子。同样粒子也可以被放置到模型坐标系中(粒子系统)。这样对粒子系统的变换都会影响到其中的每个粒子。用户可以根据需要来选择相应的坐标系。

注意:当设成世界坐标系时,世界缩放任然会影响到粒子的位置。世界坐标系不意味着粒子不需要乘粒子系统的世界变换矩阵,而是意味着不让粒子系统的缩放影响到其中的粒子的大小、和位置。当粒子系统进行缩放时,会有一个相反的缩放去影响每个粒子。

再注意:当使用世界坐标系时,静态包接体会随着粒子系统移动而移动,反之使用

EmitterSpawners:Emitter是确定了向系统添加粒子的参数。Spawner是确定如何从已经死亡的粒子演变成新的粒子。与其同时NiPSParticleSystem可以拥有一个death spawner的引用,它决定当一个粒子死亡是否会孵化出一个新粒子。如果没有这个death spawner则不会孵化一个新粒子。同一个death spawner可以被不同paticles system拥有,这样会产生一个和当前系统完全不一样的新粒子。

Mesh Particles

当一个粒子系统是复杂Mesh或场景图中的一个实例时使用NiPSMeshParticalSystem代替NiPSParticalSystem。

Running Up a Particle System:

4.粒子系统的Simulator—NiPSSimulator

功能:Simulation of particles includes updating particle positions based on velocity, applying forces to particles, simulating collisions between particles and a collider object, and killing off particles whose ages have exceeded their life。

NiPSSimulator使用Floodgate来执行simulation工作。

5.粒子系统的Simulator step

Rather than performing all of the simulation work itself, however, NiPSSimulator holds a set ofsimulator steps, each of which performs some aspect of the simulation. Each step provides a Floodgate kernel and its required input and output streams.

clip_image002

4.粒子系统中的力

作用力:NiPSForce

力的类型:

clip_image004

5.粒子系统中的碰撞

碰撞:NiPSCollider

碰撞的类型:

clip_image006

6.粒子系统中的Emitters和Spawners

Emitters和Spawner控制了粒子系统中添加粒子的方式。

Emitters(NiPSEmitter):初始化粒子的相关参数如半径、速度、生命期等

粒子初始位置:

clip_image008

Spawner(NiPSSpawner):描写已存在的粒子的状态时如何改变的。

7.粒子系统中的Generators

The generator in a particle system is responsible for taking the particle data and generating renderable geometry from it, storing that geometry in data streams on theNiPSParticleSystem object. Generators should not be attached to NiPSMeshParticleSystem objects, since they represent their particles in a different way。

有两种Generator:NiPSFaceingQuadGenerator、NiPSAlignedQuadGenerator。

8.粒子系统中的Controller

System Controller、Emitter Controller、Force Controller

9.粒子系统中的Bounding Volumes

Static Bounding volumes、Dynamic Bounding Volumes

二、美术中的粒子系统

1.GB支持如下类型的粒子系统

· Spray

· Super-Spray

· Snow

· Blizzard

· PArray

· PCloud

原创粉丝点击