Target object control method and device

文档序号:819377 发布日期:2021-03-30 浏览:23次 中文

阅读说明:本技术 目标对象控制方法及装置 (Target object control method and device ) 是由 张怡 于 2020-12-22 设计创作,主要内容包括:本申请提供目标对象控制方法及装置,其中,所述方法包括获取多个待移动的目标对象,并基于所述多个目标对象中的每个目标对象与目标位置之间的关系,确定每个所述目标对象的第一向量;以每个所述目标对象为原点,基于每个所述目标对象与预设半径内的至少一个其他目标对象的关系,确定每个所述目标向量的第二向量;基于每个所述目标对象与虚拟对象之间的关系,确定每个所述目标对象的第三向量;根据每个所述目标对象的第一向量、第二向量与第三向量确定每个所述目标对象的移动向量;根据所述移动向量控制每个所述目标对象移动至目标位置。所述方法利用每个目标对象的三个向量控制目标对象之间可以实现平滑不碰撞移动。(The application provides a target object control method and a target object control device, wherein the method comprises the steps of obtaining a plurality of target objects to be moved, and determining a first vector of each target object based on the relation between each target object and a target position in the plurality of target objects; determining a second vector of each target vector based on the relation between each target object and at least one other target object in a preset radius by taking each target object as an origin; determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object; determining a movement vector of each target object according to the first vector, the second vector and the third vector of each target object; and controlling each target object to move to a target position according to the movement vector. The method can realize smooth and collision-free movement by utilizing three vectors of each target object to control the target objects.)

1. A target object control method, characterized by comprising:

acquiring a plurality of target objects to be moved, and determining a first vector of each target object based on a relation between each target object and a target position in the plurality of target objects;

determining a second vector of each target vector based on the relation between each target object and at least one other target object in a preset radius by taking each target object as an origin;

determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to each of the target objects;

determining a movement vector of each target object according to the first vector, the second vector and the third vector of each target object;

and controlling each target object to move to a target position according to the movement vector.

2. The target object control method according to claim 1, wherein the determining a first vector for each of the target objects based on a relationship between each of the plurality of target objects and a target position comprises:

acquiring an angle between each target object in the plurality of target objects and a target position in a coordinate axis, and acquiring a current moving speed of each target object;

and determining a first vector of each target object according to the angle between each target object and the target position in the coordinate axis and the current moving speed of each target object.

3. The target object control method according to claim 1 or 2, wherein the determining the second vector of each target vector based on a relationship between each target object and at least one other target object within a preset radius with each target object as an origin comprises:

determining a fourth vector of each target object based on a reverse vector of each target object corresponding to at least one other target object within a preset radius by taking each target object as an origin;

determining a fifth vector for each of the target objects based on an average vector of at least one other target object for each of the target objects within the preset radius;

and determining a second vector of each target vector according to the fourth vector and/or the fifth vector.

4. The target object control method according to claim 3, wherein the determining the fourth vector of each target object based on the inverse vector corresponding to at least one other target object of each target object within the preset radius comprises:

determining at least one other target object of each target object within a preset radius;

acquiring a reverse angle between each other target object of the at least one other target object and each target object in a coordinate axis;

acquiring distance information between each other target object and each target object;

and determining a fourth vector of each target object according to the angle between each target object and all other target objects in the coordinate axis and the distance information between each target object and all other target objects.

5. The target object control method of claim 3, wherein determining the fifth vector for each of the target objects based on an average vector of at least one other target object for each of the target objects within the preset radius comprises:

determining at least one other target object of each target object within a preset radius;

obtaining a current vector of each other target object in the at least one other target object;

and determining a fifth vector of each target object according to the average value of the current vectors of all other target objects.

6. The target object control method according to claim 5, wherein the determining, as a fifth vector of each of the target objects, an average value of current vectors of all other target objects includes:

multiplying the target moving speed of each other target object by a preset steering coefficient to obtain the steering moving speed of each other target object;

and determining a fifth vector of each target object according to the angle of the current vector of all other target objects and the average value of the steering moving speed.

7. The target object control method according to claim 1 or 2, wherein the determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object includes:

determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms an equilateral triangle with two other target objects that are closest to each of the target objects.

8. The target object control method according to claim 7, wherein the determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object comprises:

acquiring an angle between each target object and the virtual object in a coordinate axis;

acquiring the current moving speed of each target object;

and determining a third vector of each target object according to the angle between each target object and the virtual object in the coordinate axis and the current moving speed of each target object.

