This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
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

形状

While a body simulates various types of physical behavior, a shape represents the volume of space occupied by a physical body. A physically simulated object usually has one body and one or several shapes which allow objects to collide with each other (therefore, shapes are often referred as collision shapes). Objects with shapes also fall under gravity, bounce off static surfaces or slide along them. A body without a single shape assigned behaves as a dummy body that can be connected to other bodies using joints, but does not collide and is immune to gravity.物体(body)模拟各种类型的物体行为时,形状表示物体所占据的空间量。物理模拟的对象通常具有一个物体和一个或多个形状,这些形状允许对象彼此碰撞(因此,形状通常称为碰撞形状)。具有形状的物体也会在重力作用下掉落,从静态表面反弹或沿其滑动。没有分配单一形状的物体的行为类似于虚拟物体,可以使用关节连接到其他物体,但是不会碰撞并且不受重力的影响。

注意
The maximum number of collision shapes for one body is limited to 32768.一个物理体的最大碰撞形状数限制为 32768

Basic shape types are as follows:基本形状类型如下:

Simple primitives make collision calculations easier while keeping performance high and accuracy acceptable. Convex hulls provide higher precision, however, continuous collision detection is not available for this type of shape. Therefore, convex hulls should not be used for fast-moving objects.简单的原语使碰撞计算更容易,同时保持高性能和准确性。凸包可提供更高的精度,但是,这种类型的形状无法进行连续碰撞检测。因此,不应该将凸包用于快速移动的对象。

注意
A shape doesn't have to duplicate the mesh it approximates. It is recommended to use simple primitives. Even though they are not precise, in the majority of cases they provide acceptable results.
The number of shapes should be kept as low as possible. Otherwise, heavy physics calculations will decrease the performance.
形状不必复制它近似的网格。建议使用简单的原语。即使它们不精确,在大多数情况下它们也可以提供可接受的结果。
形状的数量应尽可能保持。否则,繁琐的物理计算会降低性能。

A shape cannot be created without a body and does not have its own position in world coordinates. It is always assigned to a body and positioned relative to it.没有物体就无法创建形状,并且在世界坐标中没有自己的位置。始终将其分配给物体并相对于它定位。

See also也可以看看#

Programming implementation:编程实现:

Shape Parameters形状参数#

All shapes regardless of their type have the following common parameters所有形状,无论其类型如何,均具有以下通用参数:

Shape parameters

Enabled A flag indicating if a shape is enabled.一个标志,指示是否启用了形状。
Continuous A flag indicating if the continuous collision detection is enabled for the shape.
注意
Continuous collision detection is available for sphere and capsule shapes only.Continuous collision detection is available for sphere and capsule shapes only.
Continuous collision detection is available for sphere and capsule shapes only.
一个标志,指示是否对形状启用了连续碰撞检测。
注意
Continuous collision detection is available for sphere and capsule shapes only.连续碰撞检测仅适用于球形和胶囊形。
Mass Mass of the shape. Changing the mass influences the density, which is calculated by dividing the mass by shape volume. In case if there are several shapes assigned to a body (e.g. a set of convex hulls)形状的质量。改变质量会影响密度,密度是通过将质量除以形状体积而得出的。如果有几种形状分配给物体(例如一组凸包)
Density Density of the shape. Changing the density influences the mass, which is calculated by multiplying shape volume by density.形状的密度。更改密度会影响质量,质量是通过将形状体积乘以密度来计算的。
Friction Coefficient of friction of the shape. Defines how rough the shape's surface is. The higher the value, the less tendency the shape has to slide.
注意
In case if an object contains a surface and a shape, both with specified friction parameter, only the shape's parameter will be used.In case if an object contains a surface and a shape, both with specified friction parameter, only the shape's parameter will be used.
In case if an object contains a surface and a shape, both with specified friction parameter, only the shape's parameter will be used.
形状的摩擦系数。定义形状表面的粗糙度。值越高,形状滑动的趋势越少。
注意
In case if an object contains a surface and a shape, both with specified friction parameter, only the shape's parameter will be used.如果对象包含 surface 和形状(均具有指定的摩擦参数),则仅使用形状的参数。
Restitution Coefficient of restitution of the shape. Defines how bouncy the shape is when colliding.
  • The minimum value of 0 indicates inelastic collisions (a piece of soft clay hitting the floor)The minimum value of 0 indicates inelastic collisions (a piece of soft clay hitting the floor)
  • The maximum value of 1 represents highly elastic collisions (a rubber ball bouncing off a wall)The maximum value of 1 represents highly elastic collisions (a rubber ball bouncing off a wall)
