This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

物体(Body)

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.启用后,所有这些近似于对象体积的物体及其形状都具有遵循牛顿力学的刚性对象的共同属性。

Run Lola Run

Ragdolls and rigid bodies moving according to the rigid body dynamics碎布娃娃和刚体根据刚体动力学运动

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.角运动另一方面,如果我们在空间中冻结人体的质心,则人体唯一能执行的运动就是旋转,这由角速度描述。
注意
Setting the body's linear or angular velocity will immediately make it move or rotate in a specified direction.设置物体的线速度或角速度将立即使其沿指定方向移动或旋转。

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ρ = 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 * aF = 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度旋转(即随时间改变速度),力可以间接控制其速度和位置。

注意
Forces acting on a body do not affect it immediately — they are accumulated before each physics simulation frame, and during simulation the resulting force, if unbalanced, is applied. Then forces are reset to zero to be calculated anew for the next frame. The same is true for torques.作用在物体上的力不会立即对其产生影响,它们会在每个物理模拟框架之前累积,并且在模拟过程中会施加不平衡的合成力。然后将力重置为零,以便为下一帧重新计算。扭矩也是如此。

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.力和冲动也可以施加到物体的任意点,并且当该点不是质心时,还可能导致物体旋转。在这种情况下,将力计算为力矢量和半径矢量(从质心到必要点)的叉积,并将其添加到扭矩中。相反,未施加到质心的扭矩会增加力。

注意
Unlike forces and torques, impulses immediately change body velocity as the physics is updated. 与力和扭矩不同,脉冲随着物理原理的更新而立即改变体速。

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:物体的质量乘以为世界指定的 gravity 定义其重量:

W = m * g

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:对象的密度定义为其单位体积的质量:

ρ = m / V

Density value evidently depends on the mass value and vice versa — the higher the values are, the heavier and more dense the object is.密度值显然取决于质量值,反之亦然:值越高,物体越重且密度越大。

不同质量和密度的浮力立方

Buoyant boxes of different mass and density不同质量和密度的浮力立方

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.最大线速度和角速度定义了物体的最大可能速度。超过此限制的速度将被裁剪。例如,最大线速度参数可以帮助避免隧穿(穿透)效应。

注意
There are also global maximum linear and angular velocities thresholds. The global maximum is compared with the maximum set for the body, and the minimum value is chosen to clip the actual velocity.还有全局最大 linear angular 速度阈值。将全局最大值与为物体设置的最大值进行比较,然后选择minimum值来限制实际速度。

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.摩擦是在物理物体之间接触时计算的。

注意
If the Collision option is enabled for a surface, it also contributes to calculations.如果为曲面启用了 Collision 选项,则它也有助于计算。

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.同样,就像摩擦一样,恢复是通过物体之间的接触来计算的。

注意
If the Collision option is enabled for a surface, it also contributes to calculations.如果为曲面启用了Collision选项,则它也有助于计算。

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.当物体不移动并保持平衡一段时间后,它很可能会不动,直到对其施加外力并促使其再次移动。在这段非活动期间,实际上没有必要对其进行仿真。此状态称为冻结,它可以节省大量计算资源。

注意

Freezing can be applied only to the following bodies:冻结只能应用于以下物体:

冻结立方     当脉冲解冻时,仿真又重新开始
冻结的蓝色和未冻结的红色立方。 施加在立方金字塔上的冲动使除了一个之外的所有东西都冻结了

The body is frozen, i.e. stops to be simulated, if:如果发生以下情况,则物体被冻结,即停止模拟:

  1. 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.它的线速度小于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 velocityFrozen angular velocity个阈值。将这些全局冻结阈值与为每个物体设置的阈值进行比较,然后选择最高值来冻结物体。

  2. 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 查看或调整这些参数,请执行以下操作:

  1. Select a node in the Editor Viewport or in the World Nodes hierarchy window.Editor Viewport世界节点层次结构窗口中选择一个节点。
  2. Go to the Physics tab in the Parameters window.转到 Parameters 窗口中的Physics标签。
  3. Specify available body parameters.指定可用的物体参数。
最新更新: 2024-12-13
Build: ()