Study notes (6): game physics engine

1. The purpose of game application physics is to be real

2. Physics engine: It
can be considered as a component of the game engine, but it can be separated independently. The calculation of the physics simulation in the game is calculated and realized by the physics engine according to the laws of real world physics. There are currently two mainstream physics engines on the market, Havok and PhysX, and others include Open Dynamics Engine, Newton Game Dynamics, and Tokamak Game Physics

3. The performance advantage brought by the physics engine

  • a. Increase the richness of animation performance and reduce the workload of art (soft body physics)
  • b. Increase the authenticity of the game
  • c. Quickly simulate a variety of common situations in reality (such as swing, write an outrageously expensive code now)
  • d. Reduce the workload of the logic code (for example, under normal circumstances, the player will stop when encountering obstacles. This is natural in the physical world, but it is difficult to handle in the non-physical world)

4. How to give the game object physics?
Create a physical bounding box for the game model, the bounding box and the model always keep the same position, the physics engine acts on the physical bounding box, and then can affect the entire game object.

5. Physical type and application

  • a. Rigid body physics A rigid body refers to an object whose shape and size remain unchanged during movement and after being subjected to a force, and the relative position of internal points remains unchanged. In games, rigid body physics is the most widely used. Common terrain, buildings, players, etc. are basically endowed with rigid body physics, and the bows and arrows in the game, and physical bullets are also simulated and calculated by the physics engine. Which involves speed, acceleration, force rotation, momentum, friction, impulse, etc.
  • b. Broken physics An object will be broken when subjected to a certain force. Theoretically, the broken effect can be animated by an animator. However, if you want to produce different performance effects according to different forces, the workload of the animation is too heavy, and broken physics can Perfect solution to this problem.
  • c. The soot, snowflakes, rain, etc. in particle physics games. These particles do not add physics in many games (because the overhead is relatively high), but after adding physics, it is convenient to deal with many problems, such as rain water passing through the roof. problem
  • d. Fluid Physics Waterfalls, some rivers, etc. in the game. Our common seawater is generally not made using fluid physics, because the use of UV animation to process can greatly reduce the computational cost, and the current texture effect is also very good.

6. The origin and application of physics engine
Military warfare is actually easy to understand. Some foreign war games can be used to simulate training with a little modification. Since the purpose of the physics engine is simulation, the higher the degree of simulation, the more scenarios it can be applied to.

7. Common physical phenomena in games

  • a. Gravity, buoyancy Although this is the most common phenomenon in the real world, many games do not use physics engines to simulate gravity, but use relatively simple logic code to simulate gravity.
  • b. Collision Collision is the most common phenomenon. Any character must stop moving when encountering obstacles, or force each other to produce displacement
  • c. Deformation, including cloth, hair and other objects that are prone to deformation
  • d. Simulation of fluid movement and liquid At present, generally only large games or games with special needs will be used, and the cost is relatively large
  • e. Fragmentation The object is broken up in advance, and its model and physical binding are split into multiple pieces, which are scattered after being forced
  • f. Movements subject to physical constraints. Considering that the Ferris wheel, pendulum, swing and other constrained simulations in the real world, we can do special treatments to these objects, and this treatment is physical constraints

8. Physics engine in Unity (same as Unreal)
NVIDIA’s PhysX engine
Physics in Unity exists in the form of components. Assigning components to an OBject can give them corresponding characteristics.
There are roughly 6 types of physical components : RigidBody rigid body, Colider collision box, Joint constraint joints (the first three are rigid body components), Cloth cloth (soft body components), constant force constant force, CharacterController role controller

9. About the common applications of rigid body physics

  • a. Add collision entities (spherical SphereCollider, rectangular parallelepiped BoxCollider, capsule CapsuleCollider, wheel WheelCollider, triangular mesh MeshCollider, terrain TerrainCollider) to each object, and perform physical simulation operations based on these collision entities
  • b. Set up various hinge constraints (joint)
  • c. Ragdoll ragdoll system is generally aimed at player characters, used to simulate the effects of death
  • d. Collision screening: You can select specific marked collision boxes to collide with each other, without marking, there will be no collision

10. About the relationship between
rigid body and collision box. A rigid body is an entity that gives an object physical properties (mass, gravity, friction coefficient, etc.), while a collision box is used to simulate collisions between physics and collision results. Only rigid bodies do not have a collision box. Will pass through each other. As long as the collision box has no rigid body, then the collision force cannot be calculated correctly and it is meaningless

11.
Trigger is a technology often used in games. Simply put, it is to set an area, the player or NPC enters the area to trigger an event

12. The understanding of Joint
is called joint (hinge) in Unity, and its realization principle in physics engine is generally physical constraint. Essentially, it is to restrict some of its 6 degrees of freedom, for example, the object can only move in the XoY plane. In Unity, several commonly used joint types are provided by default (you need to configure your own constraints in unreal), which can easily achieve effects such as springs and pendulums.

13. Physical material
Physical material is the material that simulates objects in reality. It has two main functions. The first is to indicate the physical surface type of the current colliding body, which can be specially processed according to the type, and the second is to configure friction Parameters such as force can simulate the effect of collision of objects with different materials in reality.

14.
The concept of Character controller in Unity is very different from other engines such as unreal . Unity refers to a partial physics concept that is only affected by the player and not affected by other collision bodies. In unreal, it simply refers to a controller that controls the player's character.

15. The realization principle of the cloth system

  • a. Spring system generally adopts spring-mass point model
    https://www.cnblogs.com/shushen/p/5473264.html
    http://blog.csdn.net/silangquan/article/details/15746855
  • b. Long Range Attachment personally feel that this is not a technical principle, just understand the spring mass model
  • c. Collision detection The cloth is composed of multiple vertices. In order to ensure that it will not pass through the mold, it is necessary to ensure that each point can produce the correct collision
  • d. Animation fusion If the result of physical simulation is not ideal, you can let the artist manually make an animation, and then combine it according to a certain weight.
  • e. Wind disturbance Similar to plants, you can actively add a wind disturbance to simulate the effect of cloth fluttering
  • f. Gravity and damping The greater the damping, the greater the force required to flutter

Reprinted from the original link (please indicate if reprinted): http://blog.csdn.net/u012999985/article/details/79090524

Guess you like

Origin blog.csdn.net/qq_43801020/article/details/108936208