元編程參考文件

粒子

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
所屬發行版
元編程(教育版)元編程(專業版)
可用的圖種類
資料流 函數 事件 例程 藍圖 狀態機狀態
宣告於
粒子
所屬包
物理模擬