9. A target object control apparatus, characterized by comprising:

a first vector determination module configured to acquire a plurality of target objects to be moved and determine a first vector of each of the target objects based on a relationship between each of the target objects and a target position;

a second vector determination module configured to determine a second vector of each target vector based on a relationship between each target object and at least one other target object within a preset radius, with each target object as an origin;

a third vector determination module configured to determine a third vector for each of the target objects based on a relationship between the target object and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to the target object;

a motion vector determination module configured to determine a motion vector for each of the target objects based on the first, second, and third vectors for each of the target objects;

a target object control module configured to control each of the target objects to move to a target position according to the movement vector.

10. A computing device comprising a memory, a processor, and computer instructions stored on the memory and executable on the processor, wherein the processor implements the steps of the method of any one of claims 1-9 when executing the instructions.

11. A computer-readable storage medium storing computer instructions, which when executed by a processor, perform the steps of the method of any one of claims 1 to 9.

Technical Field

The application relates to the technical field of computers, in particular to a target object control method. The application also relates to a target object control apparatus, a computing device, and a computer-readable storage medium.

Background

At present, when a large-scale unit (such as a fish school, a bird school, etc.) moves to a destination in a game, collision detection is generally used for avoiding the overlapping of the units, and then trial movement is adopted for realizing the movement of the units; however, it is relatively inefficient to avoid the overlap between the units by adopting collision detection, when a large number of units move, it is easy to cause that the consumption of a Central Processing Unit (CPU) is too high, which results in the game jam, and meanwhile, the strategy of trial movement of a single Unit also causes confusion and non-reality in the whole moving process of a large scale of units.

Disclosure of Invention

In view of this, the present application provides a target object control method. The application also relates to a target object control device, a computing device and a computer readable storage medium, which are used for solving the technical defects of overlapping and confusion in large-scale unit movement in the prior art.

According to a first aspect of embodiments of the present application, there is provided a target object control method, including:

acquiring a plurality of target objects to be moved, and determining a first vector of each target object based on a relation between each target object and a target position in the plurality of target objects;

determining a second vector of each target vector based on the relation between each target object and at least one other target object in a preset radius by taking each target object as an origin;

determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to each of the target objects;

determining a movement vector of each target object according to the first vector, the second vector and the third vector of each target object;

and controlling each target object to move to a target position according to the movement vector.

According to a second aspect of embodiments of the present application, there is provided a target object control apparatus including:

a first vector determination module configured to acquire a plurality of target objects to be moved and determine a first vector of each of the target objects based on a relationship between each of the target objects and a target position;

a second vector determination module configured to determine a second vector of each target vector based on a relationship between each target object and at least one other target object within a preset radius, with each target object as an origin;

a third vector determination module configured to determine a third vector for each of the target objects based on a relationship between the target object and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to the target object;

a motion vector determination module configured to determine a motion vector for each of the target objects based on the first, second, and third vectors for each of the target objects;

a target object control module configured to control each of the target objects to move to a target position according to the movement vector.

According to a third aspect of embodiments herein, there is provided a computing device comprising a memory, a processor and computer instructions stored on the memory and executable on the processor, the processor implementing the steps of the target object control method when executing the instructions.

According to a fourth aspect of embodiments of the present application, there is provided a computer-readable storage medium storing computer instructions which, when executed by a processor, implement the steps of the target object control method.

The method comprises the steps of obtaining a plurality of target objects to be moved, and determining a first vector of each target object based on the relation between each target object and a target position in the plurality of target objects; determining a second vector of each target vector based on the relation between each target object and at least one other target object in a preset radius by taking each target object as an origin; determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to each of the target objects; determining a movement vector of each target object according to the first vector, the second vector and the third vector of each target object; and controlling each target object to move to a target position according to the movement vector. Specifically, the target object control method controls the moving speed and angle of each target object moving to the target position, the distance between each target object and the like through the obtained three vectors of each target object, so that each target object can move smoothly without collision, the moving formation of all the target objects can be kept, and the moving reality of the target objects is improved.

Drawings

Fig. 1 is a flowchart of a target object control method according to an embodiment of the present application;

fig. 2 is a schematic diagram of a target object in a target object control method according to an embodiment of the present application;

fig. 3 is a schematic diagram of a first vector of a target object in a target object control method according to an embodiment of the present application;

fig. 4 is a schematic diagram of a target object and other corresponding target objects in a target object control method according to an embodiment of the present application;

