目标
参考《粒子系统的关键概念 | Unreal Engine Documentation》 以及UE4源代码,尽可能对Cascade粒子系统中的以下概念有更深的了解:
粒子系统(ParticleSystem) 粒子发射器(ParticleEmitter) 粒子系统模块(ParticleModule) 发射器Actor
1. 粒子系统(ParticleSystem)
“粒子系统” 是一种资源,可以直接在内容浏览器中被创建: 双击这个资源可以进入Cascade粒子编辑器。
源代码中的定义和注释如下:
class UParticleSystem : public UFXSystemAsset
一个 “粒子系统” 完整表达了一个粒子特效,包含了任意数目的 “粒子发射器” ,设计师可以用它组合出复杂而精妙的效果并“装进”一个独立的系统中,随后可以放到关卡中或是由脚本创建。
UParticleSystem
这个类的继承关系如下:
UObject
UFXSystemAsset
UParticleSystem
UNiagaraSystem
2. 粒子发射器(ParticleEmitter)
一个 “粒子发射器” 发射了一种特定类型的粒子,在一个 “粒子系统” 中可以添加任意数目的 “粒子发射器” 。
UParticleEmitter
直接继承自UObject
:
class UParticleEmitter : public UObject
UParticleSystem
有发射器列表:
UPROPERTY ( instanced)
TArray< UParticleEmitter* > Emitters;
3. 粒子模块(ParticleModule)
一个 “粒子模块” 定义了粒子的一种行为,被放到了 “粒子发射器” 中。
直接继承自UObject
:
class ENGINE_API UParticleModule : public UObject
它有多个具体的种类:
UParticleModule
UParticleModuleVelocityBase
UParticleModuleVectorFieldBase
UParticleModuleTypeDataBase
UParticleModuleTrailBase
UParticleModuleSubUVBase
UParticleModuleSpawnBase
UParticleModuleSizeBase
UParticleModuleRotationRateBase
UParticleModuleRotationBase
UParticleModuleRequired
UObject
UParticleModuleParameterBase
UParticleModuleOrientationBase
UParticleModuleOrbitBase
UParticleModuleMaterialBase
UParticleModuleLocationBase
UParticleModuleLightBase
UParticleModuleLifetimeBase
UParticleModuleKillBase
UParticleModuleEventBase
UParticleModuleColorBase
UParticleModuleCollisionBase
UParticleModuleCameraBase
UParticleModuleBeamBase
UParticleModuleAttractorBase
UParticleModuleAccelerationBase
UParticleModuleAccelerationOverLifetime
UParticleModuleAccelerationDragScaleOverLife
UParticleModuleAccelerationDrag
UParticleModuleAccelerationConstant
UParticleModuleAcceleration
UParticleModuleAttractorPointGravity
UParticleModuleAttractorPoint
UParticleModuleAttractorParticle
UParticleModuleAttractorLine
UParticleModuleBeamTarget
UParticleModuleBeamSource
UParticleModuleBeamNoise
UParticleModuleBeamModifier
UParticleModuleCameraOffset
UParticleModuleCollisionGPU
UParticleModuleCollision
UParticleModuleColorScaleOverLife
UParticleModuleColorOverLife
UParticleModuleColor
UParticleModuleColor_Seeded
UParticleModuleEventReceiverBase
UParticleModuleEventGenerator
UParticleModuleEventReceiverSpawn
UParticleModuleEventReceiverKillParticles
UParticleModuleKillHeight
UParticleModuleKillBox
UParticleModuleLifetime
UParticleModuleLifetime_Seeded
UParticleModuleLight
UParticleModuleLight_Seeded
UParticleModulePivotOffset
UParticleModuleSourceMovement
UParticleModuleLocationSkelVertSurface
UParticleModuleLocationPrimitiveTriangle
UParticleModuleLocationPrimitiveBase
UParticleModuleLocationEmitterDirect
UParticleModuleLocationEmitter
UParticleModuleLocationDirect
UParticleModuleLocationBoneSocket
UParticleModuleLocation
UParticleModuleLocation_Seeded
UParticleModuleLocationWorldOffset
UParticleModuleLocationWorldOffset_Seeded
UParticleModuleLocationPrimitiveSphere
UParticleModuleLocationPrimitiveCylinder
UParticleModuleLocationPrimitiveCylinder_Seeded
UParticleModuleLocationPrimitiveSphere_Seeded
UParticleModuleMeshMaterial
UParticleModuleOrbit
UParticleModuleOrientationAxisLock
UParticleModuleParameterDynamic
UParticleModuleParameterDynamic_Seeded
UParticleModuleRotationOverLifetime
UParticleModuleRotation
UParticleModuleMeshRotation
UParticleModuleMeshRotation_Seeded
UParticleModuleRotation_Seeded
UParticleModuleRotationRateMultiplyLife
UParticleModuleRotationRate
UParticleModuleMeshRotationRateOverLife
UParticleModuleMeshRotationRateMultiplyLife
UParticleModuleMeshRotationRate
UParticleModuleMeshRotationRate_Seeded
UParticleModuleRotationRate_Seeded
UParticleModuleSizeScaleBySpeed
UParticleModuleSizeScale
UParticleModuleSizeMultiplyLife
UParticleModuleSize
UParticleModuleSize_Seeded
UParticleModuleSpawnPerUnit
UParticleModuleSpawn
UParticleModuleSubUV
UParticleModuleSubUVMovie
UParticleModuleTrailSource
UParticleModuleTypeDataRibbon
UParticleModuleTypeDataMesh
UParticleModuleTypeDataGpu
UParticleModuleTypeDataBeam2
UParticleModuleTypeDataAnimTrail
UParticleModuleVectorFieldScaleOverLife
UParticleModuleVectorFieldScale
UParticleModuleVectorFieldRotationRate
UParticleModuleVectorFieldRotation
UParticleModuleVectorFieldLocal
UParticleModuleVectorFieldGlobal
UParticleModuleVelocityOverLifetime
UParticleModuleVelocityInheritParent
UParticleModuleVelocityCone
UParticleModuleVelocity
UParticleModuleVelocity_Seeded
《粒子系统参考 | Unreal Engine Documentation》 中有详细的介绍。
4. 发射器Actor
将 “粒子系统” 从内容浏览器拖到关卡里,便可以创建一个 “发射器Actor” : AEmitter
直接继承自AActor
class ENGINE_API AEmitter : public AActor
它拥有一个UParticleSystemComponent
成员
class UParticleSystemComponent * ParticleSystemComponent;
而UParticleSystemComponent
联系了一个 “粒子系统” 作为“模板”:
class UParticleSystem * Template;
总结
总结他们的关系如下
使用1个作为模板
实例到关卡中
拥有多个_
被多个不同种类的_所定义
发射器Actor
粒子系统
粒子发射器
粒子模块