Interaction between moving objects and complex terrain in real-time rendering scenarios

Source: Internet
Author: User

1. Identify the activity of a moving object using a shadow object

In order to interact with the scenario more realistically and provide good visual and operable feedback, computation based on various situations is essential.

For example, when the height of an area changes in vain, by default, some raised polygon will block the moving direction of the moving object. Therefore, we need to determine how to guide the next action of the moving object, A typical approach is to increase the height of an obstacle, but not always.

For example, when a wall is too high, so that a moving object should not climb, I create a "shadow object ", this shadow object has a collision box of the same size on the top of the collision box of the Motion Object "ontology". Imagine that the top of the collision box of the "ontology" is located near the knee of the visible form of the motion role, then the collision box of the "shadow object" is above it. When the collision between an object and the "ontology" is blocked, rather than the collision with the "shadow object", the object is obviously blocked from being in a low position, when we simultaneously detect a ratio of a motion object that is slowed down due to obstacles to the expected speed, we will send the elevation command to the Motion Object until the state is released.

Therefore, a moving object actually uses two collision boxes to help it roam better in the scene.

2. Relationship between collision feedback vectors and Motion Vectors

 

Object A is expected to travel with a vector and collide with a certain surface for correct correction. The unit vector of correct is the average line of the collision surface, the generated result motion vector is always parallel to the tangent of the surface and perpendicular to the normal, that is, vector, correct, and result form a right triangle.

Now we propose a proposition. We know the values of vector and correct, which are the strings of the right triangle and one of the straight angle edges. A is their angle, when the result model is 1/5 of the expected motion vector model, it is determined that the moving object is blocked. How can this problem be expressed by an inequality?

According to the proposition, we can see
| Result |/| vector | when <1/5,
Object A is blocked, I .e. sin (a) <0.2;
Vector and correct are known;
Also cos (A) = | correct |/| vector |,
If | result |/| vector | = 1/5,
Then | correct |/| vector | = SQRT (24)/5;
According to the feature of the cosine function curve graph, the cosine value decreases as the angle increases at a [0,180;
Similarly, the sine value increases, that is, the sine value approaches 0, angle a approaches 0, and the corresponding cosine value increases and approaches 1. Therefore:
The inequality can be expressed as | correct |/| vector |> 0. 9798...

Iii. Some C ++ code references

In this Code, the height correction triggered when a moving object is detected to be blocked will be included in a decay period for smoother visual and operational feedback.

Float valcos = Correctional. Mod ()/speed. Mod ();

Static float f = 0; // real-time height correction value
Static float f_0 = 0; // The initial height correction value.

If (F> 0) F-= f_0 * 0.1f;
Else f = 0, f_0 = 0;

Correctional. Y + = F;

If (! Correctional. iszero ())
{
If (speed. Z & correctionalshadow. Mod () <Epsilon
& Valcos> 0.979795897f) // SQRT (24)/5
F_0 = f = fwd_spd; // fwd_spd: horizontal velocity of a moving object

OBJ. setposition (obj. getposition () + correctional );
Objshadow. setposition (obj. getposition ());

Speed. Y + = Correctional. Y; // maintain the height state.
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.