fig. 5 is a schematic diagram of a fourth vector of a target object in a target object control method according to an embodiment of the present application;

fig. 6 is a schematic diagram of a fifth vector of a target object in a target object control method according to an embodiment of the present application;

fig. 7 is a schematic diagram of another fifth vector of a target object in a target object control method according to an embodiment of the present application;

fig. 8 is a schematic diagram of a third vector of a target object in a target object control method according to an embodiment of the present application;

fig. 9 is a diagram illustrating group movement effects of a plurality of target objects in a target object control method according to an embodiment of the present application;

fig. 10 is a schematic structural diagram of a target object control apparatus according to an embodiment of the present application;

fig. 11 is a block diagram of a computing device according to an embodiment of the present application.

Detailed Description

In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. This application is capable of implementation in many different ways than those herein set forth and of similar import by those skilled in the art without departing from the spirit of this application and is therefore not limited to the specific implementations disclosed below.

The terminology used in the one or more embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the present application. As used in one or more embodiments of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present application refers to and encompasses any and all possible combinations of one or more of the associated listed items.

It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments of the present application to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first aspect may be termed a second aspect, and, similarly, a second aspect may be termed a first aspect, without departing from the scope of one or more embodiments of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.

First, the noun terms to which one or more embodiments of the present application relate are explained.

Vector quantity: english is called completely: euclidean vector, also called vector and euclidean vector for physics, engineering, etc., is a basic concept in many natural sciences such as mathematics, physics, and engineering science. A geometric object which has both size and direction and meets the parallelogram rule is indicated; wherein size is understood in the present application as the speed of movement.

Forming: is generally used to describe the deployment of ancient military forces for action or combat. Such as fish scale matrix, wild goose shape matrix … …, etc.

Equilateral triangle: also called as regular triangle, it means triangle with three equal sides, three equal internal angles, all 60 °, it is one of acute triangle.

In the present application, a target object control method is provided, and the present application relates to a target object control apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.

Referring to fig. 1, fig. 1 shows a flowchart of a target object control method according to an embodiment of the present application, which specifically includes the following steps.

Step 102: the method comprises the steps of obtaining a plurality of target objects to be moved, and determining a first vector of each target object based on the relation between each target object and a target position in the plurality of target objects.

In specific implementation, the target object control method can be applied to a game scene to control the movement of group characters in a game picture; the method can also be applied to cartoon and cartoon video scenes to realize the control of the movement of group roles in cartoon and cartoon video frames. In practical application, the target object control method is applied in different scenes, and the target objects are different; for example, in a game scene, a group character in a game picture is a plurality of target objects, which may be fish, bird or tank groups, and the like, while in a cartoon or cartoon video scene, a group character in a video frame may be a plurality of target objects, which may be cartoon military forces, cartoon characters forming a cartoon martial art formation, and the like.

Referring to fig. 2, fig. 2 is a schematic diagram illustrating a target object in a target object control method according to an embodiment of the present application.

Fig. 2 is a game scene, the screen in fig. 2 is a game screen, and the tank group in fig. 2 is a plurality of target objects of the present application.

For convenience of understanding, the target object control method is applied to a game scene in the present application, and the movement control of a group character in a game screen is realized as an example.

If the target object is a fish, and a plurality of target objects to be moved are obtained, it can be understood that a plurality of fish in the current game picture are obtained.

After obtaining a plurality of fish in a current game picture, determining a first vector of each fish based on a relation between each fish in the plurality of fish and a target position; the target position can be understood as a preset destination in a game scene, for example, a fish needs to swim to a circular water pool, and then the circular water pool is the target position.

Specifically, the determining a first vector of each target object based on a relationship between each target object of the plurality of target objects and a target position includes:

acquiring an angle between each target object in the plurality of target objects and a target position in a coordinate axis, and acquiring a current moving speed of each target object;

and determining a first vector of each target object according to the angle between each target object and the target position in the coordinate axis and the current moving speed of each target object.

The target position may be understood as a destination to which the target object is to be moved finally.

In practice, the first vector may be understood as a vector V1 pointing to the destination for each target object, and the vector V1 includes two parameters: direction and magnitude, where direction may be expressed in degrees and magnitude may be expressed in velocities.

According to the above example, the angle between each fish in the coordinate axis and the destination and the current self moving speed of each fish are obtained and are used as the first vector of each fish, wherein the current self moving speed of each fish is different.