注意
In case if an object contains a surface and a shape, both with specified restitution parameter, only the shape's parameter will be used.In case if an object contains a surface and a shape, both with specified restitution parameter, only the shape's parameter will be used.
The minimum value of 0 indicates inelastic collisions (a piece of soft clay hitting the floor)The maximum value of 1 represents highly elastic collisions (a rubber ball bouncing off a wall)In case if an object contains a surface and a shape, both with specified restitution parameter, only the shape's parameter will be used.
恢复形状的系数。定义碰撞时形状的弹性。
  • The minimum value of 0 indicates inelastic collisions (a piece of soft clay hitting the floor)最小值 0 表示无弹性碰撞(一块软粘土撞击地板)
  • The maximum value of 1 represents highly elastic collisions (a rubber ball bouncing off a wall) 1 的最大值表示高度弹性的碰撞(橡胶球从墙上弹起)
注意
In case if an object contains a surface and a shape, both with specified restitution parameter, only the shape's parameter will be used.如果对象包含 surface 和形状(都具有指定的恢复参数),则仅使用形状的参数。
Position Position of the shape in the coordinates of the body.形状在 body 坐标中的位置。
Rotation Rotation of the shape in the coordinates of the body. body 的坐标中旋转形状。
Physics Intersection mask Physics Intersection bit mask of the shape. Physics Intersection形状的位掩码。
Collision mask Collision bit mask of the shape. This mask is used to specify collisions of the shape with other ones.形状的碰撞位掩码。此蒙版用于指定形状与其他形状的碰撞。
Exclusion mask Exclusion bit mask of the shape. This mask is used to prevent collisions of the shape with other ones.形状的排除位掩码。此蒙版用于防止形状与其他形状发生碰撞。

Our video tutorial on physics contains an overview of the shape parameters and clarification on how to use the Exclusion and Collision masks.我們的物理視頻教程包含形狀參數的概述,並闡明瞭如何使用ExclusionCollision蒙版

Adding a Shape添加形状#

To add a shape via UnigineEditor, perform the following steps:要通过 UnigineEditor 添加形状,请执行以下步骤:

You can enable visualization of shapes by checking Helpers panel → Physics item → Shapes option (Visualizer should be enabled).您可以通过选中Helpers面板→Physics项目→Shapes选项(应启用Visualizer)来启用形状的可视化。

Sphere球形状#

A sphere is the simplest and the fastest shape, as it has only one parameter: a radius. Continuous collision detection is available for spherical shapes. Therefore, passing through other objects even when moving at a high speed is avoided. 球形状是最简单,最快的形状,因为它只有一个参数:半径。连续碰撞检测可用于球形。因此,即使在高速移动时也避免穿过其他物体。

Using the spherical shape for any arbitrary mesh ensures that its collisions will always be detected.将球形用于任何任意网格可确保始终检测到其碰撞。

球形状

For a shape to fit your object, you can adjust the Radius of the sphere.要使形状适合您的对象,可以调整球体的 Radius

球面半径

Capsule胶囊#

A capsule is also a very fast collision shape with continuous collision detection available. Capsules are convenient for approximation of elongated objects (pillars, etc.) as well as humanoid characters, because it allows them to go up and down the stairs smoothly, without stumbling at each step (if the steps are not too high). It also ensures that character's limb will not get stuck somewhere unexpectedly. 胶囊也是一种非常快速的检测碰撞形状,具有连续碰撞检测功能。胶囊便于拉长物体(支柱等)和类人动物角色,因为它使它们可以平稳地上下楼梯,而不会在每个步骤中绊脚(如果步骤不太高)。它还可以确保角色的肢体不会意外卡在某处。

胶囊的形状

For a shape to fit your object, you can adjust the Radius and the Height of the capsule.要使形状适合您的对象,您可以调整胶囊的半径高度

Cylinder圆柱#

