Water Body
Water body enables physical simulation of liquids of different density and viscous behavior. It also models the appropriate buoyant force on submerged objects and wave dynamics as two-way interaction is calculated. Water simulation is visually pleasant and fast enough, so it can be used within a game environment; however, if the mesh is big and dense, it can become quite costly.Water body 可以对不同的液体进行物理模拟密度和粘性行为.它还对水下物体上的适当浮力和波浪动力学建模为双向互动被计算。水模拟在视觉上令人愉悦且速度足够快,因此可以在游戏环境中使用;然而,如果网格又大又密,它会变得非常昂贵。
Water body can be assigned to the following types of objects:Water body 可以分配给以下类型的对象:
- Water Mesh objectWater Mesh 对象
- Dynamic Mesh objectDynamic Mesh 对象
See also也可以看看#
- The article on Water Mesh关于 Water Mesh 的文章
- BodyWater classBodyWater 类
- Fragment of the video tutorial on physics demonstrating the use of the Water body for simulation of various types of liquids演示物理学的视频教程的片段使用 Water body 模拟各种类型的液体
Mesh Requirements网格要求#
A mesh, to which a Water body is assigned, should meet the requirements given here. Mesh requirements are the same for both Dynamic Mesh and Water Mesh objects.分配了 Water body 的网格应满足给定的要求这里.两者的网格要求相同动态网格和水网对象。
Grid Simulation Model网格仿真模型#
The Water body is modeled as a two-dimensional grid with point particles positioned in the vertices of the mesh. The particle movement is restricted to two directions: it can be lifted upwards or dragged downwards. In the case of changing its position, the particle acquires a velocity that affects the neighboring particles and thus describes the grid of Water body at each physics time step. Thus, the waves are generated when physical bodies get in contact with water or a particle is directly assigned new velocity.Water body 被建模为二维网格,点粒子位于网格的顶点。粒子运动被限制在两个方向:它可以向上提升或向下拖动。在改变其位置的情况下,粒子获得影响相邻粒子的速度,从而描述每个物理场的 Water body 网格时间步长.因此,当物理物体与水接触或直接为粒子分配新速度时,就会产生波。
Liquidity流动性#
Liquidity defines the viscosity of water (or any other liquid): it determines how readily it splashes and affects wave formation. It multiplies the speed with which water particles pass velocity vectors to the neighboring ones.流动性定义了水(或任何其他液体)的粘度:它决定了它飞溅和影响波浪形成的难易程度。它乘以水粒子将速度向量传递给相邻粒子的速度。
- The higher the value, the more viscous the water is and the smaller are the waves risen by the objects (e.g. syrup).值越高,水越粘稠,物体(例如糖浆)引起的波浪越小。
-
Low values provide higher surface waves (e.g. tap water).低值提供更高的表面波(例如自来水)。
Be careful not to set too high or too low values, because that may lead to unstable simulation and blowing up of the water. To regain stability, try to tweak Interaction.注意不要设置太高或太低的值,因为这可能会导致模拟不稳定和水爆炸。要恢复稳定性,请尝试调整 Interaction。
Density密度#
Density of water determines the buoyancy of objects according to Archimedes' principle. Based on the volume of the submerged part of the shape and its mass, buoyancy force is applied to its center of mass and pushes the object upwards, whereto the mean normal of the grid covered by submerged shape points.根据阿基米德原理,水的密度决定了物体的浮力。根据淹没部分的体积形状和它的质量,浮力被施加到它的质心并向上推动对象,其中被淹没的形状点覆盖的网格的平均法线。
- By the minimum value of 0, the objects will not float in the water, but rather fall through it without any resistance.通过 0 的最小值,物体不会漂浮在水中,而是在没有任何阻力的情况下通过它。
- Higher values increase the buoyant force. If set too high, the immersed objects start to be pushed out in the air.较高的值会增加浮力。如果设置得太高,浸入的物体开始被推出到空中。
Physical Behavior of Objects in Water物体在水中的物理行为#
Two-way dynamic interaction provides both physically and visually convincing simulation of the waves from the physical bodies as they disturb the fluid. Imagine a moving boat that forms a wake wave behind it, or a character creating ripples while moving in the water (see the picture above).双向动态交互提供了物理和视觉上令人信服的模拟,当它们干扰流体时来自物理体的波。想象一艘移动的船在它后面形成尾波,或者一个角色在水中移动时产生涟漪(见图以上)。
Interaction with Objects与对象的交互#
A physical object submerged into the water (or any other liquid) has its own velocity vector. On the other hand, all the water particles that are covered by this physical body or surround it, have their own integrated velocity vector, which approximates the state of water. The Interaction value is a coefficient that determines how much the object's velocity influences the velocities of water particles and thus generate waves.浸入水(或任何其他液体)中的物理对象具有自己的速度矢量。另一方面,所有被这个物体覆盖或包围的水粒子,都有自己的积分速度矢量,近似于水的状态。 Interaction 值是一个系数,它确定对象的速度对水粒子速度的影响程度,从而产生波浪。
- By the minimum value of 0, an object produces no disturbances on the water surface.通过 0 的最小值,物体不会对水面产生干扰。
-
Higher values make the disturbances of water surface more intense and the waves from moving objects become higher.值越大水面的扰动越强,在移动的物体浪变得更高。
Linear Damping and Angular Damping线性阻尼和角阻尼#
Objects getting into the water are expected to slow down, as resistance of the water is higher than the drag in the air. Damping values work the other way around compared to the Interaction coefficient:进入水中的物体预计会减慢速度,因为水的阻力大于空气中的阻力。阻尼值与 Interaction 系数相反:
Linear Damping defines how much linear velocity of the submerged object is decreased over time when influenced by velocities of surrounding water particles. And similarly, Angular Damping defines the gradual decrease in the object's rotation. Both linear and angular damping forces are accumulated before being applied.Linear Damping 定义了在受周围水粒子速度影响时,水下物体的线速度随时间降低了多少。同样,Angular Damping 定义了对象旋转的逐渐减少。线性和角阻尼力在施加之前都会累积。
- By the minimum value of 0, objects movement is not hindered by the water. As a result, there are no waves in the water.通过 0 的最小值,物体的运动不受水的阻碍。结果,水中没有波浪。
-
Higher values make the damping of linear or angular velocities more intense, and objects slow down faster as they get into the water. The waves from the objects in this case become more pronounced, as the energy of the system increases.较高的值会使线速度或角速度的阻尼更加强烈,并且物体在进入水中时会减慢速度。在这种情况下,随着系统能量的增加,来自物体的波变得更加明显。
The water may blow up in case the values are be very high. Try decreasing the Interaction value to regain stability.如果值非常高,水可能会爆炸。尝试降低 Interaction 值以重新获得稳定性。
Emission of Particles粒子发射#
It is possible to create an additional visual effect of small droplets, splashes or bubbles on the water when objects fall into it. To enable this effect perform the following steps:当物体落入水中时,可以在水面上产生小水滴、飞溅或气泡的额外视觉效果。要启用此效果,请执行以下步骤:
- Create a Particle system effect by clicking Create -> Effect -> Particle system in the main menu of UnigineEditor.通过单击主菜单中的 Create -> Effect -> Particle system 创建 Particle system 效果统一编辑器.
- Go to the Parameters window.转到 Parameters 窗口。
- In the Dynamic section, choose the Spark Emitter to spawn particles by selecting Emitter -> Spark.在 Dynamic 部分,选择火花发射器通过选择 Emitter -> Spark 来生成粒子。
- Make Particle system a child of the Water Mesh object.使 Particle system 成为孩子Water Mesh 对象。
Particles will be generated only when the object first contacts the water surface, while already submerged bodies will float without generating them.只有当物体第一次接触水面时才会生成粒子,而已经淹没的物体将漂浮而不生成它们。
Water Boundaries水边界#
The following parameters relating to water boundaries make it possible to create different types of basins in the game environment. These parameters provide flexibility in setting up physical behavior of water for big natural lakes and small pools.以下与水边界相关的参数可以在游戏环境中创建不同类型的盆地。这些参数为设置大型天然湖泊和小型水池的水的物理行为提供了灵活性。
Depth深度#
Depth determines the size of waves: high waves are formed in deep waters (e.g. a sea), while only a slight ripple is generated in shallow waters (e.g. a pool):Depth 决定了波浪的大小:在深水(如大海)中会形成大浪,而在浅水(如水池)中只会产生轻微的波纹:
- With the minimum value of 0, the objects raise no waves in the water.最小值为 0 时,对象不会在水中产生波浪。
- Higher values result in higher waves generated by moving objects.较高的值会导致移动对象产生较高的波。
Intersection with the Ground与地面的交叉点#
Intersection of water with the underlying terrain can be necessary, for example, to estimate the actual depth of the water basin. To enable ground intersection perform the following steps:Intersection 的水与底层地形可能是必要的,例如,估计实际深度的水盆。 要启用地面交叉,请执行以下步骤:
- Make Water Mesh or Dynamic Mesh object a child node of the Terrain or Static Mesh使 Water Mesh 或 Dynamic Mesh 对象成为 Terrain 或 Static Mesh 的子节点
- Check the Intersection box in the Parameters window -> Physics tab -> Body section.选中 Parameters 窗口 → Physics 选项卡 → Body 部分中的 Intersection 框。
Intersection is implemented in the following way: the rays are traced downwards from the water mesh surface, as far as the Depth distance. If a ray intersects the parent node, the obtained depth is used in calculations; otherwise the preset depth value is used.相交以下列方式实现:光线从水网格表面向下追踪,直到 Depth 距离。如果一条射线与父节点相交,则将获得的深度用于计算;否则预设深度值用来。
Intersection is also traced upward to check if the water is under terrain and there is no need to render it.交叉点也向上追踪以检查水是否在地形下并且不需要渲染它。
Absorption吸收#
Absorption is an option that creates either an effect of a limited basin or, on the contrary, of an open water surface that does not have marked boundaries.Absorption 是一个选项,可以创建有限盆地的效果,或者相反,创建没有明显边界的开放水面。
- If Absorption is enabled, the waves are dispersed along the mesh perimeter. In this case the water level at mesh edges will gradually fall down to zero level.如果启用Absorption ,则波浪沿网格周长分散。在这种情况下,网格边缘的水位将逐渐下降到零水位。
- If disabled, the backwash from the wall is simulated: the wave when reaching the brink of the water is reflected and returns in the reversed direction.如果禁用,则模拟来自墙壁的反冲:到达水边时的波浪被反射并以相反的方向返回。
Optimizing Simulation优化仿真#
Updating each frame a huge number of objects located far away from the camera that are hardly distinguishable or observed as a mass is a waste of resources.更新每一帧远离相机的大量物体,这些物体几乎无法区分或观察为质量是一种资源浪费。
To improve performance and avoid the excessive load, water simulation can be updated with a reduced framerate. When the Water body is out of the area specified by the Update Distance Limit parameter, physical calculations are not performed, though objects preserve their buoyancy.为了提高性能并避免过度负载,可以进行水模拟更新了降低的帧率.当 Water body 超出 Update Distance Limit 参数指定的区域时,不执行物理计算,但对象保留其浮力。
The set of frame rates given below enables you to specify how often the water simulation should be updated when the object is visible, when only its shadow is visible, or when it is not visible at all.下面给出的一组帧速率使您能够指定在对象可见、仅其阴影可见或根本不可见时应更新水模拟的频率。
This feature is enabled with default settings ensuring optimum performance and can be adjusted per-object in the UnigineEditor or via API at run time.此功能使用默认设置启用,可确保最佳性能,并且可以在 UnigineEditor 中或通过 API 在运行时针对每个对象进行调整。
Assigning a Water Body指定水体#
To assign a Water body to an object via UnigineEditor perform the following steps:通过将 Water body 分配给对象统一编辑器执行以下步骤:
- Open the World Hierarchy window.打开 World Hierarchy 窗口。
-
Select a Water Mesh or a Dynamic Mesh object to assign the Water body to.选择 Water Mesh 或 Dynamic Mesh 对象以将 Water body 分配给。
Make sure that the object's mesh meets requirements!确保对象的网格满足要求! -
Go to the Physics tab in the Parameters window and assign a physical body to the selected object by selecting Body -> Water.转到 Parameters 窗口中的 Physics 选项卡并分配一个物理身体通过选择 Body -> Water 到选定的对象。
- Set the body name and change other parameters, if necessary.如有必要,设置主体名称并更改其他参数。