UE5.1_Niagara高級2.4_ Iterative Constraints
2.4 Iterative Constraints【迭代約束】
We initialize the chain attributes up at the emitter and pass the attributes down to the particle scripts. This is also where we initialize the attribute reader which allows the particles to communicate with each other.
【我們在發(fā)射器階段初始化鏈條屬性,并把屬性傳遞到粒子腳本。同時也初始化了屬性讀取器,使得粒子能相互通信】
Here we set up the chain, including the distance between links and a weight which affects the mass of the chain. We also do a little alternating of chain link rotations to create the criss cross distribution of links
【在這里我們設置鏈條,包括連接距離和影響鏈條質量的重量。同時使單節(jié)鏈條交替旋轉,從而使鏈條更好看】
We add forces and then zero them out on the chain start point as it is hard constrained to the Chain Origin. We wobble the chain origin with some sine waves to introduce motion.
【我們添加力并使鏈條原點受力歸零,使鏈條原點就像是被固定連接一樣。我們使用正弦波搖擺鏈條原點使其移動】
This first constraint pins each particle to a max distance which works well for fully rigid constraints such as a chain
【第一個約束是牽制每個粒子到最大距離,這種方式對實現(xiàn)像鏈條這樣的硬性約束很好用】
Here we colorize the chain by its Kinetic Energy. Just for fun.
【在這里我們根據(jù)動能來設置顏色。只是為了好玩。】
Here, we solve the iterative constraint between each chain link. Increasing iterations increases both cost and quality
【在這里,我們結算每節(jié)鏈條間的迭代約束。增加迭代數(shù)量會增加消耗和提升質量】
At the end, our final step is to re-derive a new velocity from the particle's previous position and our new constrained position. Without this, the swinging chain would have no "momentum"
【最后,我們最后一步是根據(jù)上一幀的位置和當前幀施加約束后的新位置來重新獲得一個新的速度。沒有這一步,搖擺的鏈條就會沒有“動力”】
Because the solve involves incremental steps towards the correct solution, convergence to the correct result can take a high number of iterations. To help the chain converge and create a tight feeling constraint, we pre-solve the chain segments with this maximum constraint distance (imagine concentric circles around the chain origin) once per frame, then move to the simulation stage to perform iterations to solve the lateral movement between the link segments.
【因為求解正確結果涉及增加計算次數(shù),所以匯集正確結果可能需要較高的迭代次數(shù)。為了幫助鏈條匯聚,和創(chuàng)建一個每節(jié)鏈條之間緊密連接的感覺,所以我們每幀都預先計算一次單節(jié)鏈條的最大距離限制(可以想象成圍繞鏈條原點的同心圓),然后在模擬階段來執(zhí)行迭代計算,來進行每節(jié)鏈條之間的同級移動?!?/p>
Engine.ExecutionCount【執(zhí)行計數(shù)】變量:執(zhí)行次數(shù)總數(shù),從1開始
Negate【否認】節(jié)點:取負數(shù)
Particle Attribute Reader→Get ID at Spawn Index【使用生成索引獲得ID】節(jié)點:只能在生成階段使用
Calculate Link Constraint【計算連接限制】節(jié)點
Rigid Constraint【硬性限制】:限制兩點間距離必須等于ConstraintDistance
BackwardConstraint【向后限制】:使CurrentPosition到PreviousPosition的距離不超過ConstraintDistance,超過時且ConvergenceSpeed=1時,BackConstraint為CurrentPosition指向限制距離點的向量
Update Position【更新位置】
Wind Force【風力】模組
Wind Speed【風速】
Wind Speed Scale【風速縮放】
Turbulence Mode【湍流模式】
Turbulence Scale Mode【湍流縮放模式】
Turbulence Frequency Mode【湍流頻率模式】
Turbulence Offset Mode【湍流偏移模式】
Turbulence Flow Loop Duration【湍流流動循環(huán)時間】
Noise Quality/Cost【噪音質量/消耗】
Surface Alignment Mode【表面對齊模式】
Alignment Falloff Start/End【對齊衰減開始/結束】
Friction Mode【摩擦模式】