Referring to fig. 3, fig. 3 is a schematic diagram illustrating a first vector of a target object in a target object control method according to an embodiment of the present application.

In fig. 3, a triangle represents a target object (e.g., a fish), an arrow points to the destination of the target object, and the first vector is the first vector V1 where the target object points to the destination.

In the embodiment of the application, the first vectors of each target object are obtained in such a way, and the first vectors corresponding to all the target objects are obtained, so that all the target objects can be ensured to move by taking the destination as a main direction, and the actual moving requirement of the target objects is met.

Step 104: and determining a second vector of each target vector based on the relation between each target object and at least one other target object in a preset radius by taking each target object as an origin.

The preset radius may be set according to an actual application scenario, which is not limited in this application, and is set to be 2 centimeters, 3 centimeters, and the like.

Specifically, the determining the second vector of each target vector based on the relationship between each target object and at least one other target object within a preset radius with each target object as an origin includes:

determining a fourth vector of each target object based on a reverse vector of each target object corresponding to at least one other target object within a preset radius by taking each target object as an origin;

determining a fifth vector for each of the target objects based on an average vector of at least one other target object for each of the target objects within the preset radius;

and determining a second vector of each target vector according to the fourth vector and/or the fifth vector.

The reverse vector of each target object corresponding to at least one other target object within the preset radius may be understood as a reverse vector from the center of at least one target object within the preset radius of each target object to the center of the corresponding target object.

In practical application, each target object is taken as an origin, circles are drawn based on a preset radius, and the target object included in the circle corresponding to each target object is taken as other target objects; then determining a fourth vector of each target object based on the reverse vectors of all other target objects relative to the target objects thereof; a fifth vector for each target object is determined based on the average vectors of all other target objects.

Specifically, after the fourth vector and the fifth vector are obtained, the second vector of each target object may be determined based on the fourth vector, the second vector of each target object may also be determined based on the fifth vector, or the second vector of each target object may also be determined based on the fourth vector and the fifth vector; in practical application, the fourth vector enables reverse thrust to be generated among the target objects, and in the process that all the target objects move to the target positions, overlapping and collision among the target objects can be avoided based on the fourth vector; the fifth vector enables aggregation force to be generated between the target objects, and in the process that all the target objects move to the target positions, the situation that the target objects are confused and scattered can be avoided based on the fifth vector. Therefore, the second vector of the target object determined based on the fourth vector can generate reverse thrust between the target objects in the process of moving all the target objects to the target position, so as to avoid overlapping and collision between the target objects; the second vector of the target object is determined based on the fifth vector, and aggregation force can be generated among the target objects in the process that all the target objects move to the target positions, so that confusion and scattering among the target objects are avoided; and the second vector of the target object determined based on the fourth vector and the fifth vector can generate reverse thrust between the target objects in the process of moving all the target objects to the target positions, so that overlapping and collision between the target objects are avoided, and aggregation force can be generated between the target objects, so that confusion and scattering between the target objects are avoided.

Referring to fig. 4, fig. 4 is a schematic diagram illustrating a target object and other corresponding target objects in a target object control method according to an embodiment of the present application.

Fig. 4 includes a target object 1, a target object 2, and a target object 3, and circles the target object 1 as an origin based on a preset radius, and the target object 2 and the target object 3 in the circle are used as other target objects of the target object 1; a fourth vector for target object 1 is then determined based on the inverse vectors for target object 2 and target object 3, and a fifth vector for each target object is determined based on the average vectors for target object 2 and target object 3.

In specific implementation, the fourth vector of the target object may generate a reverse thrust with the surrounding target objects in the process that all the target objects move toward the target positions, so as to avoid collision and overlapping between the target objects, and the fifth vector of the target object may generate a constraint force with the surrounding target objects in the process that all the target objects move toward the target positions, so as to ensure consistency of the target objects moving toward the target positions, and avoid confusion.

In another embodiment of the present application, the determining a fourth vector of each target object based on a reverse vector corresponding to at least one other target object of each target object within the preset radius includes:

determining at least one other target object of each target object within a preset radius;

acquiring a reverse angle between each other target object of the at least one other target object and each target object in a coordinate axis;

acquiring distance information between each other target object and each target object;

and determining a fourth vector of each target object according to the reverse angle between each target object and all other target objects in the coordinate axis and the distance information between each target object and all other target objects.

The distance information between each other target object and each target object can be understood as a reverse distance between each other target object and the corresponding target object, that is, a reverse moving speed.

