Virtual camera control method and device, electronic equipment and computer storage medium
By receiving game control input data and determining the target cube lattice, if the virtual camera finds that the lens is blocked when following the entity movement, it selects the closest cube lattice as the new target and performs frame-by-frame interpolation processing, solving the problem of the lens being blocked or interpolated, improving the customer experience.
Patent Information
- Application Number
- CN202411586803.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, when virtual cameras follow the physical movement, the lens is prone to problems such that the lens is blocked or interspersed, which affects the customer experience.
By receiving game control input data, the target cube lattice of the entity and the virtual camera is determined. If the first target cube lattice of the virtual camera is blocked, the cube lattice closest to the cube lattice is selected as the second target cube lattice, and the frame-by-frame interpolation process is performed to transition to the second target cube lattice.
It effectively solves the problem that the lens is blocked or interspersed while the virtual camera follows the physical movement, improving the customer experience.
Smart Images

Figure CN119499648A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game technology, and in particular to a control method, device, electronic device and computer storage medium for a virtual camera. Background Art
[0002] At present, in the virtual space of the metaverse and character control interaction, there are a large number of scenes where the third-person virtual camera needs to follow and look at entities (objects, characters, etc.). However, there are usually various obstacles in the scene. The virtual camera obstacle avoidance in the existing technology mainly uses ray detection of collision points. The general practice is that if there is a collision point, the camera is pushed to the appropriate position. However, this technical solution has a relatively large amount of real-time calculation, and then it cannot simulate the camera's viewport collision well when colliding. It cannot ensure that the followed entity is not lost and the advancement position is too close, resulting in the problem of interspersing into the entity, which greatly affects the customer experience. Summary of the invention
[0003] In view of this, the present application provides a control method, device, electronic device and computer storage medium for a virtual camera, which effectively solves the problem of lens obstruction or interspersal when the virtual camera follows the movement of an entity (object, character, etc.), thereby effectively improving the customer experience.
[0004] The first aspect of the present application provides a method for controlling a virtual camera, comprising:
[0005] Receiving game control input data; wherein the game control input data includes an offset of an entity;
[0006] Determine the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity;
[0007] Determine the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera;
[0008] If the first target cube grid of the virtual camera is marked as blocked in the scene space set, a cube grid closest to the first target cube grid of the virtual camera is selected in the virtual camera follow position set according to the physical target cube grid as the second target cube grid of the virtual camera;
[0009] The virtual camera is interpolated frame by frame from the current world coordinates to the second target cube grid of the virtual camera.
[0010] Optionally, determining the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity includes:
[0011] Determine the target world coordinates of the entity according to the offset of the entity and the current world coordinates of the entity;
[0012] According to the target world coordinates of the entity, a target cube grid of the entity is determined.
[0013] Optionally, determining the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera includes:
[0014] Determine the target world coordinates of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera;
[0015] According to the target world coordinates of the virtual camera, a first target cube grid of the virtual camera is determined.
[0016] Optionally, the method for constructing the scene space set includes:
[0017] Establish a three-dimensional Cartesian coordinate system for the world scene;
[0018] Cutting the x-axis, y-axis and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a unit cube set; wherein the unit cube set includes a plurality of cube grids of the size of the unit cube;
[0019] For each cube grid in the unit cube set, a collision check is performed between the cube grid and the mesh body of the world scene to obtain a first collision check result, and the cube grid is marked according to the first collision check result; wherein, if the first collision check result indicates that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera cannot move; if the first collision check result indicates that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera can move;
[0020] For each cube grid in the unit cube set, a collision check is performed between the cube grid and the grid body of the terrain scene to obtain a second collision check result, and the cube grid is marked according to the second collision check result; wherein, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point;
[0021] When all cube grids are marked, the unit cube set is used as the scene space set.
[0022] Optionally, the method for constructing the virtual camera following position set includes:
[0023] For each target-marked cube grid in the scene space set, the to-be-determined following position is determined according to the position of the target-marked cube grid and the following distance of the virtual camera; wherein the target-marked cube grid is a cube grid marked as a point where the entity can walk; the to-be-determined following position is a cube grid of the virtual camera following the entity corresponding to the target-marked cube grid;
[0024] For each of the to-be-determined following positions, the virtual camera is rotated at the to-be-determined following position to focus on the target marked cube grid position, so as to obtain a target scene depth map and an entity depth map;
[0025] Determining an occlusion rate of an entity according to the target scene depth map and the entity depth map;
[0026] If the occlusion rate of the entity is greater than the occlusion rate threshold, marking the to-be-determined follow-up position as inaccessible to the virtual camera;
[0027] If the occlusion rate of the entity is not greater than the occlusion rate threshold, marking the to-be-determined follow-up position as accessible to the virtual camera;
[0028] A virtual camera following position set is generated according to all target following positions; wherein the target following position is a to-be-determined following position marked as one that the virtual camera can enter.
[0029] A second aspect of the present application provides a control device for a virtual camera, comprising:
[0030] A receiving unit, configured to receive game control input data; wherein the game control input data includes an offset of an entity;
[0031] A first determining unit, configured to determine a target cube grid of the entity according to an offset of the entity and a current world coordinate of the entity;
[0032] A second determining unit, configured to determine a first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera;
[0033] A third determining unit is used for selecting, if the first target cube grid of the virtual camera is marked as blocked in the scene space set, a cube grid closest to the first target cube grid of the virtual camera in the virtual camera following position set according to the entity's target cube grid as the second target cube grid of the virtual camera;
[0034] The control unit is used to perform frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera.
[0035] Optionally, the first determining unit includes:
[0036] An entity coordinate determination unit, used for determining a target world coordinate of an entity according to an offset of the entity and a current world coordinate of the entity;
[0037] The entity cube grid determination unit is used to determine the target cube grid of the entity according to the target world coordinates of the entity.
[0038] Optionally, the second determining unit includes:
[0039] A virtual camera coordinate determination unit, used to determine the target world coordinates of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera;
[0040] The virtual camera cube grid determining unit is used to determine the first target cube grid of the virtual camera according to the target world coordinates of the virtual camera.
[0041] Optionally, the construction unit of the scene space set includes:
[0042] A coordinate system establishment unit, used to establish a three-dimensional Cartesian coordinate system of the world scene;
[0043] A cutting unit, used for cutting the x-axis, y-axis and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a unit cube set; wherein the unit cube set includes a plurality of cube grids of the size of the unit cube;
[0044] A first collision check unit is used to perform a collision check between each cube grid in the unit cube set and a mesh body of the world scene, obtain a first collision check result, and mark the cube grid according to the first collision check result; wherein, if the first collision check result shows that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera cannot move; if the first collision check result shows that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera can move;
[0045] A second collision check unit is used to perform a collision check between each cube grid in the unit cube set and the grid body of the terrain scene, obtain a second collision check result, and mark the cube grid according to the second collision check result; wherein, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point;
[0046] The fourth determining unit is used to use the unit cube set as the scene space set after all cube grids have been marked.
[0047] Optionally, the construction unit of the virtual camera following position set includes:
[0048] A fifth determination unit is used to determine the to-be-determined following position for each target-marked cube grid in the scene space set according to the position of the target-marked cube grid and the following distance of the virtual camera; wherein the target-marked cube grid is a cube grid marked as a point where the entity can walk; and the to-be-determined following position is a cube grid of the virtual camera following the entity corresponding to the target-marked cube grid;
[0049] A rotation unit, for rotating the virtual camera at each of the to-be-determined following positions to a position gazing at the target marked cube grid, to obtain a target scene depth map and an entity depth map;
[0050] An occlusion rate determination unit, configured to determine an occlusion rate of an entity according to the target scene depth map and the entity depth map;
[0051] a marking unit, configured to mark the to-be-determined following position as inaccessible to the virtual camera if the occlusion rate of the entity is greater than an occlusion rate threshold;
[0052] The marking unit is further configured to mark the to-be-determined following position as accessible to the virtual camera if the occlusion rate of the entity is not greater than an occlusion rate threshold;
[0053] A generating unit is used to generate a set of virtual camera following positions according to all target following positions; wherein the target following positions are to-be-determined following positions marked as being accessible to the virtual camera.
[0054] A third aspect of the present application provides an electronic device, including:
[0055] one or more processors;
[0056] a storage device having one or more programs stored thereon;
[0057] When the one or more programs are executed by the one or more processors, the one or more processors implement the virtual camera control method as described in any one of the first aspects.
[0058] A fourth aspect of the present application provides a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the method for controlling a virtual camera as described in any one of the first aspects is implemented.
[0059] As can be seen from the above scheme, the present application provides a control method, device, electronic device and computer storage medium for a virtual camera, which determines the target cube grid of the entity according to the offset of the entity in the game control input data and the current world coordinates of the entity after receiving the game control input data; determines the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; if the first target cube grid of the virtual camera is marked as blocked in the scene space set, the cube grid closest to the first target cube grid of the virtual camera is selected in the virtual camera follow position set according to the target cube grid of the entity as the second target cube grid of the virtual camera; and performs frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera. This effectively solves the problem of lens blocking or interlacing when the virtual camera follows the movement of the entity (object, character, etc.), and effectively improves the customer experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0061] Figure 1 A specific flow chart of a method for controlling a virtual camera provided in an embodiment of the present application;
[0062] Figure 2 A specific flow chart of a method for constructing a scene space set provided in another embodiment of the present application;
[0063] Figure 3 A specific flow chart of a method for constructing a virtual camera following position set provided in another embodiment of the present application;
[0064] Figure 4A schematic diagram of a control device for a virtual camera provided by another embodiment of the present application;
[0065] Figure 5 A schematic diagram of an electronic device for implementing a method for controlling a virtual camera according to another embodiment of the present application. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0068] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0069] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0070] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0071] The present application embodiment provides a method for controlling a virtual camera. Figure 1 As shown, the specific steps include:
[0072] S101, receiving game control input data.
[0073] The game control input data includes the offset of the entity, which includes but is not limited to objects, characters, etc., which are not limited here.
[0074] In the specific implementation process of this application, the world scene is first preprocessed to obtain a scene space set, and an implementation method of the scene space set construction method is as follows: Figure 2 As shown, including:
[0075] S201. Establish a three-dimensional Cartesian coordinate system for the world scene.
[0076] S202 . Cut the x-axis, y-axis, and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a set of unit cubes.
[0077] The unit cube set includes multiple cube grids of the same size as the unit cube.
[0078] It should be noted that the unit cube size (step) is preset by technicians, experts, etc., for example, 1cm 3 , 3cm 3 It is understandable that the smaller the step, the better the accuracy.
[0079] Specifically, the x-axis, y-axis, and z-axis of the three-dimensional Cartesian coordinate system of the world scene are cut in sequence according to the size of the unit cube, and the world coordinates of each cube grid are recorded, Position = {x, y, z}.
[0080] S203 . For each cube grid in the unit cube set, perform a collision check between the cube grid and the mesh body of the world scene to obtain a first collision check result, and mark the cube grid according to the first collision check result.
[0081] Among them, if the first collision check result shows that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point where the virtual camera cannot go; if the first collision check result shows that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point where the virtual camera can go.
[0082] In the specific implementation process of the present application, the physical engine can be used but not limited to detect each cube grid (cell) and the mesh (Mesh) of the world scene for collision check. If there is a collision, it is recorded that the cell cannot allow the camera to perform the unit, and the cell attribute is recorded as Camera_Block = false, otherwise it is recorded as Camera_Block = true, and all cells are composed of a set Scene_Space = {cell, cell}, where Scene_Space is a description set after the scene is divided, that is, a unit cube set.
[0083] It should be noted that a 3D scene is generally composed of multiple objects. An object (such as a chair in a room) is composed of triangular faces through 3D modeling, and the mesh composed of these triangular faces is the chair.
[0084] S204 , for each cube grid in the unit cube set, perform a collision check between the cube grid and the grid body of the terrain scene to obtain a second collision check result, and mark the cube grid according to the second collision check result.
[0085] Among them, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point.
[0086] It should be noted that the physical traversable points are pre-marked, and the technicians pre-mark the mesh of the terrain scene, such as recording the name and parameters of the terrain Mesh (mesh), which is not limited here.
[0087] Specifically, the physical engine can also be used, but not limited to, to detect each cube grid (cell) and the mesh (Mesh) of the terrain scene for collision check. If there is a collision, the cell is marked as a point where the entity can walk, and Role_Block = false is marked, otherwise Role_Block = true, indicating that the entity cannot walk.
[0088] S205: When all cube grids are marked, the unit cube set is used as the scene space set.
[0089] S102. Determine the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity.
[0090] The target world coordinates of the entity are the target positions after the entity receives the game control input data and moves according to the entity's offset.
[0091] Optionally, in the specific implementation process of the present application, an implementation of step S102 includes:
[0092] The target world coordinates of the entity are determined according to the entity's offset and the entity's current world coordinates; and the target cube grid of the entity is determined according to the entity's target world coordinates.
[0093] Specifically, add the entity's offset to the entity's current world coordinates to get the entity's target world coordinates; determine the entity's target cube grid based on the entity's target world coordinates and the unit cube size (step), with a step of 1 cm. 3 For example, assuming the entity's current world coordinates are (2.0, 2.0, 2.0), if the entity's offset is (-1.0, 1.0, 0.0), then the entity's target world coordinates are (1.0, 3.0, 2.0). Then the converted cube grid coordinates are 1.0 / 1, 3.0 / 1, 2.0 / 1, that is, the coordinates of the entity's target cube grid (RP_Cell) are (1.0, 3.0, 2.0).
[0094] S103: Determine the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera.
[0095] The first target cube grid of the virtual camera is the target position of the virtual camera after it moves according to the offset of the entity after receiving the game control input data.
[0096] Optionally, in the specific implementation process of the present application, an implementation of step S103 includes:
[0097] According to the offset of the entity and the current world coordinates of the virtual camera, the target world coordinates of the virtual camera are determined; according to the target world coordinates of the virtual camera, the first target cube grid of the virtual camera is determined.
[0098] Specifically, the offset of the entity is added to the current world coordinate of the virtual camera to obtain the target world coordinate of the virtual camera; according to the target world coordinate of the virtual camera and the unit cube size (step), the first target cube grid of the virtual camera is determined, with a step of 1 cm. 3 For example, assuming that the current world coordinates of the virtual camera are (2.0, 2.0, 2.0), if the entity's offset is (-1.0, 1.0, 0.0), then the target world coordinates of the virtual camera are (1.0, 3.0, 2.0). Then the converted cube grid coordinates are 1.0 / 1, 3.0 / 1, 2.0 / 1, that is, the coordinates of the first target cube grid (CP_Cell) of the virtual camera are (1.0, 3.0, 2.0).
[0099] S104: Determine whether the mark of the first target cube grid of the virtual camera in the scene space set is blocked.
[0100] Specifically, if the first target cube grid of the virtual camera is marked as blocked in the scene space set, step S105 is executed. If the first target cube grid of the virtual camera is marked as not blocked in the scene space set, step S106 can be directly executed with the first target cube grid of the virtual camera, that is, the virtual camera is interpolated frame by frame from the current world coordinates to the first target cube grid of the virtual camera.
[0101] S105 . Selecting a cube grid closest to the first target cube grid of the virtual camera from the virtual camera following position set according to the target cube grid of the entity as the second target cube grid of the virtual camera.
[0102] In the specific implementation process of the present application, the target follow position corresponding to the target cube grid of the entity can be determined by the coordinates of the target cube grid of the entity and the set of virtual camera follow positions, and then, the distance calculation is performed based on the coordinates of the first target cube grid of the virtual camera and the coordinates of the target follow position corresponding to each target cube grid of the entity, which can be but not limited to calculating their three-dimensional Euclidean distance, vector distance, etc., which are not limited here. Finally, the target follow position corresponding to the target cube grid of the entity whose coordinates of the first target cube grid of the virtual camera are closest to the coordinates of the target follow position corresponding to the target cube grid of the entity is used as the second target cube grid of the virtual camera.
[0103] Optionally, in another embodiment of the present application, a method for constructing a virtual camera following position set is implemented as follows: Figure 3 As shown, including:
[0104] S301. For each target marking cube grid in the scene space set, determine a to-be-determined following position according to the position of the target marking cube grid and the following distance of the virtual camera.
[0105] The target marking cube grid is a cube grid marked as a point where the entity can walk; the follow position to be determined is the cube grid of the entity followed by the virtual camera corresponding to the target marking cube grid.
[0106] In the specific implementation process of the present application, the possible range R of the virtual camera is determined according to the position of the target marking cube grid and the following distance (Camera_Distance) of the virtual camera, and the cube grid with the position of the target marking cube grid as the center and R as the width of the cube is obtained as the following position to be determined.
[0107] Specifically, R is the maximum integer that satisfies the condition. R is less than or equal to Camera_Distance and is a multiple of the side length of the target marker cube grid. If the side length of the target marker cube grid is step, then step*ni is represented as a possible R, where ni belongs to [0...n], n represents a positive integer, then R is represented as the formula max{ni}, where step*ni≤Camera_Distance. Trial loop ni from 1 to n to obtain a maximum ni that satisfies the condition.
[0108] The target marked cube grid is taken as the center, and R is the cube grid within the width of the cube, that is, the cube range cube with length*width*height of R*R*R. The specific algorithm is:
[0109] (1) Obtain the coordinates x, y, and z of the target marked cube grid.
[0110] (2) The range of cube coordinate axes: x is in the range of [xR / 2, x+R / 2], y is in the range of [yR / 2, y+R / 2], and z is in the range of [zR / 2, z+R / 2]. Therefore, the x, y, and z coordinates of the grid cell grid are offset one by one. The offset is offset, and offset is a positive integer in the range of [-R / 2, R / 2]. All grids in the range are recorded in this way as the follow-up position to be determined.
[0111] S302: For each to-be-determined following position, the virtual camera is rotated to a position of a cube grid of a gaze target mark at the to-be-determined following position to obtain a target scene depth map and an entity depth map.
[0112] Specifically, for each follow-up position to be determined, a virtual camera is placed in the follow-up position to be determined, and the virtual camera is rotated to the position of the target marked cube grid to obtain a scene depth map corresponding to the camera rendering, that is, the target scene depth map. It can be understood that the closer to the virtual camera, the smaller the scene depth value, and the farther from the virtual camera, the larger the scene depth value. The entity is placed in the target marked cube grid position, and the virtual camera placed in the follow-up position to be determined is used to render the entity separately to obtain the entity depth map.
[0113] S303: Determine the occlusion rate of the entity according to the target scene depth map and the entity depth map.
[0114] In the specific implementation process of the application, the target scene depth map (Scene_Depth) and the entity depth map (Role_Depth) are compared pixel by pixel. Only the depth values of the places with depth in the entity depth map (Role_Depth) can be compared. If the depth of the corresponding place of Scene_Depth is less than the depth at Role_Depth, it means that the entity will be occluded at the pixel. If the depth of the corresponding place of Scene_Depth is less than the depth at Role_Depth, it means that the entity is not occluded at the pixel. The occlusion rate of the entity is calculated based on all comparison results.
[0115] S304: Determine whether the occlusion rate of the entity is greater than an occlusion rate threshold.
[0116] The occlusion rate threshold is pre-set and changed by technicians, experts, etc. and is not limited here.
[0117] Specifically, if the occlusion rate of the entity is greater than the occlusion rate threshold, step S305 is executed; if the occlusion rate of the entity is not greater than the occlusion rate threshold, step S306 is executed.
[0118] S305: Mark the to-be-determined follow position as inaccessible to the virtual camera.
[0119] S306: Mark the to-be-determined follow-up position as accessible to the virtual camera.
[0120] S307: Generate a virtual camera following position set according to all target following positions.
[0121] The target following position is a to-be-determined following position marked as one that the virtual camera can enter.
[0122] It can be understood that the virtual camera following position set includes multiple target following positions corresponding to each target marking cube grid.
[0123] In the specific implementation process of the present application, the virtual camera follow position set (Cell2CameraMap) can be stored in data compression, where the key value of the data in the virtual camera follow position set is the Cell object data, and the value is the corresponding R range within which the virtual camera can enter all cube grids.
[0124] S106 , performing frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera.
[0125] In the specific implementation process of the present application, the method of transitioning the position can be but is not limited to interpolation processing, which is not limited here. It can be understood that a main loop will be designed in the game engine, and an update operation will be performed for each frame and the current frame time dt will be provided. Then, to transform the position such as p(x, y, z) to pt(xt, yt, zt), it is only necessary to use the formula Pc=p*(t-1)+pt*t, where t=dt*speed, and speed is the set speed constant.
[0126] As can be seen from the above scheme, the present application provides a control method for a virtual camera, which determines the target cube grid of the entity according to the offset of the entity in the game control input data and the current world coordinates of the entity after receiving the game control input data; determines the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; if the first target cube grid of the virtual camera is marked as blocked in the scene space set, the cube grid closest to the first target cube grid of the virtual camera is selected in the virtual camera follow position set according to the target cube grid of the entity as the second target cube grid of the virtual camera; and performs frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera. This effectively solves the problem of lens blocking or interlacing when the virtual camera follows the movement of the entity (object, character, etc.), and effectively improves the customer experience.
[0127] The present application embodiment provides a control device for a virtual camera, such as Figure 4 As shown, specifically including:
[0128] The receiving unit 401 is used to receive game control input data.
[0129] The game control input data includes the offset of the entity.
[0130] The first determining unit 402 is used to determine the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity.
[0131] Optionally, in another embodiment of the present application, an implementation of the first determining unit 402 includes:
[0132] The entity coordinate determination unit is used to determine the target world coordinates of the entity according to the offset of the entity and the current world coordinates of the entity.
[0133] The entity cube grid determination unit is used to determine the target cube grid of the entity according to the target world coordinates of the entity.
[0134] The specific working process of the units disclosed in the above embodiments of the present application can be found in the corresponding method embodiments, which will not be repeated here.
[0135] The second determining unit 403 is used to determine the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera.
[0136] Optionally, in another embodiment of the present application, an implementation of the first determining unit 402 includes:
[0137] The virtual camera coordinate determination unit is used to determine the target world coordinates of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera.
[0138] The virtual camera cube grid determining unit is used to determine the first target cube grid of the virtual camera according to the target world coordinates of the virtual camera.
[0139] The specific working process of the units disclosed in the above embodiments of the present application can be found in the corresponding method embodiments, which will not be repeated here.
[0140] The third determining unit 404 is used to select the cube grid closest to the first target cube grid of the virtual camera in the virtual camera following position set according to the entity's target cube grid if the first target cube grid of the virtual camera is marked as blocked in the scene space set, as the second target cube grid of the virtual camera.
[0141] The control unit 405 is used to perform frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera.
[0142] For the specific working process of the units disclosed in the above embodiments of the present application, please refer to the corresponding method embodiments, such as Figure 1 As shown, no further description is given here.
[0143] Optionally, in another embodiment of the present application, an implementation of a construction unit of a scene space set includes:
[0144] The coordinate system establishment unit is used to establish a three-dimensional Cartesian coordinate system of the world scene.
[0145] The cutting unit is used to cut the x-axis, y-axis and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a set of unit cubes.
[0146] The unit cube set includes multiple cube grids of the same size as the unit cube.
[0147] The first collision check unit is used to perform a collision check between each cube grid in the unit cube set and the mesh body of the world scene, obtain a first collision check result, and mark the cube grid according to the first collision check result.
[0148] Among them, if the first collision check result shows that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point where the virtual camera cannot go; if the first collision check result shows that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point where the virtual camera can go.
[0149] The second collision check unit is used to perform a collision check between each cube grid in the unit cube set and the grid body of the terrain scene, obtain a second collision check result, and mark the cube grid according to the second collision check result.
[0150] Among them, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point.
[0151] The fourth determining unit is used to use the unit cube set as the scene space set after all cube grids have been marked.
[0152] For the specific working process of the units disclosed in the above embodiments of the present application, please refer to the corresponding method embodiments, such as Figure 2 As shown, no further description is given here.
[0153] Optionally, in another embodiment of the present application, an implementation of a construction unit of a scene space set includes:
[0154] The fifth determining unit is used to determine the to-be-determined following position for each target marking cube grid in the scene space set according to the position of the target marking cube grid and the following distance of the virtual camera.
[0155] The target marking cube grid is a cube grid marked as a point where the entity can walk; the follow position to be determined is the cube grid of the entity followed by the virtual camera corresponding to the target marking cube grid.
[0156] The rotation unit is used to rotate the virtual camera to the position of the gaze target mark cube grid at each to-be-determined follow-up position to obtain a target scene depth map and an entity depth map.
[0157] The occlusion rate determination unit is used to determine the occlusion rate of the entity according to the target scene depth map and the entity depth map.
[0158] The marking unit is used to mark the to-be-determined following position as inaccessible to the virtual camera if the occlusion rate of the entity is greater than the occlusion rate threshold.
[0159] The marking unit is further used to mark the to-be-determined following position as accessible to the virtual camera if the occlusion rate of the entity is not greater than the occlusion rate threshold.
[0160] The generating unit is used to generate a set of virtual camera following positions according to all target following positions.
[0161] The target following position is a to-be-determined following position marked as one that the virtual camera can enter.
[0162] For the specific working process of the units disclosed in the above embodiments of the present application, please refer to the corresponding method embodiments, such as Figure 3 As shown, no further description is given here.
[0163] As can be seen from the above scheme, the present application provides a control device for a virtual camera. After receiving the game control input data through the receiving unit 401, the first determining unit 402 determines the target cube grid of the entity according to the offset of the entity in the game control input data and the current world coordinates of the entity; the second determining unit 403 determines the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; if the first target cube grid of the virtual camera is marked as blocked in the scene space set, the third determining unit 404 selects the cube grid closest to the first target cube grid of the virtual camera in the virtual camera follow position set according to the target cube grid of the entity as the second target cube grid of the virtual camera; the control unit 405 performs frame-by-frame interpolation processing on the virtual camera from the current world coordinates, and transitions to the second target cube grid of the virtual camera. Thereby effectively solving the problem of lens blocking or interlacing when the virtual camera follows the movement of the entity (object, character, etc.), and effectively improving the customer experience.
[0164] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0165] Another embodiment of the present application provides an electronic device, such as Figure 5 As shown, including:
[0166] One or more processors 501 .
[0167] The storage device 502 stores one or more programs.
[0168] When the one or more programs are executed by the one or more processors 501 , the one or more processors 501 implement the virtual camera control method as described in any one of the above embodiments.
[0169] Another embodiment of the present application provides a computer storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the control method of the virtual camera as described in any one of the above embodiments is implemented.
[0170] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0171] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0172] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0173] Another embodiment of the present application provides a computer program product. When the computer program product is executed, it is used to execute any of the above-mentioned virtual camera control methods.
[0174] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0175] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in this application is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing this application.
[0176] Although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present application. Certain features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0177] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of application involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above application concept. For example, the above features are replaced with (but not limited to) technical features with similar functions applied in the present application.
Claims
1. A method for controlling a virtual camera, characterized in that: include: Receiving game control input data; wherein the game control input data includes an offset of an entity; Determine the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity; Determine the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; If the first target cube grid of the virtual camera is marked as blocked in the scene space set, then according to the target cube grid of the entity, a cube grid closest to the first target cube grid of the virtual camera is selected in the virtual camera following position set as the second target cube grid of the virtual camera; The virtual camera is interpolated frame by frame from the current world coordinates to the second target cube grid of the virtual camera.
2. The method for controlling a virtual camera according to claim 1, characterized in that: Determining the target cube grid of the entity according to the offset of the entity and the current world coordinates of the entity includes: Determine the target world coordinates of the entity according to the offset of the entity and the current world coordinates of the entity; According to the target world coordinates of the entity, a target cube grid of the entity is determined.
3. The control method of a virtual camera according to claim 1, characterized in that: Determining the first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera includes: Determine the target world coordinates of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; According to the target world coordinates of the virtual camera, a first target cube grid of the virtual camera is determined.
4. The method for controlling a virtual camera according to claim 1, wherein: The method for constructing the scene space set includes: Establish a three-dimensional Cartesian coordinate system for the world scene; Cutting the x-axis, y-axis and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a unit cube set; wherein the unit cube set includes a plurality of cube grids of the size of the unit cube; For each cube grid in the unit cube set, a collision check is performed between the cube grid and the mesh body of the world scene to obtain a first collision check result, and the cube grid is marked according to the first collision check result; wherein, if the first collision check result indicates that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera cannot move; if the first collision check result indicates that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera can move; For each cube grid in the unit cube set, a collision check is performed between the cube grid and the grid body of the terrain scene to obtain a second collision check result, and the cube grid is marked according to the second collision check result; wherein, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point; When all cube grids are marked, the unit cube set is used as the scene space set.
5. The method for controlling a virtual camera according to claim 4, characterized in that: The method for constructing the virtual camera following position set includes: For each target-marked cube grid in the scene space set, the to-be-determined following position is determined according to the position of the target-marked cube grid and the following distance of the virtual camera; wherein the target-marked cube grid is a cube grid marked as a point where the entity can walk; the to-be-determined following position is a cube grid of the virtual camera following the entity corresponding to the target-marked cube grid; For each of the to-be-determined following positions, the virtual camera is rotated at the to-be-determined following position to focus on the target marked cube grid position, so as to obtain a target scene depth map and an entity depth map; Determining an occlusion rate of an entity according to the target scene depth map and the entity depth map; If the occlusion rate of the entity is greater than the occlusion rate threshold, marking the to-be-determined follow-up position as inaccessible to the virtual camera; If the occlusion rate of the entity is not greater than the occlusion rate threshold, marking the to-be-determined follow-up position as accessible to the virtual camera; A virtual camera following position set is generated according to all target following positions; wherein the target following position is a to-be-determined following position marked as one that the virtual camera can enter.
6. A virtual camera control device, characterized in that: include: A receiving unit, configured to receive game control input data; wherein the game control input data includes an offset of an entity; A first determining unit, configured to determine a target cube grid of the entity according to an offset of the entity and a current world coordinate of the entity; A second determining unit, configured to determine a first target cube grid of the virtual camera according to the offset of the entity and the current world coordinates of the virtual camera; a third determining unit, configured to select, if the first target cube grid of the virtual camera is marked as blocked in the scene space set, a cube grid closest to the first target cube grid of the virtual camera in the virtual camera following position set according to the entity's target cube grid as the second target cube grid of the virtual camera; The control unit is used to perform frame-by-frame interpolation processing on the virtual camera from the current world coordinates to transition to the second target cube grid of the virtual camera.
7. The control device for a virtual camera according to claim 6, characterized in that: The construction unit of the scene space set includes: A coordinate system establishment unit, used to establish a three-dimensional Cartesian coordinate system of the world scene; A cutting unit, used for cutting the x-axis, y-axis and z-axis of the three-dimensional Cartesian coordinate system of the world scene according to the size of the unit cube to obtain a unit cube set; wherein the unit cube set includes a plurality of cube grids of the size of the unit cube; A first collision check unit is used to perform a collision check between each cube grid in the unit cube set and a mesh body of the world scene, obtain a first collision check result, and mark the cube grid according to the first collision check result; wherein, if the first collision check result shows that the cube grid collides with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera cannot move; if the first collision check result shows that the cube grid does not collide with the mesh body of the world scene, the cube grid is marked as a point that the virtual camera can move; A second collision check unit is used to perform a collision check between each cube grid in the unit cube set and the grid body of the terrain scene, obtain a second collision check result, and mark the cube grid according to the second collision check result; wherein, if the second collision check result shows that the cube grid collides with the grid body of the terrain scene, the cube grid is marked as a physical walkable point; if the second collision check result shows that the cube grid does not collide with the grid body of the terrain scene, the cube grid is marked as a physical non-walkable point; The fourth determining unit is used to use the unit cube set as the scene space set after all cube grids have been marked.
8. The control device for a virtual camera according to claim 7, characterized in that: The construction unit of the virtual camera following position set includes: A fifth determination unit is used to determine the to-be-determined following position for each target-marked cube grid in the scene space set according to the position of the target-marked cube grid and the following distance of the virtual camera; wherein the target-marked cube grid is a cube grid marked as a point where the entity can walk; and the to-be-determined following position is a cube grid of the virtual camera following the entity corresponding to the target-marked cube grid; A rotation unit, for rotating the virtual camera at each of the to-be-determined following positions to a position gazing at the target marked cube grid, to obtain a target scene depth map and an entity depth map; An occlusion rate determination unit, configured to determine an occlusion rate of an entity according to the target scene depth map and the entity depth map; a marking unit, configured to mark the to-be-determined following position as inaccessible to the virtual camera if the occlusion rate of the entity is greater than an occlusion rate threshold; The marking unit is further configured to mark the to-be-determined following position as accessible to the virtual camera if the occlusion rate of the entity is not greater than an occlusion rate threshold; A generating unit is used to generate a set of virtual camera following positions according to all target following positions; wherein the target following positions are to-be-determined following positions marked as being accessible to the virtual camera.
9. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the virtual camera control method according to any one of claims 1 to 5.
10. A computer storage medium, characterized in that: A computer program is stored thereon, wherein when the computer program is executed by a processor, the control method of the virtual camera as claimed in any one of claims 1 to 5 is implemented.