Control method, system and storage medium for virtual camera simulating displacement to achieve obstacle avoidance

By simulating the camera's obstacle detection and displacement algorithm, it solves the problem of inaccurate virtual camera control in front of obstacles, achieves smooth movement of the field of view and precise obstacle avoidance, and improves the virtual reality viewing experience.

CN118625814BActive Publication Date: 2024-10-01VSWORK NETWORK TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411095563.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-12
Publication Date
2024-10-01
Estimated Expiration
2044-08-12

AI Technical Summary

Technical Problem

The virtual camera's control is not precise enough when encountering obstacles, resulting in multiple movements and false detections in the viewing angle, affecting the user's viewing experience.

Method used

By copying a simulated camera, setting the edge point on the near clipping surface as the obstacle detection point, using ray detection and simulated displacement algorithms, dynamically adjust the position of the virtual camera to avoid obstacles and ensure smooth and accurate movement of the field of view.

Benefits of technology

It effectively avoids obstacles, reduces the sense of inconsistency caused by movement of the field of view, ensures that the user's perspective always sees the scene, avoids multiple position adjustments and false detections, and improves the viewing effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118625814B_ABST
    Figure CN118625814B_ABST
Patent Text Reader

Abstract

The present invention discloses a control method, system and storage medium for realizing obstacle avoidance by simulating displacement of a virtual camera, which belongs to the field of virtual and reality technology. The method includes: S1, calculating the target position of the virtual camera; S2, copying an identical virtual camera as a simulation camera; S3, performing obstacle detection, if no collision body is detected, the virtual camera is moved to the target position, if a collision body is detected, simulated displacement is performed, and the method is as follows: moving the simulated camera forward a dynamic distance L=D1+D2, D1 is the distance between the current position of the virtual camera and the collision body, and D2 is the width of the collision body along the forward direction; obstacle detection is continuously performed during the movement; if the collision body is always detected, the moving virtual camera to the dynamic distance L is obtained; if there is a result that the collision body is not detected, the moving virtual camera to the position of the distance D1 is obtained. The present invention uses a simulated camera to perform simulated displacement to find a position where the virtual camera is not blocked.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtual and reality technology, and in particular to a control method, system and storage medium for a virtual camera to simulate displacement and achieve obstacle avoidance. Background Art

[0002] Virtual reality technology (English name: Virtual Reality, abbreviated as VR) is a new practical technology developed in the 20th century. Virtual reality technology encompasses computers, electronic information, and simulation technology. Its basic implementation method is based on computer technology, using and integrating the latest developments of various high technologies such as three-dimensional graphics technology, multimedia technology, simulation technology, display technology, and servo technology. With the help of computers and other equipment, a realistic three-dimensional visual, tactile, olfactory and other sensory experiences are generated in the virtual world, so that people in the virtual world have an immersive feeling.

[0003] Virtual reality technology uses a virtual camera as the user's eyes. Through the images played by the virtual camera, the user can see the three-dimensional scene. The virtual camera is a movable camera. In the three-dimensional space, when the character moves, the camera following the character also moves. When the camera moves to an obstacle, it is blocked by the object, resulting in a black screen. The traditional technical method to solve the problem of camera occlusion is to displace the blocked camera so that the camera can avoid obstacles and continue to return to the pre-set position after leaving the obstacle. Since the range of the obstacle object cannot be accurately known, the camera cannot be moved to the position at one time, and multiple adjustments are required. This will result in that from the user's perspective, although the character has not moved, the perspective picture will appear to move multiple times, which is poor. In addition, when encountering some hollow obstacles, the camera is prone to misdetect the obstacles, resulting in the camera position adjustment being not accurate and reasonable. Summary of the invention

[0004] The purpose of the present invention is to solve the problem that the control of the above-mentioned virtual camera is not precise and reasonable when encountering obstacles, and to propose a control method, system and storage medium for virtual camera simulated displacement to achieve obstacle avoidance. The method has the advantages of selecting simulated camera simulated displacement, reducing the sense of incongruity of field of view movement, accurately avoiding obstacles, and better viewing effect.