Following the above example, the fourth vector V2 for determining the target object 1 is explained.

First, a target object 2 and a target object 3 of the target object 1 within a preset radius are acquired, and then a reverse angle between the target object 2 and the target object 1 in the coordinate axis, a reverse angle between the target object 3 and the target object 1 in the coordinate axis, and a reverse distance between the target object 2 and the target object 1, and a reverse distance between the target object 3 and the target object are acquired.

Finally, a fourth vector of the target object 1 is determined based on the inverse angle between the target object 2 and the target object 1 in the coordinate axis, the inverse angle between the target object 3 and the target object 1 in the coordinate axis, and the inverse distance between the target object 2 and the target object 1, and the inverse distance between the target object 3 and the target object.

In specific implementation, determining a fourth vector of each target object according to the reverse angle between each target object and all other target objects in the coordinate axis and the distance information between each target object and all other target objects, includes:

adding the reverse angles between all other target objects and each target object in the coordinate axis, and adding the reverse distances between all other target objects and each target object, taking the added reverse angles and reverse distances as a fourth vector of each target object,

the larger the distance between the other target objects and each target object is, the smaller the fourth vector of each target object is; the smaller the distance between the other target objects and each target object is, the larger the fourth vector of each target object is.

In practical applications, a plurality of other target objects may exist in each target object parameter radius R, and each other target object generates a reverse vector, so that a plurality of reverse vectors exist, and after the plurality of reverse vectors are added, the finally added reverse vector is taken as the fourth vector V2 of the target object, that is, the direction (i.e., the angle) of the fourth vector V2 of each target object is the reverse direction of the connection direction of the other target objects and the target object in the target object preset radius R, and the size (i.e., the moving speed) is inversely proportional to the distance between the other target objects and the target object.

Referring to fig. 5, fig. 5 is a schematic diagram illustrating a fourth vector of a target object in a target object control method according to an embodiment of the present application.

The target object 1, the target object 2, the target object 3, the target object 4, the target object 5, and the target object 6 are included in fig. 5, wherein the target object 1 is used as an origin, the target object 1, the target object 2, and the target object 3 are included in a circle with a preset radius R, and then the sum of vectors pointing in the opposite directions of the target object 2 and the target object 3 is used as a fourth vector of the target object 1.

In specific implementation, the sum of the reverse direction (i.e., the angle) of the connecting line between the center point of the target object 2 and the center point of the target object 1, the reverse direction (i.e., the reverse movement speed) of the connecting line between the center point of the target object 2 and the center point of the target object 1, the reverse direction of the connecting line between the center point of the target object 3 and the center point of the target object 1, the reverse direction of the connecting line between the center point of the target object 2 and the center point of the target object 1, and the reverse direction of the connecting line between the center point of the target object 3 and the center point of the target object 1 is taken as the fourth vector of the target object 1.

Meanwhile, in a specific application, the closer each target object is to the adjacent target object, the larger the fourth vector of the target object is, and vice versa.

In the embodiment of the application, the reverse vectors of other target objects of each target object within the preset radius are used as the fourth vector of each target object, and in the process that all target objects move based on the fourth vector, the external thrust can be generated between the target objects close to each other, so that the phenomenon that the target objects close to each other are overlapped or collided in the moving process is avoided, and the user experience is improved. Taking the target object as a fish as an example, the fourth vector of each fish is obtained, so that a reverse thrust can be generated between each fish in the fish swarm and other surrounding fishes in the process that the fish swarm moves to the target position, and the collision and the overlapping with the surrounding fishes are avoided.

In another embodiment of the present application, the determining a fifth vector of each of the target objects based on an average vector of at least one other target object of each of the target objects within the preset radius includes:

determining at least one other target object of each target object within a preset radius;

obtaining a current vector of each other target object in the at least one other target object;

and determining a fifth vector of each target object according to the average value of the current vectors of all other target objects.

The current vector may be understood as a motion vector of a target object moving last time in a current picture, that is, a motion vector determined by performing weighted addition on a first vector, a second vector, and a third vector of each target object by using the target object control method of the present application.

Firstly, acquiring at least one other target object of each target object within a preset radius; then, current vectors of all other target objects in the at least one other target object are obtained, and then the current vectors are added and averaged to be used as a fifth vector of the target object.

Referring to fig. 6, fig. 6 is a schematic diagram illustrating a fifth vector of a target object in a target object control method according to an embodiment of the present application.

