This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Physics

Unigine real-time physics integrates collision detection, fracturing, buoyancy, joints and external physical forces to realistically simulate objects and complex interactions between them.

Physics simulation in Unigine is based on rigid body dynamics and is calculated for dynamic objects. Dynamic objects differ from static ones in that they have:

  • Physical body (or bodies)
  • Collision shape (or shapes)
Moreover, physical bodies can be connected by joints that restrict body movement relative each other. This way, it is possible to approximate complex objects like ragdolls or compound mechanical devices like cars.

Static objects do not have associated physical bodies, hence, no forces can be applied to them, and they are immovable. However, they still participate in contacts with dynamic objects and prevent physical bodies from going through.

Adding Physics

To ensure consistent frame rate, simulation is based on the approximate and simplified calculations (though there are a lot of parameters like linear and rotational velocities, acceleration, friction, applied forces, etc.). Remember, it is not real world physics, but rather fake physics with sufficient precision that looks convincing.

Notice
  • Do not scale any meshes in the world (static ones and physical objects) if you are going to simulate physics! Otherwise, collisions will not be calculated properly.
  • Physics approximation (i.e. approximation of objects by shapes) does not need to be absolutely accurate. Approximating with spheres instead of convex hulls is strongly recommended.

See Adding physics for object tutorial for step-by-step guidance.

Global Physics Settings

Physics is simulated with its own FPS and is in effect within Physics simulation distance. (The rendering FPS can also be capped by the physics one). All other global physics-related settings are found in the Physics settings.

Physical Interaction

Most objects are not static decorations placed in the scene, they actively interact with each other, as the real object is the object of physics. It is unnatural and quite disappointing for the viewer to see the solid object inappropriately penetrating another one. Increasing the level of realism is thus unthinkable without proper approximation of the physical properties. On the other hand, there are still objects that do not require comprehensive modelling of their dynamics. The same duality goes for objects composite of many surface shapes. To compromise this fact, physical interaction is enabled on per-surface basis.

Collision Detection

Occupying a certain area in space, bouncing off the obstacles and even simply staying on the ground requires the collision detection. After checking the collision box, the surface participates in detecting, whether other objects come in contact with it and reacts correspondingly to the specified settings.

Collision Mask

For the collision detection to be more selective and at the same time alleviate the computational load, collision mask is set. For example, the object is indifferent to other objects actions and does not contribute to physical picture of the virtual world. Still, we want it to lie on the terrain, not to fall through it. Matching the bit masks of this object and the terrain (at least one bit in the masks should match), will get the desired effect.

Intersection Detection

Intersection serve a little different purposes, than collision. Intersection ray from one point to another allows lightweight and faster computing, if the surface is intersected. For example, computing collision of car wheels takes time and decreases manoeuvrability. If intersection will be used, the wheels are not represented with the properly reacting physical spheres, but rather rays, coming from the car body to the ground. And the problem of the plausible simulation will be solved.

Intersection Mask

Bit intersection mask allows to define the exact objects to be considered, when computing intersection, and disregard all the others, that have unmatched masks. It is a flexible tool, because only one bit in the masks should match. That means one object can easily participate in several different intersections simultaneously.

Last update: 2017-07-03
Build: ()