[0005] In a first aspect, the present invention achieves the above-mentioned purpose through the following technical solutions, a control method for a virtual camera to simulate displacement to achieve obstacle avoidance, the method comprising the following steps:

[0006] S1, calculating the target position of the virtual camera, where the target position is the position of the virtual camera after following the user's character model at the current position;

[0007] S2, copying an identical virtual camera as a simulation camera, and setting several edge points on the near clipping surface of the simulation camera as obstacle detection points;

[0008] S3, performing obstacle detection, the obstacle detection method is as follows: emitting rays from the target position toward the obstacle detection point, if the ray does not detect a collision body, moving the virtual camera to the target position, if a collision body is detected, performing simulated displacement, and moving the virtual camera to the position after the simulated camera simulated displacement, the simulated displacement method is as follows:

[0009] A1. Move the simulated camera forward a dynamic distance L=D1+D2 in the direction of the ray, where D1 is the distance between the target position and the collision body, and D2 is the width of the collision body along the moving direction;

[0010] A2, continuously performing the obstacle detection while the simulated camera moves a distance D2;

[0011] A3. If a collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1;

[0012] A4. If there is a result that no collision body is detected, obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2.

[0013] Preferably, the method further includes setting the distance between the virtual camera and the character model to a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of the horizontal distance and the vertical distance is a fixed value, and setting the direction of the virtual camera to always point to the character model.

[0014] Preferably, the method for calculating the target position of the virtual camera is:

[0015] Get the position of the character model after moving;

[0016] And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

[0017] Preferably, the edge points for setting a plurality of edge points on the near clipping plane of the simulated camera as obstacle detection points are selected as four corner points of the upper left, upper right, lower left and lower right of the near clipping plane.

[0018] Preferably, the method also includes setting a spherical enclosing collision body that surrounds the virtual camera and takes the virtual camera as the center of the sphere, wherein the spherical enclosing collision body is used to detect a downward collision of the virtual camera. If a downward collision occurs, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body.

[0019] In a second aspect, the present invention achieves the above-mentioned purpose through the following technical solutions: a control system for a virtual camera to simulate displacement to achieve obstacle avoidance, the system comprising:

[0020] A target position calculation unit, used to calculate the target position of the virtual camera, wherein the target position is the position of the virtual camera after following the user's character model at the current position;

[0021] A simulated camera setting unit, used to copy an identical virtual camera at the current position of the virtual camera as a simulated camera, and set a number of edge points on the near clipping surface of the simulated camera as obstacle detection points;

[0022] The obstacle detection unit is used to perform obstacle detection. The obstacle detection method is as follows: emitting rays from the target position toward the obstacle detection point. If the ray does not detect a collision body, the virtual camera is moved to the target position. If a collision body is detected, simulated displacement is performed to move the virtual camera to the position after the simulated displacement of the simulated camera.

[0023] The simulation displacement unit is used to perform simulation displacement. The method of the simulation displacement is:

[0024] A1. Move the simulated camera forward a dynamic distance L=D1+D2 in the direction of the ray, where D1 is the distance between the target position and the collision body, and D2 is the width of the collision body along the moving direction;

[0025] A2, continuously performing the obstacle detection while the simulated camera moves a distance D2;

[0026] A3. If a collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1;

[0027] A4. If there is a result that no collision body is detected, obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2.

[0028] Preferably, the system also includes a virtual camera setting unit, which is used to set the distance between the virtual camera and the character model to a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of the horizontal distance and the vertical distance is a fixed value, and the direction of the virtual camera is set to always point to the character model.

[0029] Preferably, the method by which the target position calculation unit calculates the target position of the virtual camera is:

[0030] Get the position of the character model after moving;

[0031] And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

[0032] Preferably, the system also includes a virtual camera height adjustment unit, which is used to set a spherical enclosing collision body that surrounds the virtual camera and takes the virtual camera as the center of the sphere, and the spherical enclosing collision body is used to detect a downward collision of the virtual camera. If a downward collision occurs, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body.