Fig. 6 includes a target object 1, a target object 2, a target object 3, and a target object 4, where the circle with the target object 1 as an origin and the preset radius R includes the target object 1, the target object 2, the target object 3, and the target object 4, then current vectors of the target object 2, the target object 3, and the target object 1 are obtained, then the current vectors of the target object 2, the target object 3, and the target object 4 are added and averaged, and the calculated average value is used as a fifth vector V3 of the target object 1.

Referring to fig. 7, fig. 7 is a schematic diagram illustrating another fifth vector of a target object in a target object control method according to an embodiment of the present application.

Fig. 7 includes a target object 1, a target object 2, a target object 3, and a target object 4, where the circle with the target object 1 as an origin and the preset radius R includes the target object 1, the target object 2, the target object 3, and the target object 4, then current vectors of the target object 2, the target object 3, and the target object 1 are obtained, then the current vectors of the target object 2, the target object 3, and the target object 4 are added and averaged, and the calculated average value is used as a fifth vector V3 of the target object 1.

In the embodiment of the application, each target object is taken as a centroid, other target objects of each target object within a preset radius are obtained, and an average value of current vectors of the other target objects is taken as a fifth vector of each target object; when all target objects move, the moving speed and direction of each target object are constrained based on the current vectors of other target objects within the preset radius, so that consistency between each target object and other adjacent target objects is kept when the target objects move, and confusion is avoided.

In specific implementation, the taking the average value of the current vectors of all other target objects as the fifth vector of each target object includes:

multiplying the target moving speed of each other target object by a preset steering coefficient to obtain the steering moving speed of each other target object;

and determining a fifth vector of each target object according to the angle of the current vector of all other target objects and the average value of the steering moving speed.

Specifically, the current vector includes a target angle and a target moving speed, and in a game scene, in order to ensure the authenticity of the movement of the target object, time is required for the turning of the target object, and the turning cannot be performed instantaneously, so that the target object is prevented from jumping to a larger extent to influence the user experience.

In practical application, after determining the current vector (i.e., the target angle and the target moving speed) of the other target object of each target object, the target moving speed of each other target object is multiplied by a preset steering coefficient to obtain the steering moving speed of each other target object, and then the target vectors of each other target object formed by the steering moving speed and the angle (i.e., the target angle) of the current vector are weighted and averaged to obtain the fifth vector of each target object.

In the embodiment of the application, when all the target objects move, the steering moving speed and direction of each target object can be controlled based on the fifth vector of each target object when all the target objects steer, so that the smooth steering of all the target objects is realized, and the sense of reality experienced by a user is strong. Taking the target object as a fish as an example, acquiring a fifth vector of each fish, and controlling the steering movement speed and direction of the fish in the process that the fish school moves to the target position to realize smooth movement; and each fish in the fish school and other adjacent fish can keep the consistency of movement when moving, and confusion between the fish and the adjacent fish in the moving process is avoided.

Step 106: determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects that are closest in distance to each of the target objects.

Specifically, the determining a third vector of each target object based on a relationship between each target object and a virtual object includes:

determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms an equilateral triangle with two other target objects that are closest to each of the target objects.

The virtual object may be set according to an actual application, which is not limited in this application, for example, the virtual object may be a point or a preset shape. Specifically, the position of the virtual object is determined by two other target objects, which are closest to each target object, and the virtual object and the two other target objects are connected to form an equilateral triangle.

In specific implementation, because the fourth vector of each target object is a vector generating a reverse thrust, if each target object is permanently repelled, the target objects will be scattered when the target objects move as a whole, and the third vector of each target object can be used to generate relevance between each target object and other target objects, so that when the target objects move as a whole, a normal formation can be kept to move all the time.

In another embodiment of the present specification, the determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object includes:

acquiring an angle between each target object and the virtual object in a coordinate axis;

acquiring the current moving speed of each target object;

and determining a third vector of each target object according to the angle between each target object and the virtual object in the coordinate axis and the current moving speed of each target object.

In practical application, two other target objects with the closest distance to each target object are determined, then an equilateral triangle is drawn by taking a connecting line between the two determined target objects as an edge, and then an angle between each target object and the corresponding equilateral triangle and the current moving speed of each target object are taken as a third vector V4 of each target object, wherein the third vector V4 can be regarded as a vector in which each target object points to a formation position formed by a plurality of target objects.

Referring to fig. 8, fig. 8 is a schematic diagram illustrating a third vector of a target object in a target object control method according to an embodiment of the present application.

