Three-dimensional coordinate mapping method, device, storage medium and computer equipment
Through the combination of depth map and world bounding box, efficient resource utilization and compatibility of three-dimensional coordinate mapping are achieved, solving the problems of low resource utilization and poor effect in the existing technology, and broadening the application scenarios of three-dimensional dynamic observation.
Patent Information
- Application Number
- CN202410635503.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-22
AI Technical Summary
In the process of three-dimensional dynamic observation, the resource utilization rate of existing technology is low, making it difficult to achieve expected results, especially when there are a large number of objects in the scene and it is difficult to process user-defined entities.
By obtaining the depth map, determine the candidate position and perform depth sampling. If there is depth, the target position is determined directly; if there is no depth, the position points in the mouse target frame are traversed. If there is no depth, the world bounding box and rays are used to determine the target position to achieve three-dimensional Coordinate mapping.
It improves the compatibility and computing resource utilization of three-dimensional coordinate mapping, can handle entities expanded by users themselves, broadens application scenarios and improves dynamic observation effects.
Smart Images

Figure CN118229770B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer-aided design technology, and in particular to a three-dimensional coordinate mapping method, device, storage medium and computer equipment. Background Art
[0002] When 3D dynamic viewing is enabled in a computer, the computer-aided design platform will calculate the rotation center of the corresponding 3D world coordinate system based on the 2D mouse point entered by the user on the screen, allowing the user to interact with the 3D scene. In the process of 3D dynamic viewing, in order to obtain the mapping relationship between the mouse and the entity, the ray intersection algorithm is usually used. The ray intersection algorithm is a commonly used algorithm in computer graphics. It can be used to determine whether a ray (usually a straight line starting from the camera position) intersects with an object in the scene and calculate the position of the intersection.
[0003] However, the ray intersection algorithm needs to detect each object in the scene one by one. When there are many objects in the scene, a lot of computing resources are consumed. Moreover, for complex entities extended by users on the computer-aided design platform, the computer-aided design platform cannot process such customized entities. This results in low resource utilization when performing 3D dynamic observation, and the use scenarios of 3D dynamic observation are limited, which makes it difficult to achieve the expected effect of 3D dynamic observation. Summary of the invention
[0004] The purpose of this application is to solve at least one of the above-mentioned technical defects, especially the low effective utilization rate of resources in the prior art when performing three-dimensional dynamic observation, and the limited usage scenarios of three-dimensional dynamic observation, which makes it difficult to achieve the expected technical defects of three-dimensional dynamic observation.
[0005] In a first aspect, the present application provides a three-dimensional coordinate mapping method, the method comprising:
[0006] When it is detected that the user enables three-dimensional dynamic viewing, a depth map is obtained and a candidate position is determined;
[0007] Based on the depth map, performing depth sampling on the candidate position;
[0008] If the candidate position has a depth in the depth map, determining the candidate position as a position to be mapped, and determining a target position according to the position to be mapped;
[0009] If the candidate position does not have a depth in the depth map, determine the mouse target frame corresponding to the candidate position, and traverse and sample the depths of the position points in the mouse target frame except the candidate position. When a position point with a depth is traversed, determine the position point as the position to be mapped, and determine the target position according to the position to be mapped;
[0010] If there is no position point with depth in the mouse target frame, determine the world bounding box formed by all entities in the scene, construct a target ray, and determine the target position according to the world bounding box and the target ray;
[0011] The target position is used as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0012] In one embodiment, the step of determining the target position according to the position to be mapped includes:
[0013] Obtaining the view matrix and projection matrix of the viewport corresponding to the candidate position;
[0014] Determine an inverse matrix of the view matrix and an inverse matrix of the projection matrix according to the view matrix and the projection matrix;
[0015] According to the inverse matrix of the view matrix and the inverse matrix of the projection matrix, the position to be mapped is mapped to the world coordinate system to obtain a target position.
[0016] In one embodiment, the step of determining the candidate location includes:
[0017] Obtain the mouse position when the user enables 3D dynamic viewing, and obtain the view matrix and projection matrix of the viewport corresponding to the mouse position;
[0018] According to the view matrix, the mouse position is converted into a camera coordinate system to obtain a first coordinate;
[0019] According to the projection matrix, convert the first coordinate to a clipping space to obtain a second coordinate;
[0020] Performing homogeneous division on the second coordinate in the clipping space to obtain the candidate position.
[0021] In one embodiment, the step of determining the mouse target frame corresponding to the candidate position includes:
[0022] Obtain a preset target frame generation strategy;
[0023] The target aperture generation strategy is adopted to generate a mouse target aperture corresponding to the candidate position.
[0024] In one embodiment, the step of constructing the target ray includes:
[0025] Determine a camera position; wherein the camera position is a position of the camera in a three-dimensional world;
[0026] A ray emitted from the camera position and passing through the candidate position is constructed, and the constructed ray is determined as a target ray.
[0027] In one embodiment, the step of determining the target position according to the world bounding box and the target ray comprises:
[0028] Determine the intersection points of the target ray and the upper and lower surfaces of the world bounding box;
[0029] The average coordinate value between the first intersection point and the second intersection point is calculated to obtain the target position; wherein the first intersection point is the intersection point of the target ray and the upper surface of the world bounding box, and the second intersection point is the intersection point of the target ray and the lower surface of the world bounding box.
[0030] In one embodiment, the step of determining the intersection of the target ray and the upper and lower surfaces of the world bounding box includes:
[0031] Determining a parametric equation of the target ray;
[0032] Determine a plane equation of an upper surface of the world bounding box, and determine a plane equation of a lower surface of the world bounding box;
[0033] Solving the intersection point between the target ray and the upper surface of the world bounding box according to the parametric equation and the plane equation of the upper surface of the world bounding box to obtain the first intersection point;
[0034] According to the parameter aspect and the plane equation of the lower surface of the world bounding box, the intersection of the target ray and the lower surface of the world bounding box is solved to obtain the second intersection point.
[0035] In a second aspect, the present application provides a three-dimensional coordinate mapping device, the device comprising:
[0036] An information determination module, for obtaining a depth map and determining a candidate position when it is detected that the user enables three-dimensional dynamic viewing;
[0037] A depth sampling module, configured to perform depth sampling on the candidate position based on the depth map;
[0038] A first position determination module, configured to determine the candidate position as a position to be mapped if the candidate position has a depth in the depth map, and determine a target position according to the position to be mapped;
[0039] A second position determination module is configured to determine a mouse target frame corresponding to the candidate position if the candidate position does not have a depth in the depth map, and traverse and sample the depths of position points other than the candidate position in the mouse target frame, and when a position point with a depth is traversed to, determine the position point as a position to be mapped, and determine a target position according to the position to be mapped;
[0040] A third position determination module is used to determine a world bounding box formed by all entities in the scene if there is no position point with depth in the mouse target frame, and to construct a target ray, and to determine a target position according to the world bounding box and the target ray;
[0041] The coordinate mapping module is used to use the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0042] In a third aspect, the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the three-dimensional coordinate mapping method described in any of the above embodiments.
[0043] In a fourth aspect, the present application provides a computer device, comprising: one or more processors, and a memory;
[0044] The memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, the steps of the three-dimensional coordinate mapping method described in any one of the above embodiments are performed.
[0045] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0046] The present application provides a three-dimensional coordinate mapping method, device, storage medium and computer equipment, the method comprising: when it is detected that the user enables three-dimensional dynamic observation, a depth map is obtained, and a candidate position is determined, and then the depth map is used to perform depth sampling on the candidate position. When the candidate position has depth, the target position can be directly determined according to the candidate position. When the candidate position does not have depth, the mouse target frame corresponding to the candidate position is determined, and then the position points in the mouse target frame are traversed, and when the position point with depth is traversed, the target position is determined according to the position point, and when there is no position point with depth in the mouse target frame, the world bounding box and target ray composed of all entities in the scene are used to determine the target position. In the process of mapping the three-dimensional coordinates, the coordinate mapping is performed based on the depth map. Since the depth map is the data generated when the graphics are rendered, there is no need to generate the depth map additionally to save computing resources. At the same time, the target position in the three-dimensional coordinate mapping process is obtained by conversion based on the position to be mapped. The conversion process is separated from the entity in the scene and can handle the entity extended by the user. Thereby improving the compatibility of the three-dimensional coordinate mapping method. Moreover, when there are positions with depth in the mouse target frame, coordinate mapping can be performed based on the depth map to save computing resources and process entities extended by users; when there are no positions with depth in the mouse target frame, the rotation center can be determined by finding the intersection of rays. In this way, this solution can select different coordinate mapping strategies according to the depth sampling situation to broaden the application scenarios of the three-dimensional coordinate mapping method and further improve the effect of three-dimensional dynamic observation. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present application 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0048] Figure 1 A schematic diagram of a flow chart of a three-dimensional coordinate mapping method provided in an embodiment of the present application;
[0049] Figure 2 A schematic diagram of a flow chart of steps for determining a target position according to a position to be mapped provided in an embodiment of the present application;
[0050] Figure 3 A schematic diagram of a flow chart of the steps of determining a candidate location provided in an embodiment of the present application;
[0051] Figure 4 A schematic flow chart of the steps of determining a mouse target frame corresponding to a candidate position provided in an embodiment of the present application;
[0052] Figure 5 A flowchart of the steps of determining a target position according to a world bounding box and a target ray provided in an embodiment of the present application;
[0053] Figure 6 A schematic flow chart of the steps of determining the intersection of a target ray and the upper and lower surfaces of a world bounding box provided in an embodiment of the present application;
[0054] Figure 7 A schematic diagram of the structure of a three-dimensional coordinate mapping device provided in an embodiment of the present application;
[0055] Figure 8 An internal structure diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] 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.
[0057] In one embodiment, the present application provides a three-dimensional coordinate mapping method, and the following embodiment is described by applying the method to a server. It can be understood that the three-dimensional coordinate mapping method can be executed by a single server or a server cluster composed of multiple servers, and the present application does not make specific restrictions on this.
[0058] like Figure 1 As shown, the present application provides a three-dimensional coordinate mapping method, the method comprising:
[0059] Step S101: when it is detected that the user enables three-dimensional dynamic viewing, a depth map is obtained and a candidate position is determined.
[0060] Among them, 3D dynamic observation refers to the operation of users converting the perspective in the 3D scene. The depth map refers to the depth data obtained by rendering the entities in the 3D scene currently being 3D dynamically observed. The depth value of each position point in the depth map is in the range [0, 1]. The candidate position refers to the position of the mouse position input by the user corresponding to the NDC coordinate system.
[0061] In this step, when the user needs to change the perspective in the three-dimensional scene to observe the entities in the three-dimensional scene, the mouse position can be input through the client, and the server obtains the depth map generated when rendering the entity and the mouse position input by the user, and then determines the corresponding candidate position based on the mouse position input by the user.
[0062] Step S102: Based on the depth map, depth sampling is performed on the candidate positions.
[0063] In this step, the position corresponding to the candidate position in the depth map can be determined, and then the depth value of the position can be obtained to obtain the depth corresponding to the candidate position in the depth map, so as to complete the depth sampling of the candidate position.
[0064] In one example, the candidate positions can be depth sampled according to the following expression:
[0065]
[0066] In the formula, is the depth of the candidate position, is the depth map, represents the coordinates of the candidate position, refers to the depth map ( ) The position is sampled.
[0067] Step S103: Determine whether the candidate position has a depth in the depth map.
[0068] It is understandable that before rendering the three-dimensional scene, the server will set the depth value of each pixel of the corresponding depth buffer to 1. When the rendered content covers the corresponding pixel in the depth buffer, the depth value of the pixel will be set to a value less than 1 and greater than 0.
[0069] Step S104: If the candidate position has a depth in the depth map, the candidate position is determined as the position to be mapped, and the target position is determined according to the position to be mapped.
[0070] The target position refers to the rotation center of this 3D dynamic observation.
[0071] In this step, when the corresponding position of the candidate position in the depth map has depth, it means that the depth value of the corresponding position of the candidate position in the depth map is less than 1. At this time, the candidate position is used as the position to be mapped, and then the position to be mapped is mapped to obtain the target position.
[0072] It can be understood that when a candidate position has depth in the depth map, it can be said that the candidate position is an entity. Therefore, the candidate position can be used as the position to be mapped, and then the target position can be calculated based on the position to be mapped, and the target position obtained based on the position to be mapped can be used as the rotation center to complete the user's three-dimensional dynamic observation operation.
[0073] Step S105: taking the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0074] The rotation center refers to the reference point around which the three-dimensional scene rotates.
[0075] In this step, after the target position is determined, the target position can be used as the rotation center of the scene currently being observed in three-dimensional dynamic viewing, so that three-dimensional dynamic viewing can be performed.
[0076] Step S106: If the candidate position does not have a depth in the depth map, determine the mouse target box corresponding to the candidate position, and traverse and sample the depths of the position points in the mouse target box except the candidate position.
[0077] The mouse target frame refers to a square area used to describe the position of the mouse, and the square area includes multiple position points.
[0078] In this step, when the candidate position does not have a depth in the depth map, the corresponding mouse target frame can be determined by the candidate position, so as to perform traversal sampling in the mouse target frame until a position point with a depth is sampled.
[0079] Furthermore, the order of traversing the samples in the mouse target frame can be determined according to a preset rule. The preset rule can be to start from the candidate position and use a depth-first search method to traverse, or the preset rule can be to start from the candidate position and use a breadth-first search method to traverse. This application does not make specific restrictions on this.
[0080] In one example, starting from the candidate position in the mouse target box, the sampling breadth-first search method is used for traversal. At this time, the candidate position is traversed to the surrounding position points. In this way, when there is a position point with depth in the mouse target box, the position point closest to the candidate position and with depth can be found. The accuracy of the rotation center is improved, thereby improving the effect of three-dimensional dynamic observation.
[0081] Step S107: Determine whether the current traversal position has a depth.
[0082] In this step, it is determined whether the position point currently being traversed has any depth, so as to find the position point with depth in the mouse target frame.
[0083] Step S108: When a position point with depth is traversed, the position point is determined as a position to be mapped, and a target position is determined according to the position to be mapped.
[0084] When traversing to a position point with depth, that is, the currently traversed position point has depth, at this time, the currently traversed position point is determined as the position to be mapped, and then the target position used as the rotation center in the three-dimensional world coordinate system is determined according to the position to be mapped.
[0085] Step S105: taking the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0086] For the description of this step, please refer to the description of the above step S105.
[0087] Exemplarily, assume that the mouse target frame is a square area of 3*3 in size, and is numbered 1, 2, 3, 4, 5, ..., 8, 9 from top to bottom and from left to right. Among them, the position corresponding to number 5 is the candidate position. When the depth value corresponding to number 5 is equal to 1, that is, there is no depth at the candidate position, at this time, starting from the candidate position, the mouse target frame is traversed and sampled, and the traversal can be performed from the eight neighborhoods around the candidate position, and the specific order is not limited. When traversing to a position point with depth, the target position can be determined based on the position point. If there is no position point with depth after traversing all position points except the candidate position. Then the target position can be determined by the ray intersection method.
[0088] Step S109: Determine whether all position points except the candidate position in the mouse target frame have been traversed.
[0089] Step S110: If there is no position point with depth in the mouse target frame, determine the world bounding box formed by all entities in the scene, construct a target ray, and determine the target position according to the world bounding box and the target ray.
[0090] The scene is the 3D scene currently being dynamically observed. The world bounding box is the bounding box formed by the bounding boxes of all entities in the scene. The basic idea of the bounding box is to use a slightly larger geometric body with simpler characteristics to approximate complex geometric objects. Using a bounding box can reduce the amount of calculation and improve the running speed and efficiency of the program. For example, when processing a 3D model composed of thousands of triangles, directly using a bounding box instead of the model can greatly reduce the amount of data that the computer needs to process. Only the shape and position information of the bounding box need to be processed to determine the position and size of the model.
[0091] In this step, when there is no position point with depth in the mouse target frame, the rotation center cannot be determined based on the depth information. The ray intersection method is used to first determine the world bounding box formed by all entities in the scene, and then construct the target ray to solve the target position based on the world bounding box and the target ray.
[0092] Furthermore, the step of determining the world bounding box formed by all entities in the scene includes: sampling entity information of all entities in the scene, calculating the local bounding box of each entity according to the entity information of each entity, merging the local bounding boxes of each entity to obtain an initial bounding box, and optimizing the initial bounding box to obtain a world bounding box. The entity information refers to parameter information of the entity, such as vertex information used for display, etc.
[0093] Step S105: taking the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0094] For the description of this step, please refer to the description of the above step S105.
[0095] Step S111: Continue traversing.
[0096] The present application provides a three-dimensional coordinate mapping method, device, storage medium and computer equipment, the method comprising: when it is detected that the user enables three-dimensional dynamic observation, a depth map is obtained, and a candidate position is determined, and then the depth map is used to perform depth sampling on the candidate position. When the candidate position has depth, the target position can be directly determined according to the candidate position. When the candidate position does not have depth, the mouse target frame corresponding to the candidate position is determined, and then the position points in the mouse target frame are traversed, and when the position point with depth is traversed, the target position is determined according to the position point, and when there is no position point with depth in the mouse target frame, the world bounding box and target ray composed of all entities in the scene are used to determine the target position. In the process of mapping the three-dimensional coordinates, the coordinate mapping is performed based on the depth map. Since the depth map is the data generated when the graphics are rendered, there is no need to generate the depth map additionally to save computing resources. At the same time, the target position in the three-dimensional coordinate mapping process is obtained by conversion based on the position to be mapped. The conversion process is separated from the entity in the scene and can handle the entity extended by the user. Thereby improving the compatibility of the three-dimensional coordinate mapping method. Moreover, when there are positions with depth in the mouse target frame, coordinate mapping can be performed based on the depth map to save computing resources and process entities extended by users; when there are no positions with depth in the mouse target frame, the rotation center can be determined by finding the intersection of rays. In this way, this solution can select different coordinate mapping strategies according to the depth sampling situation to broaden the application scenarios of the three-dimensional coordinate mapping method and further improve the effect of three-dimensional dynamic observation.
[0097] like Figure 2 As shown, in one embodiment, the step of determining the target position according to the position to be mapped includes:
[0098] Step S201: Obtain the view matrix and projection matrix of the viewport corresponding to the candidate position.
[0099] Among them, the view matrix is a matrix used to represent the position and direction of the camera. It is also called the observation matrix. The view matrix can convert the object coordinates in the world coordinate system into the coordinates in the camera coordinate system. Through the view matrix, the position and orientation of the camera in the world can be determined, thereby realizing operations such as camera movement and rotation. The projection matrix is used to represent the planar mapping of a three-dimensional object and can convert three-dimensional coordinates into two-dimensional coordinates.
[0100] It is understandable that the viewport corresponding to the candidate position is the viewport corresponding to the mouse position. Since there can be multiple viewports in a screen, the projection matrix and view matrix used in each viewport are different. Therefore, when performing three-dimensional coordinate mapping, it is necessary to obtain the projection matrix and view matrix of the viewport corresponding to the candidate position.
[0101] Step S202: Determine the inverse matrix of the view matrix and the inverse matrix of the projection matrix according to the view matrix and the projection matrix.
[0102] In this step, the inverse matrix of the view matrix and the inverse matrix of the projection matrix can be determined respectively according to the matrix inversion method, wherein the inverse matrix multiplied by the original matrix is equal to the identity matrix.
[0103] Step S203: Map the position to be mapped to the world coordinate system according to the inverse matrix of the view matrix and the inverse matrix of the projection matrix to obtain the target position.
[0104] In this step, the coordinates corresponding to the position to be mapped in the world coordinate system, that is, the target position, can be inversely calculated through the inverse matrix of the view matrix and the inverse matrix of the projection matrix.
[0105] In an example, the position to be mapped can be mapped to the world coordinate system according to the following expression to obtain the target position:
[0106]
[0107] In the formula, represents the target location, is the inverse matrix of the projection matrix, is the inverse matrix of the view matrix, It can be expressed as ( , , ),in, and are the x and y components of the candidate position, is the depth of the candidate position in the depth map.
[0108] It is understandable that since the candidate position is a position coordinate in the NDC coordinate system, when the candidate position is determined to be the position to be mapped, the position to be mapped needs to be converted to the world coordinate system to determine the target position. Through depth sampling and coordinate mapping, the coordinates during three-dimensional dynamic observation can be simply and quickly mapped, and the rotation center of three-dimensional dynamic observation can be efficiently determined. Moreover, the target position is obtained by coordinate transformation based on the position to be mapped. The coordinate transformation process is separated from the entities in the scene and can handle entities expanded by the user. Thereby improving the compatibility of the three-dimensional coordinate mapping method.
[0109] like Figure 3 As shown, in one embodiment, the step of determining the candidate location includes:
[0110] Step S301: obtaining the mouse position when the user enables 3D dynamic viewing, and obtaining the view matrix and projection matrix of the viewport corresponding to the mouse position.
[0111] It can be understood that since there can be multiple viewports in one screen, the projection matrix and view matrix used in each viewport are different. Therefore, it is necessary to obtain the projection matrix and view matrix of the viewport corresponding to the mouse position.
[0112] In this step, the mouse position input by the user when enabling three-dimensional dynamic viewing is obtained, and the view matrix and projection matrix of the viewport corresponding to the mouse position are obtained to perform coordinate system conversion on the mouse position.
[0113] Step S302: According to the view matrix, the mouse position is converted into the camera coordinate system to obtain a first coordinate.
[0114] The camera coordinate system refers to the coordinate system of the camera at its own angle, with the origin at the optical center of the camera. The first coordinate is the coordinate of the position corresponding to the mouse position in the camera coordinate system.
[0115] In this step, the mouse position is multiplied by the view matrix to obtain the first coordinate.
[0116] Step S303: According to the projection matrix, the first coordinate is converted into the clipping space to obtain the second coordinate.
[0117] The clipping space refers to the space obtained after calculation with the projection matrix, also known as the homogeneous clipping space. The second coordinate is the coordinate of the position corresponding to the first coordinate in the clipping space.
[0118] In this step, the first coordinate is multiplied by the projection matrix to obtain the second coordinate.
[0119] Step S304: Perform homogeneous division on the second coordinate in the clipping space to obtain a candidate position.
[0120] In this step, the w component in the clipping space is obtained, and each component in the second coordinate is divided by the w component to complete the homogeneous division of the second coordinate to obtain the candidate position. The w component is used to represent the homogeneous depth or the perspective depth.
[0121] Specifically, homogeneous division can convert the second coordinate from the clipping space to the NDC coordinate system, where the NDC (Normalized Device Coordinates) coordinate system is used to represent the coordinates in the clipping space after perspective division.
[0122] It is understandable that in the process of 3D coordinate mapping, the mouse position needs to be converted to the NDC coordinate system for processing. Then the candidate position can be sampled for depth. Moreover, since the coordinate mapping is based on the depth map, which is the data generated when the graphics are rendered, there is no need to generate a depth map additionally to save computing resources.
[0123] like Figure 4 As shown, in one embodiment, the step of determining the mouse target frame corresponding to the candidate position includes:
[0124] Step S401: Obtain a preset target frame generation strategy.
[0125] Among them, the target frame generation strategy is used to determine the boundary position of the mouse target frame for the candidate position.
[0126] Step S402: adopting a target frame generation strategy to generate a mouse target frame corresponding to the candidate position.
[0127] In this step, according to the acquired target frame generation strategy, a corresponding mouse target frame is generated based on the candidate position, and then traversal is performed in the generated mouse target frame to find the position point with depth in the mouse target frame.
[0128] In an example, the target frame generation strategy may be to construct a square area of 3*3 with the candidate position as the center, determine the boundary of the square area, and then determine the mouse target frame corresponding to the candidate position according to the target frame generation strategy.
[0129] It is understandable that by determining the mouse target frame through the target frame generation strategy, a mouse target frame of appropriate size and position can be reasonably generated to achieve the purpose of traversing and sampling around the candidate position as much as possible. When there is no depth at the candidate position, it is also possible to traverse within the mouse target frame to find the position point with depth, thereby improving the robustness of the three-dimensional coordinate mapping method and broadening the application scenarios of the three-dimensional coordinate mapping method.
[0130] In one embodiment, the step of constructing the target ray includes:
[0131] Determine a camera position; wherein the camera position is a position of the camera in the three-dimensional world;
[0132] A ray emitted from the camera position and passing through the candidate position is constructed, and the constructed ray is determined as the target ray.
[0133] In this embodiment, the camera position is first determined, and then a ray passing through the candidate position is emitted from the camera position. The ray is determined as the target ray. It can be understood that a ray can be uniquely determined through the two points of the camera position and the candidate position.
[0134] It can be understood that by constructing a ray emitted from the camera position and passing through the candidate position to determine the target position, the rotation center can be determined as accurately as possible, and the effect of three-dimensional dynamic observation can be guaranteed when the depth cannot be collected.
[0135] like Figure 5 As shown, in one embodiment, the step of determining the target position according to the world bounding box and the target ray includes:
[0136] Step S501: Determine the intersection points of the target ray and the upper and lower surfaces of the world bounding box.
[0137] It can be understood that the intersection points of the target ray with the upper and lower surfaces of the world bounding box include the intersection points of the target ray with the upper surface of the world bounding box and the intersection points of the target ray with the lower surface of the world bounding box.
[0138] Step S502: Calculate the average coordinate value between the first intersection point and the second intersection point to obtain the target position.
[0139] The first intersection point is the intersection point of the target ray and the upper surface of the world bounding box, and the second intersection point is the intersection point of the target ray and the lower surface of the world bounding box.
[0140] In one example, the average coordinate value between the first intersection point and the second intersection point may be calculated according to the following expression:
[0141]
[0142] In the formula, represents the average coordinate value between the first intersection point and the second intersection point, i.e. the target position, , , are the x, y and z components of the first intersection point respectively, , , are the x-component, y-component, and z-component of the second intersection point respectively.
[0143] It is understandable that when the depth cannot be collected, the rotation center is determined by using the ray intersection method. Moreover, by determining the world bounding box formed by all entities and then determining the target position by the intersection of the world bounding box and the target ray, the rotation center can be determined as accurately as possible, thereby ensuring the effect of three-dimensional dynamic observation when the depth cannot be collected.
[0144] like Figure 6 As shown, in one embodiment, the step of determining the intersection of the target ray and the upper and lower surfaces of the world bounding box includes:
[0145] Step S601: Determine the parameter equation of the target ray.
[0146] The parametric equation is used to describe the target ray, which includes the information of the starting point and direction of the target ray.
[0147] Step S602: Determine the plane equation of the upper surface of the world bounding box, and determine the plane equation of the lower surface of the world bounding box.
[0148] Among them, the plane equation is used to represent a two-dimensional plane.
[0149] In this step, the plane equations of the upper surface of the world bounding box and the lower surface of the world bounding box can be determined by the point method or the three-point method. When the plane equation is determined by the point method, a point on the plane and the normal vector of the plane can be obtained to determine the plane equation of the plane. When the plane equation is determined by the three-point method, three non-collinear points on the plane can be obtained to determine the plane equation of the plane.
[0150] Step S603: according to the parametric equation and the plane equation of the upper surface of the world bounding box, the intersection point between the target ray and the upper surface of the world bounding box is solved to obtain a first intersection point.
[0151] Step S604: according to the parameter aspect and the plane equation of the lower surface of the world bounding box, the intersection of the target ray and the lower surface of the world bounding box is solved to obtain a second intersection point.
[0152] In step S603 and step S604, the first intersection point and the second intersection point may be determined by substituting the parameter equation of the target ray into the plane equation of the upper surface of the world bounding box and the plane equation of the lower surface of the world bounding box, respectively.
[0153] It is understandable that when the depth cannot be collected, the rotation center is determined by using the ray intersection method. Moreover, by determining the world bounding box formed by all entities and then determining the target position by the intersection of the world bounding box and the target ray, the rotation center can be determined as accurately as possible, thereby ensuring the effect of three-dimensional dynamic observation when the depth cannot be collected.
[0154] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0155] The following is a description of a three-dimensional coordinate mapping device provided in an embodiment of the present application. The three-dimensional coordinate mapping device described below and the three-dimensional coordinate mapping method described above can be referenced to each other.
[0156] like Figure 7 As shown, the present application provides a three-dimensional coordinate mapping device 700, the device comprising:
[0157] The information determination module 701 is used to obtain a depth map and determine a candidate position when it is detected that the user enables 3D dynamic viewing;
[0158] A depth sampling module 702 is used to perform depth sampling on the candidate position based on the depth map;
[0159] A first position determination module 703 is used to determine the candidate position as a position to be mapped if the candidate position has a depth in the depth map, and determine a target position according to the position to be mapped;
[0160] A second position determination module 704 is configured to determine a mouse target frame corresponding to the candidate position if the candidate position does not have a depth in the depth map, and traverse and sample the depths of positions other than the candidate position in the mouse target frame, and when a position point with a depth is traversed, determine the position point as a position to be mapped, and determine a target position according to the position to be mapped;
[0161] The third position determination module 705 is used to determine the world bounding box formed by all entities in the scene if there is no position point with depth in the mouse target frame, and construct a target ray, and determine the target position according to the world bounding box and the target ray;
[0162] The coordinate mapping module 706 is used to use the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
[0163] In one embodiment, the first position determination module and the second position determination module both include:
[0164] The matrix acquisition submodule is used to obtain the view matrix and projection matrix of the viewport corresponding to the candidate position;
[0165] A matrix determination submodule, used for determining an inverse matrix of a view matrix and an inverse matrix of a projection matrix according to the view matrix and the projection matrix;
[0166] The position determination submodule is used to map the position to be mapped to the world coordinate system according to the inverse matrix of the view matrix and the inverse matrix of the projection matrix to obtain the target position.
[0167] In one embodiment, the information determination module includes:
[0168] The position acquisition submodule is used to obtain the mouse position when the user enables 3D dynamic viewing, and to obtain the view matrix and projection matrix of the viewport corresponding to the mouse position;
[0169] A first conversion submodule, used for converting the mouse position into a camera coordinate system according to a view matrix to obtain a first coordinate;
[0170] A second conversion submodule, used for converting the first coordinates into a clipping space according to a projection matrix to obtain a second coordinate;
[0171] The third conversion submodule is used to perform homogeneous division on the second coordinate in the clipping space to obtain a candidate position.
[0172] In one embodiment, the second location determination module includes:
[0173] A strategy acquisition submodule is used to obtain a preset target frame generation strategy;
[0174] The target frame generation submodule is used to generate a mouse target frame corresponding to the candidate position by adopting a target frame generation strategy.
[0175] In one embodiment, the third location determination module includes:
[0176] A camera position determination submodule is used to determine the camera position; wherein the camera position is the position of the camera in the three-dimensional world;
[0177] The ray construction submodule is used to construct a ray emitted from the camera position and passing through the candidate position, and determine the constructed ray as the target ray.
[0178] In one embodiment, the third location determination module includes:
[0179] The intersection determination submodule is used to determine the intersection points of the target ray and the upper and lower surfaces of the world bounding box;
[0180] The coordinate averaging submodule is used to calculate the average coordinate value between the first intersection point and the second intersection point to obtain the target position; wherein the first intersection point is the intersection point of the target ray and the upper surface of the world bounding box, and the second intersection point is the intersection point of the target ray and the lower surface of the world bounding box.
[0181] In one embodiment, the intersection determination submodule includes:
[0182] A first equation determination unit, used to determine a parameter equation of a target ray;
[0183] A second equation determination unit, used to determine a plane equation of an upper surface of the world bounding box and a plane equation of a lower surface of the world bounding box;
[0184] A first intersection point solving unit, used to solve the intersection point of the target ray and the upper surface of the world bounding box according to the parameter equation and the plane equation of the upper surface of the world bounding box to obtain a first intersection point;
[0185] The second intersection point solving unit is used to solve the intersection between the target ray and the lower surface of the world bounding box according to the parameter aspect and the plane equation of the lower surface of the world bounding box to obtain the second intersection point.
[0186] The division of each module in the above three-dimensional coordinate mapping device is only for illustration. In other embodiments, the three-dimensional coordinate mapping device can be divided into different modules as needed to complete all or part of the functions of the above three-dimensional coordinate mapping device. Each module in the above three-dimensional coordinate mapping device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0187] In one embodiment, the present application also provides a storage medium, which stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the three-dimensional coordinate mapping method described in any of the above embodiments.
[0188] In one embodiment, the present application also provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the three-dimensional coordinate mapping method as described in any one of the above embodiments.
[0189] Indicatively, Figure 8 As shown, Figure 8 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 800 may be provided as a server. Figure 8 The computer device 800 includes a processing component 802, which further includes one or more processors, and a memory resource represented by a memory 801 for storing instructions executable by the processing component 802, such as an application. The application stored in the memory 801 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 802 is configured to execute instructions to perform the three-dimensional coordinate mapping method of any of the above embodiments.
[0190] The computer device 800 may further include a power supply component 803 configured to perform power management of the computer device 800, a wired or wireless network interface 804 configured to connect the computer device 800 to a network, and an input / output (I / O) interface 805. The computer device 800 may operate based on an operating system stored in the memory 801, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0191] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0192] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish an entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only include those elements, but also include other elements that are not clearly listed, or also include elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements. Herein, the singular "one", "one" and "described / the" may also include plural forms, unless the context clearly indicates another way. It should also be understood that the terms "include / comprise" or "have" etc. specify the existence of stated features, wholes, steps, operations, components, parts or combinations thereof, but do not exclude the possibility of the existence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the relevant listed items.
[0193] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.
[0194] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A three-dimensional coordinate mapping method, characterized in that: The method comprises: When it is detected that the user enables three-dimensional dynamic viewing, a depth map is obtained and a candidate position is determined; Based on the depth map, performing depth sampling on the candidate position; If the depth value of the corresponding position of the candidate position in the depth map is less than 1, the candidate position is determined as the position to be mapped, and the target position is determined according to the position to be mapped; If the depth value of the corresponding position of the candidate position in the depth map is equal to 1, then determine the mouse target frame corresponding to the candidate position, and traverse and sample the depths of the position points in the mouse target frame except the candidate position. When a position point with a depth value less than 1 is traversed, the position point is determined as the position to be mapped, and determine the target position according to the position to be mapped; If there is no position point with a depth value less than 1 in the mouse target frame, determine the world bounding box formed by all entities in the scene, construct a target ray, and determine the target position according to the world bounding box and the target ray; The target position is used as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
2. The three-dimensional coordinate mapping method according to claim 1, characterized in that: The step of determining the target position according to the position to be mapped comprises: Obtaining the view matrix and projection matrix of the viewport corresponding to the candidate position; Determine an inverse matrix of the view matrix and an inverse matrix of the projection matrix according to the view matrix and the projection matrix; According to the inverse matrix of the view matrix and the inverse matrix of the projection matrix, the position to be mapped is mapped to the world coordinate system to obtain a target position.
3. The three-dimensional coordinate mapping method according to claim 1, characterized in that: The step of determining the candidate position comprises: Obtain the mouse position when the user enables 3D dynamic viewing, and obtain the view matrix and projection matrix of the viewport corresponding to the mouse position; According to the view matrix, the mouse position is converted into a camera coordinate system to obtain a first coordinate; According to the projection matrix, convert the first coordinate to a clipping space to obtain a second coordinate; Performing homogeneous division on the second coordinate in the clipping space to obtain the candidate position.
4. The three-dimensional coordinate mapping method according to any one of claims 1 to 3, characterized in that: The step of determining the mouse target frame corresponding to the candidate position includes: Obtain a preset target frame generation strategy; The target aperture generation strategy is adopted to generate a mouse target aperture corresponding to the candidate position.
5. The three-dimensional coordinate mapping method according to claim 1, characterized in that: The step of constructing the target ray includes: Determine a camera position; wherein the camera position is a position of the camera in a three-dimensional world; A ray emitted from the camera position and passing through the candidate position is constructed, and the constructed ray is determined as a target ray.
6. The three-dimensional coordinate mapping method according to claim 1, characterized in that: The step of determining the target position according to the world bounding box and the target ray comprises: Determine the intersection points of the target ray and the upper and lower surfaces of the world bounding box; The average coordinate value between the first intersection point and the second intersection point is calculated to obtain the target position; wherein the first intersection point is the intersection point of the target ray and the upper surface of the world bounding box, and the second intersection point is the intersection point of the target ray and the lower surface of the world bounding box.
7. The three-dimensional coordinate mapping method according to claim 6, characterized in that: The step of determining the intersection of the target ray and the upper and lower surfaces of the world bounding box comprises: Determining a parametric equation of the target ray; Determine a plane equation of an upper surface of the world bounding box, and determine a plane equation of a lower surface of the world bounding box; Solving the intersection point between the target ray and the upper surface of the world bounding box according to the parametric equation and the plane equation of the upper surface of the world bounding box to obtain the first intersection point; According to the parameter aspect and the plane equation of the lower surface of the world bounding box, the intersection of the target ray and the lower surface of the world bounding box is solved to obtain the second intersection point.
8. A three-dimensional coordinate mapping device, characterized in that: The device comprises: An information determination module, for obtaining a depth map and determining a candidate position when it is detected that the user enables three-dimensional dynamic viewing; A depth sampling module, configured to perform depth sampling on the candidate position based on the depth map; A first position determination module, configured to determine the candidate position as a position to be mapped if the depth value of the corresponding position of the candidate position in the depth map is less than 1, and determine a target position according to the position to be mapped; A second position determination module is configured to determine a mouse target frame corresponding to the candidate position if the depth value of the corresponding position of the candidate position in the depth map is equal to 1, and traverse and sample the depths of position points other than the candidate position in the mouse target frame, and when a position point with a depth value less than 1 is traversed, determine the position point as a position to be mapped, and determine a target position according to the position to be mapped; A third position determination module is used to determine a world bounding box formed by all entities in the scene if there is no position point with a depth value less than 1 in the mouse target frame, and to construct a target ray, and to determine a target position according to the world bounding box and the target ray; The coordinate mapping module is used to use the target position as the rotation center in the three-dimensional world coordinate system to perform three-dimensional dynamic observation.
9. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the three-dimensional coordinate mapping method as described in any one of claims 1 to 7.
10. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the three-dimensional coordinate mapping method according to any one of claims 1 to 7 are performed.