[0033] In a third aspect, the present invention achieves the above-mentioned purpose through the following technical scheme: a storage medium having a computer program stored thereon, which, when executed by a processor, implements the control method of achieving obstacle avoidance by simulating displacement of a virtual camera as described in the first aspect.

[0034] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention replicates a simulated camera to be used as a mobile simulation of a virtual camera, and utilizes the simulated displacement of the simulated camera to detect the occlusion of obstacles during movement, thereby effectively avoiding obstacles and synchronizing the final appropriate position to the virtual camera. In this way, the adjusted virtual camera cannot be blocked by obstacles, ensuring that the user's perspective can always see the scene picture, and there is no need for the virtual camera to move multiple times during the obstacle detection process, ensuring that the perspective moves smoothly without a sense of frustration, and that the perspective will not move back and forth and cause jitter when some translucent obstacles block the lens perspective. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 This is a flow chart of the control method of the virtual camera of the present invention for simulating displacement to achieve obstacle avoidance.

[0036] Figure 2 It is a schematic diagram of the process of the virtual camera of the present invention being blocked by an obstacle.

[0037] Figure 3 The figure is a flow chart of the method for simulating displacement of the present invention.

[0038] Figure 4 A schematic diagram of the control system composition of the virtual camera of the present invention for simulating displacement to achieve obstacle avoidance. DETAILED DESCRIPTION

[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0040] Example 1

[0041] like Figure 1 As shown, a control method for a virtual camera to simulate displacement to achieve obstacle avoidance includes the following steps:

[0042] Step S1, calculate the target position of the virtual camera, the target position is the point where the virtual camera moves after following the user's character model at the current position. In the virtual scene, we know that the virtual camera is used as the "eyes" of the user, and the scene can be seen through the virtual camera. In order to provide the user with an immersive experience, the virtual camera is usually bound to the character model, and is generally set 2 meters behind and 1 meter above the user's character model. Through the tilted downward angle, the user can see the scene while also observing the shape of the character model. Since the two are in a bound state, when the user controls the character model to move, the virtual camera also moves with the character model. The target position here is the position of the virtual camera after following the character model. The character's walking is regarded as a series of movements of the virtual camera, which are combined into a continuous moving picture in this way. The target position is calculated in order to obtain the original moving point of the virtual camera. The above-mentioned movement relationship between the virtual camera and the character model is an ideal relationship, such as Figure 2 As shown, since the virtual camera is behind the character model, when there is an obstacle behind the character model, such as the wall in the figure, the virtual camera will be blocked by the wall, resulting in a black screen in the lens, which is obviously not suitable for the use of virtual scenes. Therefore, although the target position is obtained, it is still necessary to determine whether to select the target position as the landing point of the virtual camera. The specific determination is described in detail in the steps below.

[0043] Step S2, copy an identical virtual camera as the simulation camera, and set several edge points on the near clipping plane of the simulation camera as obstacle detection points. In this step, a camera is selected to be copied as the simulation camera to replace the virtual camera for obstacle detection. The copied simulation camera only has a near clipping plane consistent with the virtual camera, and does not have the function of synchronizing the virtual camera screen. This is to avoid screen overlap. The near clipping plane of the camera is a plane perpendicular to the viewing cone intercepted on the camera's viewing cone. The size of this plane is the size of the visual field seen by the user. Therefore, by selecting the edge points on this near clipping plane as obstacle detection points, it can be detected whether the obstacle will block the user's visual field. The simulation camera is used to be placed at the target position for use to determine whether there is an obstacle in front of the target position.

[0044] Step S3, obstacle detection is performed. The obstacle detection method is as follows: emitting rays from the target position toward the obstacle detection point. If the ray does not detect a collision body, the virtual camera is moved to the target position. If a collision body is detected, a simulated displacement is performed to move the virtual camera to the position after the simulated displacement of the simulated camera. In this step, the simulated camera performs obstacle detection on the near clipping plane direction at the target position. The obstacle detection is to detect whether the near clipping plane of the simulated camera at the target position will be blocked by an obstacle. Since the near clipping plane of the simulated camera is consistent with the virtual camera, if there is an obstruction, the field of view of the virtual camera is also blocked. Otherwise, the field of view of the virtual camera will not be blocked. The detection method is to determine whether there is a collision body by emitting rays from the simulated camera at the target position toward the obstacle detection point. If no collision body is detected, it means that the virtual camera cannot be blocked at the target position. At this time, the virtual camera is modulated to the target position to complete the advancement of the field of view. However, if there is a collision body, it is necessary to perform displacement at the original target position to ensure that the field of view of the virtual camera is not blocked.