A cylinder can be used to approximate elongated shapes with flat ends (e.g. a shafts, pylons, etc.). It is similar to a box shape. 圆柱可用于近似具有平坦端部的细长形状(例如,杆,塔等)。类似于立方形状。

圆柱的形状

For a shape to fit your object, you can adjust the Radius and the Height of the cylinder.要使形状适合您的对象,可以调整圆柱的半径高度

圆柱的高度和半径

Box立方#

A box is a cuboid shape which can be used for approximation of volume of various objects. it is suitable for walls, doors, stairs, parts of mechanisms, car bodies, and many other things. The length of a box shape in each dimension can be chosen arbitrarily. 立方是一个长方体形状,可用于近似各种对象的体积。它适用于墙壁,门,楼梯,机械零件,车身以及许多其他物体。每个尺寸的立方形状的长度都可以任意选择。

For a shape to fit your object, you can adjust the size of the box along each axis: Size X, Size Y, Size Y.为使形状适合您的对象,您可以沿每个轴调整框的大小:Size X, Size Y, Size Y

Convex Hull凸包#

Convex hull is the slowest of all shapes and is used for objects having complex geometry. The created shape will always be convex, that is, holes and cavities of the mesh are ignored when generating a convex hull. Instead, they are included into the shape volume. Convex shape is the smallest shape that can enclose vertices of the approximated mesh. Convex hull是所有形状中最慢的,用于具有复杂几何形状的对象。创建的形状将始终是凸形的,即,在生成凸包时,将忽略网格的孔和腔。而是将它们包含在形状体积中。凸形是可以包围近似网格顶点的最小形状。

To generate a convex hull specify an approximation error value:要生成凸包,请指定一个近似误差值:

凸形参数

The Approximation error parameter makes it possible to reduce the number of vertices of the created shape. Simple and rough convex hulls with small number of vertices are processed faster, therefore, it is recommended to keep the number of vertices as low as possible.使用Approximation error参数可以减少所创建形状的顶点数量。顶点数量少的简单且粗糙的凸包处理速度更快,因此,建议将顶点数量保持尽可能低。

  • By the value of 0, the shape precisely duplicates the mesh; the whole volume of it is enclosed. 通过值 0 ,形状精确地复制了网格;它的全部体积都封闭起来。
  • The higher the value, the less vertices there are in the created shape, but the more details are skipped.越高,所创建的形状中的顶点越少,但是跳过的细节越多。
Zero Approximation Error
Approximation error = 0近似错误= 0
    Higher value of Approximation Error
Approximation error = 0.1近似误差= 0.1

Autogenerated自动生成#

To approximate a complex concave object and exclude cavities from its volume, use a set of autogenerated convex hulls.要近似复杂的凹形对象并从其体积中排除腔,请使用组自动生成的凸形壳

A complex concave object approximated by a single convex hull (left) and an autogenerated set of convex hulls (right)由单个凸包(左)和一组自动生成的凸包(右)近似的复杂凹面对象

To add an autogenerated set of shapes specify the following parameters:要添加一组自动生成的形状,请指定以下参数:

自动生成参数

Recursion depth determines the degree of mesh decomposition. If 0 or a negative value is provided, only one shape will be created. The higher the value, the more convex shapes are to be generated Recursion depth确定网格分解的程度。如果提供 0 或负值,则只会创建一个形状。值更高,将生成更多凸形

Approximation error makes it possible to reduce the number of vertices of generated shapes. Simple and rough convex hulls with small number of vertices are processed faster, therefore, it is recommended to keep the number of vertices as low as possible. Approximation error可以减少所生成形状的顶点数量。顶点数量少的简单且粗糙的凸包处理速度更快,因此,建议将顶点数量保持尽可能低。

  • By the value of 0, the shape precisely duplicates the mesh; the whole volume of it is enclosed. 通过值 0 ,形状精确地复制了网格;它的全部体积都封闭起来。
  • The higher the value, the less vertices there are in the created shape, but the more details are skipped.更高,创建的形状中存在个顶点,但是跳过了更多详细信息。

Merging threshold determines the volume threshold for merging convex shapes after decomposition and can be used to reduce the number of generated shapes: the higher the value, the less convex shapes are to be generated. Merging threshold确定分解后合并凸形的体积阈值,可用于减少生成的形状的数量:较高的值,较小的凸形是

最新更新: 2023-05-25
Build: ()