Fig. 8 includes a target object 1, a target object 2, a target object 3, a target object 4, a target object 5, and a target object 6, where the circle with the target object 1 as an origin and the preset radius R includes the target object 1, the target object 2, and the target object 3, and the target object 2 and the target object 3 are two other target objects closest to the target object 1, and then an equilateral triangle is drawn based on the target object 2 and the target object 3, and an angle between the target object 1 and a vertex of the equilateral triangle and a current moving speed of the target object 1 are acquired as a third vector V4 of the target object 1.

In a specific implementation, the direction in the third vector of each target object is a direction forming an equilateral triangle, that is, an angle between each target object and a vertex of the equilateral triangle in a coordinate axis, and the size (that is, a moving speed) in the third vector of each target object is not fixed, and if the setting is larger, the speed of the target object returning to the matrix type is faster, and vice versa.

In the embodiment of the application, by obtaining the third vectors which point to the two nearest target objects and form an equilateral triangle, when all the target objects move integrally, the formation of each target object in the moving process can be controlled, because the fourth vector of each target object is a vector which generates reverse thrust, if each target object is always repelled, the target objects can be scattered when the target objects move integrally, the third vector of each target object can be used for generating relevance between each target object and other target objects, and the fourth vector and the third vector of each target object enable the target objects to move without collision and overlapping, and scattering, so that the normal formation can be kept to move all the time, and the user experience is improved.

Still taking the target object as a fish as an example, the third vector of each fish is obtained, and in the process of moving the fish school to the target position, the relevance is generated between each fish in the fish school and other surrounding fishes, and in the moving process, the fourth vector and the third vector of each fish enable the fishes to move in a normal formation all the time without collision and overlapping and scattering, so that the user experience is improved.

Step 108: and determining the movement vector of each target object according to the first vector, the second vector and the third vector of each target object.

Specifically, the determining the motion vector of each target object according to the first vector, the second vector and the third vector of each target object includes:

and weighting and adding the first vector, the second vector and the third vector of each target object to obtain a movement vector of each target object.

In particular, after the first vector, the second vector (i.e., the fourth vector and the fifth vector) and the third vector of each target object are obtained, the four vectors are added to obtain a final motion vector, i.e., a motion vector, of each target object, and the motion of each target object to the target position can be controlled by the motion vector to obtain a smooth group motion effect. Specifically, the calculation of the target vector may be performed by the following formula:

where V denotes a motion vector, V1 denotes a first vector, V2 denotes a fourth vector, V3 denotes a fifth vector, and V4 denotes a third vector.

Step 110: and controlling each target object to move to a target position according to the movement vector.

In the embodiment of the application, after the motion vector of each target object is obtained, the motion of the target object can be controlled based on the motion vector corresponding to each target object, so that each target object can smoothly and truly move to the target position based on the corresponding motion vector, the group moving effect of smooth motion of all target objects is realized, and the user experience is improved.

Referring to fig. 9, fig. 9 is a diagram illustrating a group movement effect of a plurality of target objects in a target object control method according to an embodiment of the present application.

Fig. 9 is a diagram illustrating a group smooth movement effect when a plurality of target objects move to target positions.

In specific implementation, if the method is applied to video frames, when a plurality of target objects in each video frame move to a target position of a next video frame, the method may also be implemented by using the target object control method of the present application, which is not described herein again.

According to the target object control method provided by the embodiment of the application, the moving speed and the moving angle of each target object to the target position, the distance between each target object and the like are controlled through the obtained three vectors of each target object, so that each target object can move smoothly without collision, the moving formation of all the target objects can be kept, and the moving reality of the target objects is improved.

Corresponding to the above method embodiment, the present application further provides an embodiment of a target object control apparatus, and fig. 10 shows a schematic structural diagram of a target object control apparatus provided in an embodiment of the present application. As shown in fig. 10, the apparatus includes:

a first vector determination module 1002 configured to obtain a plurality of target objects to be moved, and determine a first vector of each of the target objects based on a relationship between each of the target objects and a target position;

a second vector determination module 1004 configured to determine a second vector of each of the target vectors based on a relationship of each of the target objects to at least one other target object within a preset radius, with each of the target objects as an origin;

a third vector determination module 1006 configured to determine a third vector for each of the target objects based on a relationship between the target object and a virtual object, wherein the virtual object forms a predetermined shape with at least two other target objects closest to the target object;

a motion vector determination module 1008 configured to determine a motion vector for each of the target objects from the first, second, and third vectors for each of the target objects;