[0045] like Figure 3 As shown, it is a flow chart of the steps of simulating displacement, and the method of simulating displacement is as follows:

[0046] Step A1, move the simulated camera forward a dynamic distance L=D1+D2 in the direction of the ray, wherein D1 is the distance between the target position and the collision body, and D2 is the width of the collision body along the direction of advancement. In this step, the position and model outline of the collision body can be obtained through the above-mentioned ray detection. After the model outline is known, the width of the collision body along the direction of advancement of the model camera can be calculated, and the dynamic distance is calculated using the above-mentioned data, and then the simulated camera moves this dynamic distance. The dynamic distance is selected here instead of a fixed distance because the distance between the simulated camera and the collision body is variable, and needs to be determined according to the distribution of the collision body and the position of the character in the actual scene, which is more realistic.

[0047] Step A2, the obstacle detection is continuously performed during the process of the simulated camera moving a distance of D2. Step A1 also needs to perform continuous obstacle detection during the simulated displacement process. This is to exclude the situation that the collision body is not all a regular model. When encountering an irregular model, such as a hollow wall, the obstacle detection may detect the collision body at the target position (the solid part of the hollow wall). However, during the movement, since the position of the simulated camera changes, the angle of the ray emitted toward the obstacle detection point near the clipping surface also changes, and it is easy to fail to detect the collision body (the hollow part of the hollow wall). In the hollow part, it actually does not affect the field of view of the virtual camera, but the virtual camera is more closely aligned with the positional relationship with the character model at this hollow position. Therefore, it is also necessary to consider the occurrence of such irregular collision bodies. Therefore, the following judgment is required for the irregular collision bodies mentioned in this step.

[0048] Step A3, if the collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1. If the collision body is always detected, as described in step A2, the collision body is always monitored, which means that the collision body is a model of a solid structure. No matter where the simulated camera is at this dynamic distance L, its line of sight will be blocked. Therefore, the position after moving the complete dynamic distance L is directly selected as the position of the virtual camera, which can ensure that the virtual camera will not be blocked.

[0049] Step A4, if there is a result that the collision body is not detected, then obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2. If the collision body is not detected, as mentioned in step A2, the collision body is a hollow structure, so even if the virtual camera is at the position of the collision body, it will not be blocked by the field of view, so the position after moving the distance D1 is selected as the position of the virtual camera.

[0050] The method also includes setting the distance between the virtual camera and the character model as a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of which is a fixed value, and setting the direction of the virtual camera to always point to the character model. In step S1, it is also mentioned that the virtual camera and the character model are bound, so by setting the default distance, the virtual camera moves with the character model while it is walking, changing the picture in the field of view. Another advantage of setting the default distance is that if the virtual camera is displaced with the target position as a reference, the horizontal distance between the virtual camera and the character model will actually be shortened, and at this time the lens may be too close to the character model and will be partially blocked by the character model, thus affecting the display effect. Since the sum of the horizontal distance and the vertical distance is a fixed value, when the horizontal distance is reduced, the vertical distance will increase, and the virtual camera will be higher than in normal conditions, so that it will not be blocked by the character model, but also can be away from the blocked field of view for a better view.

[0051] In step S1, it is mentioned that the target position is the landing point of the virtual camera in the absence of occlusion, and the virtual camera is bound to the character model. Therefore, how to calculate the target position also needs to be related to the character model. The method for calculating the target position of the virtual camera is:

[0052] Get the position of the character model after moving;

[0053] And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

