元编程参考文档

粒子

16 个节点

本页内容 16

添加粒子迸发

函数

加入一次迸发后的场景:在某一时刻从一个球里向四面八方一次抛出的粒子,发光的或实心的。撞击溅出的碎屑,烟花的弹壳。

签名
添加粒子迸发 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    半径: 数字
    数量: 整数
    速度: 数字
    时间: 数字
    寿命: 数字
    发光: 真否
ParticleSceneDescription AddParticleBurst(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    double radius = 0.1,
    int count = 20000,
    double speed = 6,
    double time = 0,
    double lifetime = 3,
    bool glowing = true)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The emitter's name.
位置Vector3d—The ball's centre (m).
半径数字0.1Its radius (m).
数量整数20000How many particles.
速度数字6How fast they are thrown (m/s).
时间数字0When (s).
寿命数字3How long they last (s).
发光真否TrueGlowing sparks; off, solid grey debris.

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

添加粒子发射器

函数

加入一个放出粒子的球后的场景,粒子的样子由自己决定:由太阳照亮的实心小点,或者当“发光”大于 0 时是发光的。

签名
添加粒子发射器 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    半径: 数字
    速率: 数字
    速度: Vector3d
    散布: 数字
    寿命: 数字
    大小: 数字
    颜色: 颜色
    发光: 数字
ParticleSceneDescription AddParticleEmitter(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    double radius,
    double rate,
    Vector3d velocity,
    double spread,
    double lifetime,
    double size,
    ColorElement colour,
    double glow = 0)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The emitter's name.
位置Vector3d—Its centre (m).
半径数字—Its radius (m).
速率数字—Particles born per second.
速度Vector3d—The velocity they are born with (m/s).
散布数字—The speed of the random part of that velocity (m/s).
寿命数字—How long a particle lives (s).
大小数字—A particle's radius (m).
颜色颜色—A particle's colour.
发光数字0How brightly it glows; 0 is a solid speck.

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

添加粒子障碍长方体

函数

加入一个粒子会从上面弹开的实心长方体后的场景。

签名
添加粒子障碍长方体 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    大小: Vector3d
ParticleSceneDescription AddParticleObstacleBox(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    Vector3d size)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The solid's name.
位置Vector3d—Its centre (m).
大小Vector3d—Its size (m) along X, Y and Z.

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

添加粒子障碍球

函数

加入一个粒子会从上面弹开的实心球后的场景。

签名
添加粒子障碍球 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    半径: 数字
ParticleSceneDescription AddParticleObstacleSphere(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    double radius)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The solid's name.
位置Vector3d—Its centre (m).
半径数字—Its radius (m).

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

添加降雪

函数

加入从一层空气里落下的雪后的场景:白色的雪片随风和湍流飘动,然后落定。雪需要能托住它的空气:“新建粒子”里阻力取 6 左右,湍流 0.7 左右,弹性 0。

签名
添加降雪 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    大小: Vector3d
    速率: 数字
    寿命: 数字
ParticleSceneDescription AddSnowfall(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    Vector3d size,
    double rate = 8000,
    double lifetime = 9)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The emitter's name.
位置Vector3d—The middle of the slab the flakes are born in (m).
大小Vector3d—The slab's size (m) along X, Y and Z.
速率数字8000Flakes per second.
寿命数字9How long a flake lasts (s): long enough to reach the ground and lie there a while.

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

添加火花喷泉

函数

加入一个火花喷泉后的场景:从一点抛出的发光亮线,冷却时由黄变红,会落下并弹跳。

签名
添加火花喷泉 -> Particle Scene Description
    场景: Particle Scene Description
    名称: 文本
    位置: Vector3d
    方向: Vector3d
    速率: 数字
    散布: 数字
    寿命: 数字
ParticleSceneDescription AddSparkFountain(
    ParticleSceneDescription scene,
    string name,
    Vector3d position,
    Vector3d direction,
    double rate = 30000,
    double spread = 1.1,
    double lifetime = 2.6)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
