当前位置:网站首页>What is radiographic testing

What is radiographic testing

2021-05-04 15:25:01 Old Wang of developing games

In the real world , What an object can or cannot do is restricted by objective laws such as Newton's law , If it wasn't for the deliberate cover up , Everything we see must be “ come very naturally ” Of ( They all conform to the objective law, so they must be natural ), But in the virtual world of games , There are no such objective laws , All the effects are simulated by game developers with various technologies “ illusion ”. therefore , I want these “ illusion ” look “ natural ”, Developers also have to simulate some “ Objective laws ” To constrain them .

Simulate these objective laws in Physics , A lot of times we'll leave it to the physics engine to deal with , Simply set the rigid body , Bounding box and some parameters , The physics engine will help us “ Build ” There's a physical world out there . But sometimes , We need to more accurately determine the nature of an environment , For example, how high is the obstacle ahead , Whether our characters can climb up , And we also want to decide the animation posture for the character to climb up according to the height of the obstacle , We need some more advanced methods . among , The most common and flexible method is Radiographic testing .

Radiographic testing In short, it allows us to specify the starting point A And the end B, The engine will fire a beam of A To B The rays of , The rays will interact with AB Collision between objects , And put the position 、 Normals and other information back to us . It's a bit like a bat using ultrasound to avoid obstacles .

 Insert picture description here

UE4 A very rich library of radiographic functions is provided in , Search the blueprint for trace, We can see some columns and its related nodes ( function ), These are all functions for radiographic testing

 Insert picture description here

Ray type

Don't be scared by so many functions , In fact, they all come down to the following form :

( Prefix :Multi) + The shape of the ray + [ suffix :ForObjects|ByChannel|ByProfile]

  • The shape of the ray : We can think of radiation as a shock wave from the sais , They could be a laser , A sphere , A cube or a capsule and so on .

Here's an example of a spherical ray : The front and rear ends are spherical , In the middle is the trajectory of this sphere

 Insert picture description here
The three suffixes provide three filtering methods for setting the response ray of the detected object :

  • suffix :ForObjects It means that the detection object of this ray is a class and its subclass objects , For example, we want to use this ray to detect all kinds of treasure boxes ;

  • suffix :ByChannel It's another way to classify the detected objects , We can do it in Project Settings/Collision/Trace Channels Add Channel, And assign a ray to a certain Channel, And then set this on various objects Channel The way the rays respond : Ignore (Ignore)、 overlap (Overlap) Or block (Block).

notes : Ignore (Ignore) It means that the object does not collide with the channel ray ; stop (Block) It means that the object will collide with the channel's rays , And the partial failure of the ray after colliding with the object ( No more collisions with other objects ); overlap (Overlap) Will collide with the channel's rays , And the part after the ray collides with the object will not fail ( This option is often associated with Multi Class with ray function , See below )

 Insert picture description here

  • suffix :ByProfile, The first two suffixes define rays from the perspective of the object being detected , occasionally , For example, we have a character , And we have set the response mode of this role and various environment objects , We want to define a ray so that the way it responds is completely copied from the character , At this time , We can do that Project Settings/Collision/Preset Add a Profile Preset , And set the default to be the same as the corresponding attribute of the character .

 Insert picture description here

  • Prefix : Finally, let's talk about prefixes Multi. If not Multi Prefix detection method , Then the ray will fail when it touches a target object ; And if you use tape Multi Prefix detection method , And the response of the target object to the ray is set to overlap (Overlap), Then the ray will not fail when it touches a target object , It is often used to detect a series of target objects .

Use none Multi Examples of prefix detection method or response mode not set to overlap :

 Insert picture description here
Use a Multi Example of prefix detection method and response mode set to overlap :

 Insert picture description here

Ray Debug Express

The non failure part of the ray is displayed in red by default , The invalid part is displayed in green by default . If the ray fails after the collision , The collision point is displayed as a red square by default , If the ray does not fail after the collision , The collision point is displayed as a green square by default .

 Insert picture description here

The parameter and return value of ray function

Parameters

We use SphereTraceByChannel For example , Explain the parameters and return values of the ray function

 Insert picture description here

  • Start and End: For the beginning and the end of the ray .
  • The shape of the ray : A parameter that describes the shape of a ray , Rays of different shapes are slightly different here , In this case, the spherical radius Radius.
  • suffix : Depending on the suffix type of the ray function , Here are choices Trace Channel、Object Types as well as Profile Name.
  • Trace Complex: Each collider has two versions of the bounding box , The collision bounding box type selected here is Simple still Complex.

 Insert picture description here

  • Actors To Ignore: Extra arrays of objects that need to be excluded from collision objects .

  • Ignore Self: Whether to exclude the collision with itself ( The default is true)

Other parameters are and Debug Related parameters , You can experiment by yourself .

Return value

  • Return Value: Boolean type , Whether there was a collision .
  • Out Hit: Collision results of structure types , After expansion, it is as follows :

 Insert picture description here
The more common one is : Out Hit Distance The distance from the starting point of the ray to the point of impact ;Out Hit Location The world coordinates of the collision point ;Out Hit Normal The normal of the collision point .

Summary

That's all UE4 A brief introduction to radiographic testing in , in application , We can not only use the ray function mentioned above directly , You can also combine them , So as to make more complex environmental judgment .

版权声明
本文为[Old Wang of developing games]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/05/20210504152416042a.html

随机推荐