[0054] In step S2, it can be seen that the near clipping plane is a plane, and the size of the plane is the user's field of view. In order to avoid omissions in obstacle detection, the closer to the edge of this plane, the more accurate the detection. The edge points of the near clipping plane of the simulated camera are set as the edge points of obstacle detection points, which are selected as the upper left, upper right, lower left and lower right corner points of the near clipping plane. The near clipping plane is vertically intercepted on the viewing frustum, so the near clipping plane has a rectangular structure, and the upper left, upper right, lower left and lower right corner points are exactly the edgemost points of the rectangular near clipping plane.

[0055] The method also includes setting a spherical surrounding collision body surrounding the virtual camera and taking the virtual camera as the center of the sphere, wherein the spherical surrounding collision body is used to detect a collision below the virtual camera, and if there is a collision below, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body. In the process of adjusting the position of the virtual camera, if there is an obstacle below, it will also affect the synchronized field of view of the virtual camera, so a spherical surrounding collision body surrounding the virtual camera is set here, and the spherical surrounding collision body is used to detect whether there is an obstacle below, so that obstacle avoidance is more comprehensive when controlling the virtual camera.

[0056] Example 2

[0057] like Figure 4 As shown, a control system for a virtual camera to simulate displacement to achieve obstacle avoidance, the system includes:

[0058] A target position calculation unit, used to calculate the target position of the virtual camera, wherein the target position is the position of the virtual camera after following the user's character model at the current position;

[0059] A simulated camera setting unit, used to copy an identical virtual camera at the current position of the virtual camera as a simulated camera, and set a number of edge points on the near clipping surface of the simulated camera as obstacle detection points;

[0060] An obstacle detection unit is used to perform obstacle detection. The obstacle detection method is as follows: emitting rays in the direction of the target position with the detection point as the origin. If the ray does not detect a collision body, the virtual camera is moved to the target position. If a collision body is detected, a simulated displacement is performed.

[0061] The simulation displacement unit is used to perform simulation displacement, and the method of the simulation displacement is:

[0062] A1. Move the simulated camera toward the target position by a dynamic distance L=D1+D2, where D1 is the dynamic distance between the current position of the virtual camera and the collision body, and D2 is the width of the collision body along the moving direction;

[0063] A2, continuously performing the obstacle detection while the simulated camera moves a distance D2;

[0064] A3. If a collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1;

[0065] A4. If there is a result that no collision body is detected, obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2.

[0066] The system also includes a virtual camera setting unit, which is used to set the distance between the virtual camera and the character model to a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of the horizontal distance and the vertical distance is a fixed value, and the virtual camera is set to always point to the character model.

[0067] The method for the target position calculation unit to calculate the target position of the virtual camera is:

[0068] Get the position of the character model after moving;

[0069] And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

[0070] The system also includes a virtual camera height adjustment unit, which is used to set a spherical surrounding collision body surrounding the virtual camera and taking the virtual camera as the center of the sphere. The spherical surrounding collision body is used to detect a downward collision of the virtual camera. If a downward collision exists, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body.

[0071] Embodiment 2 is essentially the same as Embodiment 1, so the specific working principles of each unit will not be described in detail.

[0072] Example 3

[0073] This embodiment proposes a storage medium, which includes a program storage area and a data storage area, wherein the program storage area can store an operating system and programs required for running instant messaging functions, etc.; the data storage area can store various instant messaging information and operation instruction sets, etc. The computer program is stored in the program storage area, and when the computer program is executed by the processor, the control method of simulating displacement of a virtual camera to achieve obstacle avoidance as described in Example 1 is implemented. The processor may include one or more central processing units, or a digital processing unit, etc.

[0074] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, the embodiments should be considered exemplary and non-restrictive in all respects, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims be included in the present invention.

[0075] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.

Claims

