Control method and system for obstacle avoidance of virtual camera by means of simulated displacement, and storage medium
By replicating a virtual camera into a simulated camera and performing obstacle detection, and calculating dynamic distance to simulate displacement, the problem of virtual cameras being unable to accurately judge obstacles is solved, achieving precise obstacle avoidance and stable field of view display.
Patent Information
- Application Number
- PCT/CN2025/097342
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-08-12
- Filing Date
- 2025-05-27
- Publication Date
- 2026-02-19
AI Technical Summary
In existing technologies, virtual cameras cannot accurately determine the range of obstacles when they encounter them, resulting in inaccurate camera position adjustments, multiple shifts in the viewpoint, and a tendency to falsely detect hollow obstacles, which affects the user experience.
By replicating a virtual camera as a simulated camera, setting the edge points near the clipping surface as obstacle detection points, emitting rays to detect obstacles, and simulating displacement when a collision is detected, the dynamic distance is calculated for precise obstacle avoidance.
It enables precise obstacle avoidance for the virtual camera when encountering obstacles, avoids field of view obstruction, and improves the continuity of user experience and the stability of the viewing angle.
Smart Images

Figure CN2025097342_19022026_PF_FP_ABST
Abstract
Description
Control method and system for obstacle avoidance by virtual camera simulation displacement and storage medium
[0001] Cross-reference to Related Applications
[0002] The present disclosure claims priority to the Chinese patent application No. 2024110955633, filed on August 12, 2024, and entitled "Control method and system for obstacle avoidance by virtual camera simulation displacement and storage medium", the entire content of which is incorporated herein by reference. TECHNICAL FIELD
[0003] The present disclosure relates to the field of virtual and real technologies, and in particular, to a control method and system for obstacle avoidance by virtual camera simulation displacement and a storage medium. BACKGROUND
[0004] Virtual reality technology (English name: Virtual Reality, abbreviated as VR) is a brand-new practical technology developed in the 20th century. Virtual reality technology includes computer, electronic information, simulation technology, and its basic implementation is mainly based on computer technology, using and integrating three-dimensional graphics technology, multimedia technology, simulation technology, display technology, servo technology, and other latest developments of various high-techs, and generating a virtual world with realistic three-dimensional vision, touch, smell, and other sensory experiences with the help of computers and other devices, so that people in the virtual world have a sense of being there.
[0005] Virtual reality technology uses a virtual camera as the user's eyes, and the user watches a three-dimensional scene through the screen played by the virtual camera. The virtual camera is a movable camera, and when the character moves in the three-dimensional space, 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 way to solve the problem of camera being blocked is to displace the blocked camera to avoid the obstacle, and to continue to restore 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 therefore needs to be adjusted multiple times, which will cause the visual angle to move multiple times from the user's perspective, although the character does not move, the visual angle picture will move multiple times, which is poor in visual perception, and when encountering some hollow obstacles, the camera is easy to misdetect the obstacle, resulting in inaccurate and unreasonable adjustment of the camera position. SUMMARY
[0006] According to various embodiments of the present disclosure, a control method for obstacle avoidance by virtual camera simulation displacement is provided, which includes the following steps:
[0007] S1, calculate a target position of the virtual camera, the target position being a point position of the virtual camera after moving following the character model of the user at a current position;
[0008] S2, copy a same virtual camera as a simulation camera, and set a plurality of edge points on a near clipping plane of the simulation camera as obstacle detection points;
[0009] S3, perform obstacle detection, the performing obstacle detection comprising: emitting a ray from the target position to the obstacle detection points, if the ray does not detect a collision body, moving the virtual camera to the target position, if the collision body is detected, performing simulation displacement, and moving the virtual camera to a position after the simulation displacement of the simulation camera, the moving the virtual camera to the position after the simulation displacement of the simulation camera comprising:
[0010] A1, moving the simulation camera by a dynamic distance in a direction of the ray, the dynamic distance being a first distance plus a second distance, wherein the first distance is a distance between the target position and the collision body, and the second distance is a width of the collision body along the direction of the movement;
[0011] A2, continuously performing obstacle detection during the moving of the simulation camera by the second distance;
[0012] A3, if the collision body is always detected, obtaining a first position of the simulation camera after the moving by the dynamic distance, and moving the virtual camera to the first position;
[0013] A4, if there is a result of not detecting the collision body, obtaining a second position of the simulation camera after the moving by the first distance, and moving the virtual camera to the second position.
[0014] According to various embodiments of the present disclosure, a control system for implementing simulation displacement of a virtual camera to avoid obstacles is also provided, comprising:
[0015] a target position calculation unit configured to calculate a target position of the virtual camera, the target position being a point position of the virtual camera after moving following a character model of a user at a current position;
[0016] a simulation camera setting unit configured to copy a same virtual camera as a simulation camera at the current position of the virtual camera, and set a plurality of edge points on a near clipping plane of the simulation camera as obstacle detection points;
[0017] an obstacle detection unit configured to perform obstacle detection, the performing obstacle detection comprising: emitting a ray from the target position to the obstacle detection points, if the ray does not detect a collision body, moving the virtual camera to the target position, if the collision body is detected, performing simulation displacement, and moving the virtual camera to a position after the simulation displacement of the simulation camera;
[0018] analog displacement unit configured to perform analog displacement, the performing analog displacement comprising:
[0019] A1, moving the analog camera by a dynamic distance towards the ray direction, the dynamic distance being a first distance plus a second distance, wherein the first distance is a distance between the target position and the collision body, and the second distance is a width of the collision body along the moving direction;
[0020] A2, continuously performing obstacle detection during the moving of the analog camera by the second distance;
[0021] A3, if the collision body is detected all the time, obtaining a first position of the analog camera after the moving of the dynamic distance, and moving the virtual camera to the first position;
[0022] A4, if there is a result that the collision body is not detected, obtaining a second position of the analog camera after the moving of the first distance, and moving the virtual camera to the second position.
[0023] According to various embodiments of the present disclosure, a storage medium is also provided, and the storage medium has a computer program stored thereon, and the computer program, when executed by a processor, implements the control method for virtual camera analog displacement to achieve obstacle avoidance as described in some of the foregoing embodiments.
[0024] Details of one or more embodiments of the present disclosure are presented in the following drawings and description. Other features, objects, and advantages of the present disclosure will become apparent from the description, drawings, and claims. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or in the prior art, brief introductions will be given to the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only embodiments of the present disclosure, and other drawings can also be obtained by those skilled in the art without any creative effort based on the disclosed drawings.
[0026] FIG. 1 is a flowchart of a control method for virtual camera analog displacement to achieve obstacle avoidance according to some embodiments.
[0027] FIG. 2 is a schematic diagram of a process in which a virtual camera is blocked by an obstacle in a control method for virtual camera analog displacement to achieve obstacle avoidance according to some embodiments.
[0028] FIG. 3 is a flowchart of a method of analog displacement in a control method for virtual camera analog displacement to achieve obstacle avoidance according to some embodiments.
[0029] FIG. 4 is a schematic diagram of a control system for virtual camera analog displacement to achieve obstacle avoidance according to some embodiments. DETAILED DESCRIPTION
[0030] The technical solutions of the embodiments of the present disclosure will be described clearly and completely below in combination with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present disclosure.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present disclosure belongs. The terminology used in the description of the present disclosure herein only for the purpose of describing the specific embodiments of the present disclosure, and is not intended to limit the present disclosure.
[0032] It should be noted that when an element is considered to be "connected" to another element, it can be directly connected to the other element, or connected to the other element through a central element. In addition, "connected" in the following embodiments should be understood as "electrically connected", "communicatively connected" and the like if there is transmission of electrical signals or data between the connected objects.
[0033] As used herein, the singular forms "a", "an" and "the" can also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms "comprise / comprising" or "have / having" specify the presence of stated features, integers, steps, operations, components, parts, or combinations thereof, but do not exclude the presence or addition of one or more other features, integers, steps, operations, components, parts, or combinations thereof. At the same time, the term "and / or" used in the specification includes any and all combinations of the related listed items.
[0034] Please understand in combination with FIG. 1, in some embodiments, a virtual camera simulation displacement obstacle avoidance control method is provided. The virtual camera simulation displacement obstacle avoidance control method includes steps S1-S3.
[0035] Step S1, calculate the target position of the virtual camera. The target position of the virtual camera is the point of the virtual camera after following the user's character model to move. In the virtual scene, we know that the virtual camera is used as the user's "eyes", through which the user can see the scene picture. In order to provide the user with a sense of being on the scene, the virtual camera is usually bound to the character model. The virtual camera can be set 2 meters behind the user's character model and 1 meter above the user's character model, and the user can view the form of the character model through the angle of inclination. 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, and the target position is the position of the virtual camera after following the character model to move. The character walking can be regarded as a movement of the virtual camera, and the continuous moving picture is composed in this way. The target position is calculated to obtain the original moving point of the virtual camera. The above-mentioned moving relationship between the virtual camera and the character model is an ideal state, please understand in combination with Figure 2. Since the virtual camera is behind the character model, when there is an obstacle behind the character model (for example, the wall in Figure 2), the virtual camera will be blocked by the wall, resulting in a black screen in the picture. This obviously cannot meet the use of the virtual scene, so although the target position is obtained, it is still necessary to judge whether to select the target position as the landing point of the virtual camera, and the specific judgment method is described in detail in the following steps.
[0036] Step S2, copy a same virtual camera as a simulation camera, and set a plurality of edge points on the near clipping plane of the simulation camera as obstacle detection points. In this step, a camera can be selected as a simulation camera to replace the virtual camera for obstacle detection. The simulation camera obtained by copying only has a near clipping plane consistent with the virtual camera, and does not have the function of synchronizing the picture of the virtual camera, which is to avoid the occurrence of picture overlap. The near clipping plane of the camera is a plane perpendicular to the view pyramid of the camera, and the size of the plane is the size of the field of view picture seen by the user. Therefore, the edge points on the near clipping plane can be selected as obstacle detection points to detect whether the obstacle will block the user's field of view picture. The simulation camera is placed on the target position to judge whether there is an obstacle in front of the target position.
[0037] Step S3, obstacle detection is performed. The obstacle detection method is as follows: a ray is emitted 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 simulation displacement is performed, and the virtual camera is moved to the position of the simulation camera after the simulation displacement. In this step, the simulation camera performs obstacle detection on the distance in the direction of the near clipping plane at the target position. The obstacle detection is to detect whether the near clipping plane is blocked by an obstacle when the simulation camera is at the target position. Since the near clipping plane of the simulation camera is consistent with the virtual camera, if there is blocking, the field of view of the virtual camera is also blocked; if there is no blocking, the field of view of the virtual camera is not blocked. The detection method is to set the simulation camera at the target position, and emit a ray toward the obstacle detection point to determine whether there is a collision body. 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, and the advance of the field of view picture is completed; if there is a collision body, a displacement needs to be performed at the original target position to ensure that the field of view of the virtual camera is not blocked.
[0038] Please understand in combination with FIG. 3, which is a step flow chart of simulation displacement. The simulation displacement method includes steps A1-A4.
[0039] Step A1, the simulation camera is moved to advance a dynamic distance L in the direction of the ray, wherein the dynamic distance L=D1+D2, D1 represents a first distance, which is the distance between the target position and the collision body, and D2 represents a second distance, which is the width of the collision body in the advancing direction. In this step, the position and model contour of the collision body can be obtained through the above-mentioned ray detection, and after the model contour is known, the width of the collision body in the advancing direction of the model camera can be calculated. The dynamic distance is calculated using the above-mentioned data, and then the simulation camera is moved by the dynamic distance. The dynamic distance is selected instead of a fixed distance because the distance between the simulation camera and the collision body is variable, and needs to be determined according to the distribution of the collision body in the actual scene and the position of the role, which is more realistic.
[0040] Step A2, the obstacle detection is continued during the process of simulating the camera moving the second distance D2, and step Al also needs to continue the obstacle detection during the process of simulating the displacement, so as to exclude the case that the collision body is not a regular model. When an irregular model is encountered (such as a hollow wall), it is possible that the obstacle detection can detect the collision body (the solid part of the hollow wall) at the target position, but during the movement, since the position of the simulation camera changes, the angle of the ray emitted towards the obstacle detection point of the near clipping plane also changes, and it is easy to appear that the collision body cannot be detected (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 close to the position relationship with the character model in this hollow part, so the case of the irregular collision body also needs to be considered, and therefore the irregular collision body mentioned in this step also needs to be judged as follows.
[0041] Step A3, if the collision body is always detected, the first position P1 of the simulation camera after moving the dynamic distance L is obtained, and the virtual camera is moved to the first position P1. If the collision body is always detected, as described in step A2, the collision body is a model with solid structure, no matter which position of the simulation camera in the dynamic distance L is, the view will be blocked. The position after moving the complete dynamic distance L can be directly selected as the position of the virtual camera, so as to ensure that the virtual camera will not be blocked.
[0042] Step A4, if there is a result that the collision body is not detected, the second position P2 of the simulation camera after moving the first distance D1 is obtained, and the virtual camera is moved to the second position P2. If there is a case that the collision body is not detected, as described in step A2, the collision body is a structure with hollow, so even if the virtual camera is at the position of the collision body, the virtual camera will not be blocked by the view, so the position after moving the first distance D1 is selected as the position of the virtual camera.
[0043] In some embodiments, the control method for obstacle avoidance by simulating displacement of the virtual camera further comprises: setting a distance between the virtual camera and the character model as a default distance. The default distance comprises a horizontal distance and a vertical distance, and the sum of the horizontal distance and the vertical distance is a fixed value. The orientation of the virtual camera is always directed to the character model. In step S1, it is also mentioned that the virtual camera is bound to the character model, so the default distance can be set to make the virtual camera move with the character model during walking, thereby changing the picture in the field of view. There is another advantage of setting the default distance. If the virtual camera is displaced with the target position as the 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 be partially blocked by the character model, thereby affecting the display effect. Since the sum of the horizontal distance and the vertical distance is a fixed value, when the horizontal distance is shortened, the vertical distance will be increased, and the virtual camera will be higher than in the normal condition. In this way, the virtual camera will not be blocked by the character model, but will be away from the block, and the field of view will be better.
[0044] For example, in step S1, it is mentioned that the target position is the landing point of the virtual camera in the case of no obstruction, and the virtual camera is bound to the character model, so how to determine the target position also needs to be related to the character model. The method for determining the target position of the virtual camera comprises: obtaining the position of the character model after moving; and calculating the position point of the virtual camera in the case of no obstacle according to the default distance and the gravity direction of the character model.
[0045] For example, in step S2, it is known that the near clipping plane is a plane, and the size of the plane is the field of view range of the user. In order to avoid omission in obstacle detection, the closer to the edge of the plane, the more accurate the detection. Set several edge points on the near clipping plane of the simulated camera as edge points of the obstacle detection points. The edge points of the obstacle detection points can be selected as the four corner points of the near clipping plane, i.e. the upper left corner, the upper right corner, the lower left corner and the lower right corner. Since the near clipping plane is vertically cut on the frustum, the near clipping plane can be set as a rectangular structure, and the four corner points are the most edge points of the rectangular near clipping plane.
[0046] In some embodiments, the control method for obstacle avoidance by simulating displacement of the virtual camera further comprises: setting 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 the collision below the virtual camera. 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. During the adjustment of the position of the virtual camera, if there is an obstacle below, it will also affect the synchronous field of view picture of the virtual camera, so here the spherical surrounding collision body surrounding the virtual camera is set to detect whether there is an obstacle below through the spherical surrounding collision body. In this way, the virtual camera is controlled more comprehensively when avoiding obstacles.
[0047] Please understand in combination with Figure 4, some embodiments of the present disclosure also provide a virtual camera simulation displacement obstacle avoidance control system for implementing the virtual camera simulation displacement obstacle avoidance control method described in some of the foregoing embodiments. The virtual camera simulation displacement obstacle avoidance control system includes: a target position calculation unit 10, a simulation camera setting unit 20, an obstacle detection unit 30, and a simulation displacement unit 40. The target position calculation unit 10 is configured to calculate the target position of the virtual camera, which is the point position of the virtual camera after moving following the user's character model at the current position; the simulation camera setting unit 20 is configured to copy a same virtual camera as a simulation camera at the current position of the virtual camera, and set a plurality of edge points on the near clipping plane of the simulation camera as obstacle detection points; the obstacle detection unit 30 is configured to perform obstacle detection, and the obstacle detection method includes: emitting a ray from the detection point to the target position direction, if the ray does not detect a collision body, moving the virtual camera to the target position, if a collision body is detected, performing simulation displacement; the simulation displacement unit 40 is configured to perform simulation displacement.
[0048] For example, the simulation displacement includes:
[0049] A1, moving the simulation camera to advance a dynamic distance L towards the target position, the dynamic distance L being a first distance D1 plus a second distance D2, i.e. L = D1 + D2, wherein the first distance D1 is the dynamic distance between the current position of the virtual camera and the collision body, and the second distance D2 is the width of the collision body along the advancing direction;
[0050] A2, continuously performing the obstacle detection during the movement of the simulation camera by the second distance D2;
[0051] A3, if the collision body is always detected, obtaining a first position P1 of the simulation camera after moving the dynamic distance L, and moving the virtual camera to the first position P1;
[0052] A4, if there is a result of not detecting the collision body, obtaining a second position P2 of the simulation camera after moving the first distance D1, and moving the virtual camera to the second position P2.
[0053] In some embodiments, the virtual camera simulation displacement obstacle avoidance control system further includes a virtual camera setting unit 50. The virtual camera setting unit 50 is configured to set the distance between the virtual camera and the character model to a default distance, the default distance including a lateral distance and a longitudinal distance, the sum of the lateral distance and the longitudinal distance being a fixed value, and to set the orientation of the virtual camera to always point towards the character model.
[0054] For example, the target position calculation unit calculates the target position of the virtual camera in the following manner: obtaining the position of the character model after movement; and calculating the position of the virtual camera in the absence of obstacles according to a default distance and a gravity direction of the character model.
[0055] In some embodiments, the control system for obstacle avoidance by virtual camera simulation of displacement further comprises a virtual camera height adjustment unit 60. The virtual camera height adjustment unit 60 is configured to set a spherical enclosing collision body surrounding the virtual camera and taking the virtual camera as the center of the sphere. The spherical enclosing collision body is configured to detect whether there is a collision below the virtual camera, and if there is a collision below the virtual camera, 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.
[0056] The control system for obstacle avoidance by virtual camera simulation of displacement also has the technical principles of the control method for obstacle avoidance by virtual camera simulation of displacement described in some of the foregoing embodiments, and the details are not described here.
[0057] In some embodiments, the disclosure also provides a storage medium, which comprises a program storage area and a data storage area. 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 sets of operation instructions, etc. The computer program is stored in the program storage area, and when the computer program is executed by the processor, the control method for obstacle avoidance by virtual camera simulation of displacement described in some of the foregoing embodiments of the disclosure is implemented. The processor can include one or more central processing units or digital processing units, etc.
[0058] It should be understood that, unless otherwise explicitly specified herein, the execution of the steps described is not strictly limited in sequence, and the steps can be executed in other sequences. Moreover, at least a part of the steps described can include multiple sub-steps or multiple stages, which do not necessarily be executed at the same time, but can be executed at different times, and the execution sequence of the sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with other steps or sub-steps or stages of other steps.
[0059] Each of the embodiments in the specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be mutually referred to.
[0060] The technical features of the above-described embodiments can be combined in any manner. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described, but as long as the combinations of the technical features do not contradict, they should be considered as within the scope of the disclosure.
[0061] The above-described embodiments only express several implementation manners of the present disclosure, the description is relatively specific and detailed, but it cannot be understood as a limitation on the patent scope. It should be noted that, for those skilled in the art, without departing from the concept of the present disclosure, several modifications and improvements can be made, which are all within the protection scope of the present disclosure. Therefore, the protection scope of the patent of the present disclosure should be subject to the appended claims.
Claims
1. A control method for virtual camera simulation displacement to achieve obstacle avoidance, comprising the following steps: S1, calculating a target position of a virtual camera, the target position being a point position of the virtual camera after moving following a character model of a user at a current position; S2, copying a same virtual camera as a simulation camera, and setting a plurality of edge points on a near clipping plane of the simulation camera as obstacle detection points; S3, performing obstacle detection, the performing obstacle detection comprising: emitting a ray from the target position toward the obstacle detection points, if no collision body is detected by the ray, moving the virtual camera to the target position; if a collision body is detected, performing simulation displacement, and moving the virtual camera to a position after the simulation displacement of the simulation camera, the moving the virtual camera to the position after the simulation displacement of the simulation camera comprising: A1, moving the simulation camera forward by a dynamic distance in a direction of the ray, the dynamic distance being a first distance plus a second distance, wherein the first distance is a distance between the target position and the collision body, and the second distance is a width of the collision body along the forward direction; A2, continuously performing the obstacle detection during the moving of the simulation camera by the second distance; A3, if the collision body is always detected, obtaining a first position of the simulation camera after moving the dynamic distance, and moving the virtual camera to the first position; A4, if there is a result of not detecting the collision body, obtaining a second position of the simulation camera after moving the first distance, and moving the virtual camera to the second position.
2. The control method of claim 1, wherein, The control method for virtual camera simulation displacement to achieve obstacle avoidance further comprises: setting a distance between the virtual camera and the character model as a default distance, the default distance comprising a horizontal distance and a vertical distance, and a sum of the horizontal distance and the vertical distance being a fixed value; and setting an orientation of the virtual camera to always point to the character model.
3. The control method of claim 2, wherein, The calculating the target position of the virtual camera comprises: obtaining a position of the character model after moving; calculating a position point of the virtual camera without an obstacle according to the default distance and a gravity direction of the character model.
4. The control method of claim 1, wherein, The setting a plurality of edge points on the near clipping plane of the simulation camera as the obstacle detection points comprises: selecting four corner points of the near clipping plane, i.e., a top-left corner point, a top-right corner point, a bottom-left corner point, and a bottom-right corner point, as the edge points of the obstacle detection points.
5. The control method of claim 1, wherein, The control method for virtual camera simulation displacement to achieve obstacle avoidance further comprises: setting a spherical surrounding collision body surrounding the virtual camera and taking the virtual camera as a center of the spherical surrounding collision body, the spherical surrounding collision body being used for detecting a lower collision of the virtual camera, and if there is a lower collision, calculating a position of the collision body and adjusting a height of the virtual camera upward to a top of the collision body.
6. A control system for virtual camera simulation displacement to achieve obstacle avoidance, comprising: a target position calculation unit configured to calculate a target position of a virtual camera, the target position being a point position of the virtual camera after moving following a character model of a user at a current position; a simulation camera setting unit configured to copy a same virtual camera as a simulation camera, and set a plurality of edge points on a near clipping plane of the simulation camera as obstacle detection points; The obstacle detection unit is configured to perform obstacle detection, and the performing obstacle detection comprises: emitting a ray from the target position towards an obstacle detection point, if no collision body is detected by the ray, moving the virtual camera to the target position, and if a collision body is detected, performing simulated displacement to move the virtual camera to a position after the simulated camera performs simulated displacement; The simulated displacement unit is configured to perform simulated displacement, and the performing simulated displacement comprises: A1, moving the simulated camera forward by a dynamic distance in the direction of the ray, the dynamic distance being a first distance plus a second distance, wherein the first distance is the distance between the target position and the collision body, and the second distance is the width of the collision body along the forward direction; A2, continuously performing the obstacle detection during the movement of the simulated camera by the second distance; A3, if a collision body is always detected, obtaining a first position of the simulated camera after moving the dynamic distance, and moving the virtual camera to the first position; A4, if there is a result of not detecting a collision body, obtaining a second position of the simulated camera after moving the first distance, and moving the virtual camera to the second position.
7. The virtual camera simulation displacement obstacle avoidance control system of claim 6, wherein, The control system for realizing obstacle avoidance by simulated displacement of the virtual camera further comprises a virtual camera setting unit configured to set the distance between the virtual camera and the character model as a default distance, the default distance comprising a lateral distance and a longitudinal distance, the sum of the lateral distance and the longitudinal distance being a fixed value, and the virtual camera setting unit is further configured to set the orientation of the virtual camera to always point to the character model.
8. The virtual camera simulation displacement obstacle avoidance control system of claim 7, wherein, The target position calculation unit is configured to calculate the target position of the virtual camera, comprising: obtaining the position of the character model after movement; calculating the position point of the virtual camera without obstacles according to the default distance and the gravity direction of the character model.
9. The virtual camera simulation displacement obstacle avoidance control system of claim 6, wherein, The control system for realizing obstacle avoidance by simulated displacement of the virtual camera further comprises a virtual camera height adjustment unit configured to set a spherical collision body surrounding the virtual camera with the virtual camera as the center of the sphere, the spherical collision body being used to detect the collision below the virtual camera, and if there is a collision below, calculating the position of the collision body and adjusting the height of the virtual camera upward to the top of the collision body.
10. A storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the control method for realizing obstacle avoidance by simulated displacement of the virtual camera according to any one of claims 1-5.
Citation Information
Patent Citations
Collision detection method and device
CN112657192A
Control method and system for simulating displacement by virtual camera to realize obstacle avoidance, and storage medium
CN118625814A
Image generation system, program, and information storage medium
JP2004341572A
Program, information storage medium and game machine
JP2009028188A
Program, information storage medium, and image generator
JP2011210019A