实体
Bodies can be considered physical approximations of objects. They describe the object's behavior and represent a set of its physical parameters, such as mass, velocity, etc. It is the body that enables interaction of an object with other objects and external physical forces. Each type of body is used for simulation of a specific type of object:实体可以视为对象的物理近似。它们描述对象的行为并表示一组物理参数,例如质量,速度等。它是使对象与其他对象和外部物理力相互作用的主体。每种类型的主体都用于模拟特定类型的对象:
- Rigid body (also requires a shape to be assigned) — enables simulation of objects in accordance with the rigid body dynamics.刚体(还需要分配 shape )—能够根据刚体动力学模拟对象。
- Ragdoll body (also requires a shape to be assigned for each bone) — provides bone-animated characters with procedural animation of a death sequence.布娃娃身体(还需要为每个骨骼分配一个 shape )—为骨骼动画角色提供死亡序列的程序动画。
- Fracture body — enables real-time simulation of destructible objects.骨折体-可以实时模拟可破坏物体。
- Rope body — enables physical simulation of various types of ropes and wires.绳索主体-可以对各种类型的绳索和钢丝进行物理模拟。
- Cloth body — enables physical simulation of various types of cloth.布体-可以对各种类型的布料进行物理模拟。
- Water body — enables physical simulation of liquids of different density and viscous behavior including buoyancy effect and wave dynamics.水体-可以对不同密度和粘性行为的液体进行物理模拟,包括浮力效应和波浪动力学。
There are also two types of auxiliary bodies:还有两种类型的辅助体:
- Dummy body — a static type of body without physical properties. It is used to attach other bodies via joints.虚拟身体-一种没有物理属性的静态身体。它用于通过关节连接其他实体。
- Path body — a static type of body without physical properties. It is a spline, along which an arbitrary rigid body can be moved.路径主体-一种没有物理属性的静态主体。这是一个花键,可以使任意刚体沿其移动。
For quick visualization of all types of bodies, watch a fragment of our video tutorial on physics.为了快速查看所有类型的物体,请观看我们的 物理视频教程的一部分。
Rigid Body Dynamics刚体动力学#
Most physics simulations are based on rigid body dynamics. A rigid body is an ideal representation of a solid body, which occupies a finite volume of space. This volume of space is determined by a shape or a set of shapes assigned to the body. Rigid bodies cannot be deformed, i.e. their geometry does not change no matter what happens with this body. Rigid body dynamics is applied to the following bodies with shapes assigned:大多数物理学模拟都是基于刚体动力学的。刚体是固体的理想表示,它占据有限的空间。该空间量由 shape 或分配给主体的一组形状确定。刚性物体不能变形,即,不管该物体发生什么,其几何形状都不会改变。刚体动力学应用于指定了形状的以下刚体:
After being enabled, all these bodies and their shapes that approximate the object's volume share common properties of rigid objects obeying Newtonian mechanics.在启用后,所有这些近似于对象体积的实体及其形状都具有遵循牛顿力学的刚性对象的共同属性。
Watch a fragment of our video tutorial on physics for illustration of this article.观看我们的物理视频教程片段,以获取本文的插图。
Basic Concepts基本概念#
A state of a rigid body at any moment is specified with its position, orientation in space (with respect to some reference point — center of mass), and velocity. There are two types of body motion and, therefore, two velocity components:刚体在任何时刻的状态都由其在空间中的位置,方向(相对于某些参考点-质心 )和速度。身体运动有两种类型,因此有两个速度分量:
- Linear motion. If we imagine that the orientation of the body is fixed, then the only movement the body can undergo is translation motion — change in linear position. This change is performed with linear velocity.线性运动。如果我们想象身体的方向是固定的,那么身体只能经受的运动就是平移运动-线性位置的变化。此更改以线速度执行。
- Angular motion. On the other hand, if we freeze the center of mass of our body in space, the only movement the body will be able to perform is rotation, which is described by angular velocity.角运动。 另一方面,如果我们在空间中冻结人体的质心,则人体唯一能执行的运动就是旋转,这由角速度描述。
As the body moves, its linear and angular momenta change. The linear momentum can be thought of as an extent to which the body will continue to move along a straight path. It is the product of mass and linear velocity of the body:随着身体的移动,其线性和角动量发生变化。 线性动量可以认为是身体继续沿直线运动的程度。它是质量与身体线速度的乘积:
p = m * v p = m * v
The body will keep on moving forever, unless affected by an external force or impulse. Force equals mass of the body multiplied by acceleration:除非受到外力或冲动,否则身体将永远运动。 力等于身体质量乘以加速度:
F = m * a F = m * a
By causing the body to undergo acceleration (i.e., to change its velocity over time), force controls its velocity and position indirectly.通过使身体经历0度旋转(即随时间改变速度),力可以间接控制其速度和位置。
Impulse is the integral of force over time. It may be regarded as a change in momentum of an object to which a resultant force is applied. For example, when two bodies collide, they exchange impulses that are equal and opposite, as Newton's third law applies, and result in moving apart. 脉冲是力随时间的积分。可以将其视为施加了合力的物体的动量变化。例如,当两个物体碰撞时,当牛顿第三定律适用时,它们交换相等且相反的脉冲,并导致分开。
Similarly to the linear momentum, the angular momentum is the measure of the "quantity of rotation motion" and can be thought of as an extent to which the body will continue to rotate around an axis of symmetry. It is expressed as the product of the inertia tensor of the body and its angular velocity.与线性动量类似,角动量是“旋转运动量”的量度,可以认为是人体将继续围绕对称轴旋转的程度。它表示为身体 惯性张量 与角速度的乘积。
Rotation continues until torque, a rotational force, is exerted on this body. Torque is the cross product of the radius vector (a vector from the center of mass to the point where torque is applied) and the force vector (the magnitude of the force). Loosely speaking, it acts like a lever affecting rotational speed.旋转持续到扭矩(旋转力)施加到该物体上。扭矩是半径矢量(从质心到施加扭矩的点的矢量)和力矢量(力的大小)的叉积。宽松地说,它的作用就像影响转速的杠杆一样。
Forces and impulses can also be applied to an arbitrary point of the body and may cause body rotation, when this point is not the center of mass. In this case, force is computed as a cross product of force vector and radius vector (from the center of mass to the necessary point) and is added to the torque. And the other way around, torque applied not to the center of mass increases force.力和冲动也可以施加到身体的任意点,并且当该点不是质心时,还可能导致身体旋转。在这种情况下,将力计算为力矢量和半径矢量(从质心到必要点)的叉积,并将其添加到扭矩中。相反,未施加到质心的扭矩会增加力。
To sum it up, the movement is characterized by the following basic parameters:总结起来,该运动的特征在于以下基本参数:
直线运动 | 角运动 |
---|---|
Mass (scalar) | Inertia tensor (mat3) |
Linear velocity (vec3) | Angular velocity (vec3) |
Force(vec3)
Impulse ( vec3) |
Torque (vec3) |
Adjustable body parameters that determine its behavior in the framework of rigid body dynamics are as follows:确定其在刚体动力学框架中的行为的可调节体参数如下:
Mass弥撒#
Mass of the object multiplied by gravity specified for the world defines its weight:
The center of mass is automatically calculated as the mean location of mass of all shapes that approximate the object. It serves as a reference point for linear motion and rotation, as well as application of external force and torque. 重心被自动计算为逼近对象的所有形状的平均质量位置。它用作直线运动和旋转以及外力和扭矩施加的参考点。
Mass parameters of the body can be set up manually or determined automatically using the shape-based parameters. It is convenient when a body has several shapes.身体的质量参数可以手动设置,也可以使用基于形状的参数自动确定。当主体具有几种 shapes 时,这很方便。
Density密度#
Density of the objects is defined as its mass per unit volume:
Density value evidently depends on the mass value and vice versa: the higher the values are, the heavier and more dense the object is.密度值显然取决于质量值,反之亦然:值越高,物体越重且密度越大。
Density determines buoyancy of the body in accordance with Archimedes' principle. The higher the density, the less tendency a body has to float.根据阿基米德原理,密度决定了身体的浮力。密度越高,身体漂浮的趋势越少。
Linear Damping and Angular Damping线性阻尼和角阻尼#
When the object begins moving in a definite direction, the linear damping force slows it down to a complete stop. Similar to linear damping, angular damping reduces angular velocity of objects over time, so that their rotation ceases. To the linear damping of the body, the global Linear Damp is added, and the exponential function is calculated. In exactly the same way to angular damping of the body, the global Angular Damp is added.当物体开始沿确定的方向移动时,线性阻尼力将其减速直至完全停止。与线性阻尼类似,角阻尼会随着时间的推移降低对象的角速度,从而使它们的旋转停止。在车身的线性阻尼中,添加了全局 Linear Damp ,并计算了指数函数。以与主体的角度阻尼完全相同的方式,添加了全局 Angular Damp 。
These two parameters ensure that objects smoothly come to a stop and no calculations are done for unnecessary motion.这两个参数可确保对象平稳停止,并且无需进行不必要运动的计算。
Maximum Linear Velocity and Maximum Angular Velocity最大线速度和最大角速度#
Maximum linear and angular velocity define the maximum possible velocities of the body. Velocities that exceed this limit are clipped. For example, the maximum linear velocity parameter can help to avoid tunneling (penetration) effect.最大线速度和角速度定义了身体的最大可能速度。超过此限制的速度将被裁剪。例如,最大线速度参数可以帮助避免隧穿(穿透)效应。
Friction摩擦#
Coefficient of friction allows to model more rough rubbing of surfaces and is opposite to the body's movement direction. The higher the value, the less tendency the body has to slide. The friction values of both surfaces being in contact are considered.摩擦系数允许对表面进行更粗糙的摩擦建模,并且与身体的运动方向相反。值越高,身体滑动的趋势就越小。考虑两个接触表面的摩擦值。
The resulting calculated friction depends on the objects' masses and gravity, and the angle between contacting surfaces. For example, if a body slides down an inclined plane, the friction becomes lower because the force of gravity, which is perpendicular to the face of the surface, diminishes.计算得出的摩擦力取决于对象的质量和重力,以及接触面之间的角度。例如,如果人体沿倾斜平面滑行,则摩擦力会降低,因为垂直于表面的重力减小了。
Friction is calculated at contact between physical bodies.摩擦是在物理物体之间接触时计算的。
Restitution归还#
Coefficient of restitution determines the degree of relative kinetic energy retained after a collision. It defines how bouncy the object is by contacting with another object. It depends on the elasticity of materials of colliding bodies. The simulated restitution, like friction, considers the total value for both objects being in contact.恢复力的系数确定了碰撞后保留的相对动能的程度。它通过与另一个对象接触来定义对象的弹性。它取决于碰撞体材料的弹性。模拟的恢复(如摩擦)会考虑两个物体接触的总值。
- The maximum value of 1 models elastic collision. Objects bounce off according to the impulse they get by contact. 1 的最大值模拟弹性碰撞。物体根据它们通过接触获得的冲动反弹。
- The minimum value of 0 models inelastic collision. Objects do not bounce at all. 0 的最小值模拟无弹性碰撞。物体根本不反弹。
Again, just like friction, restitution is calculated by the contact between physical bodies.同样,就像摩擦一样,恢复是通过身体之间的接触来计算的。
Freezing冷冻#
When a body does not move and stays in the equilibrium for some time, it will most probably be immobile until an external force is exerted on it and urges it to move again. During this period of inactivity, there is actually no need to simulate it. This state is called freezing and it allows saving a great deal of computational resources.当物体不移动并保持平衡一段时间后,它很可能会不动,直到对其施加外力并促使其再次移动。在这段非活动期间,实际上没有必要对其进行仿真。此状态称为冻结,它可以节省大量计算资源。
冷冻的蓝色和未冷冻的红色盒子。 施加在盒子金字塔上的冲动使除了一个之外的所有东西都冻结了
|
The body is frozen, i.e. stops to be simulated, if:如果发生以下情况,则身体被冻结,即停止模拟:
- Its linear velocity is lower than Frozen linear velocity and its angular velocity is lower than Frozen angular velocity. Both velocity values must be lower at the same time, otherwise, the simulation will not stop.
There are also Frozen linear velocity and Frozen angular velocity thresholds set for the whole world. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.There are also Frozen linear velocity and Frozen angular velocity thresholds set for the whole world. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.
There are also Frozen linear velocity and Frozen angular velocity thresholds set for the whole world. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.它的线速度小于Frozen linear velocity,角速度小于Frozen angular velocity。两个速度值必须同时较低,否则仿真将不会停止。There are also Frozen linear velocity and Frozen angular velocity thresholds set for the whole world. These global freezing thresholds are compared to the ones set for each body, and the highest value is chosen to freeze the body.还为整个世界设置了Frozen linear velocity和Frozen angular velocity个阈值。将这些全局冻结阈值与为每个身体设置的阈值进行比较,然后选择 最高值来冻结身体。
- Velocity values stay lower than frozen velocities for the number of Frozen frames. This is done to ensure that the body has really terminated its motion.对于Frozen frames的数量,速度值保持低于冻结速度。这样做是为了确保身体真正终止其运动。
When the body is frozen, its linear and angular velocity are set to 0. The simulation of the body movement starts again as another non-frozen object touches it or some force is applied to it.冻结身体时,其线速度和角速度设置为 0 。当另一个未冻结的物体触摸它或对其施加一些力时,将再次开始模拟身体运动。
Setting Body Parameters设置身体参数#
The parameters of each body are determined by its type. To view or adjust these parameters via UnigineEditor:每个实体的参数由其类型决定。要通过 UnigineEditor 查看或调整这些参数,请执行以下操作:
- Select a node in the Editor Viewport or in the World Nodes hierarchy window.在Editor Viewport或 世界节点 层次结构窗口中选择一个节点。
- Go to the Physics tab in the Parameters window.转到 Parameters 窗口中的Physics标签。
- Specify available body parameters.指定可用的主体参数。