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.
【我们在发射器阶段初始化链条属性,并把属性传递到粒子脚本。同时也初始化了属性读取器,使得粒子能相互通信】
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
【在这里我们设置链条,包括连接距离和影响链条质量的重量。同时使单节链条交替旋转,从而使链条更好看】
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
【第一个约束是牵制每个粒子到最大距离,这种方式对实现像链条这样的硬性约束很好用】
Here we colorize the chain by its Kinetic Energy. Just for fun.
【在这里我们根据动能来设置颜色。只是为了好玩。】
Here, we solve the iterative constraint between each chain link. Increasing iterations increases both cost and quality
【在这里,我们结算每节链条间的迭代约束。增加迭代数量会增加消耗和提升质量】
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"
【最后,我们最后一步是根据上一帧的位置和当前帧施加约束后的新位置来重新获得一个新的速度。没有这一步,摇摆的链条就会没有“动力”】
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.
【因为求解正确结果涉及增加计算次数,所以汇集正确结果可能需要较高的迭代次数。为了帮助链条汇聚,和创建一个每节链条之间紧密连接的感觉,所以我们每帧都预先计算一次单节链条的最大距离限制(可以想象成围绕链条原点的同心圆),然后在模拟阶段来执行迭代计算,来进行每节链条之间的同级移动。】
Engine.ExecutionCount【执行计数】变量:执行次数总数,从1开始
Negate【否认】节点:取负数
Particle Attribute Reader→Get ID at Spawn Index【使用生成索引获得ID】节点:只能在生成阶段使用
Calculate Link Constraint【计算连接限制】节点
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【湍流流动循环时间】
Noise Quality/Cost【噪音质量/消耗】
Surface Alignment Mode【表面对齐模式】
Alignment Falloff Start/End【对齐衰减开始/结束】
Friction Mode【摩擦模式】