1. A control method for virtual camera to achieve obstacle avoidance by simulating displacement, characterized in that: The method comprises the following steps: S1, calculating the target position of the virtual camera, where the target position is the position of the virtual camera after following the user's character model at the current position; S2, copying an identical virtual camera as a simulation camera, and setting several edge points on the near clipping surface of the simulation camera as obstacle detection points; S3, performing obstacle detection, the obstacle detection method is as follows: emitting rays from the target position toward the obstacle detection point, if the ray does not detect a collision body, moving the virtual camera to the target position, if a collision body is detected, performing simulated displacement, and moving the virtual camera to the position after the simulated camera is simulated displaced, the simulated displacement method is as follows: A1. Move the simulated camera forward a dynamic distance L=D1+D2 in the direction of the ray, where D1 is the distance between the target position and the collision body, and D2 is the width of the collision body along the moving direction; A2, continuously performing the obstacle detection while the simulated camera moves a distance D2; A3. If a collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1; A4. If there is a result that no collision body is detected, obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2.

2. The control method for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 1, characterized in that: The method also includes setting the distance between the virtual camera and the character model as a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of the horizontal distance and the vertical distance is a fixed value, and setting the direction of the virtual camera to always point to the character model.

3. The control method for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 2, characterized in that: The method for calculating the target position of the virtual camera is: Get the position of the character model after moving; And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

4. The control method for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 1, characterized in that: The edge points for setting a plurality of edge points on the near clipping plane of the simulated camera as obstacle detection points are selected as four corner points of the upper left, upper right, lower left and lower right of the near clipping plane.

5. The control method for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 1, characterized in that: The method also includes setting a spherical surrounding collision body surrounding the virtual camera and taking the virtual camera as the center of the sphere, wherein the spherical surrounding collision body is used to detect a downward collision of the virtual camera. If a downward collision exists, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body.

6. A control system for a virtual camera to simulate displacement and achieve obstacle avoidance, characterized in that: The system includes: A target position calculation unit, used to calculate the target position of the virtual camera, wherein the target position is the position of the virtual camera after following the user's character model at the current position; A simulation camera setting unit, used for copying an identical virtual camera as a simulation camera, and setting a number of edge points on a near clipping surface of the simulation camera as obstacle detection points; The obstacle detection unit is used to perform obstacle detection. The obstacle detection method is as follows: emitting rays from the target position toward the obstacle detection point. If the ray does not detect a collision body, the virtual camera is moved to the target position. If a collision body is detected, simulated displacement is performed to move the virtual camera to the position after the simulated displacement of the simulated camera. The simulation displacement unit is used to perform simulation displacement. The method of the simulation displacement is: A1. Move the simulated camera forward a dynamic distance L=D1+D2 in the direction of the ray, where D1 is the distance between the target position and the collision body, and D2 is the width of the collision body along the moving direction; A2, continuously performing the obstacle detection while the simulated camera moves a distance D2; A3. If a collision body is always detected, the position P1 of the simulated camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the position P1; A4. If there is a result that no collision body is detected, obtain the position P2 of the simulated camera after moving the distance D1, and move the virtual camera to the position P2.

7. The control system for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 6, characterized in that: The system also includes a virtual camera setting unit, which is used to set the distance between the virtual camera and the character model to a default distance, wherein the default distance includes a horizontal distance and a vertical distance, the sum of the horizontal distance and the vertical distance is a fixed value, and the virtual camera is set to always point to the character model.

8. The control system for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 7, characterized in that: The method for the target position calculation unit to calculate the target position of the virtual camera is: Get the position of the character model after moving; And calculate the position of the virtual camera in the absence of obstacles based on the default distance and the gravity direction of the character model.

9. The control system for realizing obstacle avoidance by simulating displacement of a virtual camera according to claim 6, characterized in that: The system also includes a virtual camera height adjustment unit, which is used to set a spherical surrounding collision body surrounding the virtual camera and taking the virtual camera as the center of the sphere. The spherical surrounding collision body is used to detect a downward collision of the virtual camera. If a downward collision exists, the position of the collision body is calculated and the height of the virtual camera is adjusted upward to the top of the collision body.

10. A storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the control method for realizing obstacle avoidance by simulating displacement of a virtual camera as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Method and system for automated camera collision and composition preservation

    CA3056269A1

  • Virtual compound-eye camera system for acquiring three-dimensional scene of building satisfying time-space consistency and working method thereof

    CN109118585A

  • Method and device for controlling virtual camera in virtual scene and electronic equipment

    CN116764208A