a target object control module 1010 configured to control each of the target objects to move to a target position according to the movement vector.

Optionally, the first vector determining module 1002 is further configured to:

acquiring an angle between each target object in the plurality of target objects and a target position in a coordinate axis, and acquiring a current moving speed of each target object;

and determining a first vector of each target object according to the angle between each target object and the target position in the coordinate axis and the current moving speed of each target object.

Optionally, the second vector determining module 1004 is further configured to:

determining a fourth vector of each target object based on a reverse vector of each target object corresponding to at least one other target object within a preset radius by taking each target object as an origin;

determining a fifth vector for each of the target objects based on an average vector of at least one other target object for each of the target objects within the preset radius;

and determining a second vector of each target vector according to the fourth vector and/or the fifth vector.

Optionally, the second vector determining module 1004 is further configured to:

determining at least one other target object of each target object within a preset radius;

acquiring a reverse angle between each other target object of the at least one other target object and each target object in a coordinate axis;

acquiring distance information between each other target object and each target object;

and determining a fourth vector of each target object according to the reverse angle between each target object and all other target objects in the coordinate axis and the distance information between each target object and all other target objects.

Optionally, the second vector determining module 1004 is further configured to:

determining at least one other target object of each target object within a preset radius;

obtaining a current vector of each other target object in the at least one other target object;

and determining a fifth vector of each target object according to the average value of the current vectors of all other target objects.

Optionally, the second vector determining module 1004 is further configured to:

multiplying the target moving speed of each other target object by a preset steering coefficient to obtain the steering moving speed of each other target object;

and determining a fifth vector of each target object according to the angle of the current vector of all other target objects and the average value of the steering moving speed.

Optionally, the third vector determining module 1006 is further configured to:

determining a third vector for each of the target objects based on a relationship between each of the target objects and a virtual object, wherein the virtual object forms an equilateral triangle with two other target objects that are closest to each of the target objects.

Optionally, the third vector determining module 1006 is further configured to:

acquiring an angle between each target object and the virtual object in a coordinate axis;

acquiring the current moving speed of each target object;

and determining a third vector of each target object according to the angle between each target object and the virtual object in the coordinate axis and the current moving speed of each target object.

According to the target object control device provided by the embodiment of the application, the moving speed and the moving angle of each target object to the target position, the distance between each target object and the like are controlled through the obtained three vectors of each target object, so that each target object can move smoothly without collision, the moving formation of all the target objects can be kept, and the moving reality of the target objects is improved.

The above is a schematic scheme of a target apparatus of the present embodiment. It should be noted that the technical solution of the target device and the technical solution of the target method belong to the same concept, and details that are not described in detail in the technical solution of the target device can be referred to the description of the technical solution of the target method.

Referring to FIG. 11, FIG. 11 illustrates a block diagram of a computing device 1100 provided in accordance with an embodiment of the present application. The components of the computing device 1100 include, but are not limited to, memory 1110 and a processor 1120. The processor 1120 is coupled to the memory 1110 via a bus 1130 and the database 1150 is used to store data.

The computing device 1100 also includes an access device 1140, the access device 1140 enabling the computing device 1100 to communicate via one or more networks 1060. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. The access device 1140 may include one or more of any type of network interface, e.g., a Network Interface Card (NIC), wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.

In one embodiment of the application, the above-described components of computing device 1100, as well as other components not shown in FIG. 11, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 11 is for purposes of example only and is not limiting as to the scope of the present application. Those skilled in the art may add or replace other components as desired.

Computing device 1100 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smartphone), wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 1100 can also be a mobile or stationary server.

Wherein, the processor 1120 is configured to execute the following computer-executable instructions, and the steps of the target object control method are realized when the processor 1120 executes the instructions.

The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the target object control method belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the target object control method.

An embodiment of the present application also provides a computer readable storage medium, which stores computer instructions, and the instructions are executed by a processor to implement the steps of the target object control method as described above.

The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the target object control method, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the target object control method.

The foregoing description of specific embodiments of the present application has been presented. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.

The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.

It should be noted that, for the sake of simplicity, the above-mentioned method embodiments are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.

In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.

The preferred embodiments of the present application disclosed above are intended only to aid in the explanation of the application. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the application and its practical applications, to thereby enable others skilled in the art to best understand and utilize the application. The application is limited only by the claims and their full scope and equivalents.

25页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:虚拟场景中虚拟对象的控制方法、装置及电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类