名称文本—The emitter's name.
位置Vector3d—Where the sparks come from (m).
方向Vector3d—The velocity they are thrown with (m/s): (0, 0, 6) is straight up, to about two metres.
速率数字30000Sparks per second.
散布数字1.1The speed of the random part of their velocity (m/s): what opens the jet into a fountain.
寿命数字2.6How long a spark glows (s).

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

导出粒子序列图

函数

运行场景,把它的粒子的序列图写成带透明度的 PNG,并在旁边用文本文件写出它的布局。返回 PNG 的路径。

签名
导出粒子序列图 -> 文本
    场景: Particle Scene Description
    路径: 文本
    时长: 数字
    眼睛: Vector3d
    目标: Vector3d
    列数: 整数
    行数: 整数
    帧大小: 整数
    视场角: 数字
    显示发光: 真否
string ExportParticleFlipbook(
    ParticleSceneDescription scene,
    string path,
    double duration,
    Vector3d eye,
    Vector3d target,
    int columns = 8,
    int rows = 8,
    int frameSize = 256,
    double fieldOfView = 40,
    bool showGlow = true)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
路径文本—The PNG to write; its folder is created if missing.
时长数字—How long to run (s).
眼睛Vector3d—Where the camera stands (m).
目标Vector3d—What it looks at (m).
列数整数8Frames in a row.
行数整数8Rows of frames.
帧大小整数256A frame's width and height in pixels.
视场角数字40The camera's vertical field of view in degrees.
显示发光真否TrueGive glowing particles an alpha as bright as they are; off, they are colour without alpha, for a game that adds the sheet. The text file says which.

返回

结果文本
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

新建粒子

函数

供粒子飞行的空旷空气,下面是高度为 0 的地面。

签名
新建粒子 -> Particle Scene Description
    重力: 数字
    风: Vector3d
    阻力: 数字
    湍流: 数字
    弹性: 数字
    地面: 真否
    黄昏: 真否
ParticleSceneDescription NewParticles(
    double gravity = 9.81,
    Vector3d wind,
    double drag = 0.5,
    double turbulence = 0,
    double bounce = 0.4,
    bool ground = true,
    bool dusk = false)

参数

名称类型默认值说明
重力数字9.81Gravity (m/s²), pointing down along -Z.
风Vector3d—The wind (m/s).
阻力数字0.5How fast a particle takes the air's velocity (per second): 0 flies free of the air, 0.5 is a spark, 6 drifts like snow.
湍流数字0The speed of the air's own swirls (m/s); 0 is still air.
弹性数字0.4The share of its speed a particle keeps when it bounces: 0 lands and stays.
地面真否TrueWhether there is a ground at height 0 to land on.
黄昏真否FalseTake pictures under a dark sky, against which glowing particles show.

返回

结果Particle Scene Description
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子数

函数

某一记录帧里有多少个活着的粒子。

签名
粒子数(结果: Particle Result, 帧: 整数) -> 整数
int ParticleCount(ParticleResult result, int frame)

参数

名称类型默认值说明
结果Particle Result—The run.
帧整数—The recorded frame, from 0.

返回

结果整数
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子序列图

函数

运行场景,在运行期间均匀地取出只有粒子的帧,拼成一张带透明度的图片:游戏用来播放火花的序列图。帧从左到右、行从上到下排列。实心的粒子是不透明的。发光的粒子只添光、什么也不遮,所以严格说来它是完全没有透明度的颜色,这样做出的一张火花图,在凡是按透明度混合图片的地方都显示为一片空白:“显示发光”给这些光一个与它同样亮的透明度。

签名
粒子序列图 -> Pixel Image
    场景: Particle Scene Description
    时长: 数字
    眼睛: Vector3d
    目标: Vector3d
    列数: 整数
    行数: 整数
    帧大小: 整数
    视场角: 数字
    显示发光: 真否
PixelImage ParticleFlipbook(
    ParticleSceneDescription scene,
    double duration,
    Vector3d eye,
    Vector3d target,
    int columns = 4,
    int rows = 4,
    int frameSize = 128,
    double fieldOfView = 40,
    bool showGlow = true)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
时长数字—How long to run (s).
眼睛Vector3d—Where the camera stands (m).
目标Vector3d—What it looks at (m).
列数整数4Frames in a row.
行数整数4Rows of frames.
帧大小整数128A frame's width and height in pixels.
视场角数字40The camera's vertical field of view in degrees.
显示发光真否TrueGive glowing particles an alpha as bright as they are, so that they show in a viewer and in tools that blend by alpha. Off, they are colour without alpha: exact, for a game that adds the sheet to its picture.

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子帧数

函数

一次运行记录了多少帧。

签名
粒子帧数(result: Particle Result) -> 整数
int ParticleFrameCount(ParticleResult result)

参数

名称类型默认值说明
resultParticle Result—

返回

结果整数
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子帧时间

函数

某一记录帧的模拟时间(秒)。

签名
粒子帧时间(result: Particle Result, frame: 整数) -> 数字
double ParticleFrameTime(ParticleResult result, int frame)

参数

名称类型默认值说明
resultParticle Result—
frame整数—

返回

结果数字
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子图片

函数

把场景运行一段时间,然后给它拍一张照:地面、固体和粒子。

签名
粒子图片 -> Pixel Image
    场景: Particle Scene Description
    时间: 数字
    眼睛: Vector3d
    目标: Vector3d
    宽度: 整数
    高度: 整数
    视场角: 数字
PixelImage ParticlePicture(
    ParticleSceneDescription scene,
    double time,
    Vector3d eye,
    Vector3d target,
    int width = 640,
    int height = 480,
    double fieldOfView = 40)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
时间数字—How long to run before the picture (s).
眼睛Vector3d—Where the camera stands (m).
目标Vector3d—What it looks at (m).
宽度整数640The picture's width in pixels.
高度整数480The picture's height in pixels.
视场角数字40The camera's vertical field of view in degrees.

返回

结果Pixel Image
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子点

函数

某一记录帧里粒子的位置(米):每个活着的粒子一个点,三维视图会把它们画出来。

签名
粒子点(结果: Particle Result, 帧: 整数) -> Vector3d 数组
Vector3d[] ParticlePoints(ParticleResult result, int frame)

参数

名称类型默认值说明
结果Particle Result—The run.
帧整数—The recorded frame, from 0.

返回

结果Vector3d 数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

粒子速度

函数

某一记录帧里粒子的运动(米/秒):每个活着的粒子一个速度,顺序与“粒子点”相同。

签名
粒子速度(结果: Particle Result, 帧: 整数) -> Vector3d 数组
Vector3d[] ParticleVelocities(ParticleResult result, int frame)

参数

名称类型默认值说明
结果Particle Result—The run.
帧整数—The recorded frame, from 0.

返回

结果Vector3d 数组
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟

模拟粒子

函数

把场景运行一段时间,并记录每一帧的粒子,供点节点读取。十万个粒子的一帧是 2.4 MB,所以热闹的场景要少记几帧(每隔几帧保留)。

签名
模拟粒子 -> Particle Result
    场景: Particle Scene Description
    时长: 数字
    每秒帧数: 数字
    每隔几帧保留: 整数
ParticleResult SimulateParticles(
    ParticleSceneDescription scene,
    double duration = 2,
    double framesPerSecond = 30,
    int keepEvery = 1)

参数

名称类型默认值说明
场景Particle Scene Description—The scene.
时长数字2How long to run (s).
每秒帧数数字30Frames per second of simulated time.
每隔几帧保留整数1Record every frame (1), every second one (2) and so on; the last frame is always recorded.

返回

结果Particle Result
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
粒子
所属包
物理模拟