Method, device and equipment for picking up three-dimensional model components and storage medium
By combining ray casting and screen projection, the problem of inaccurate 3D model picking in WebGL was solved, achieving accurate picking at close range, especially for precise manipulation of point or line segment components.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIULING (JIANGSU) DIGITAL INTELLIGENT TECH CO LTD
- Filing Date
- 2021-04-29
- Publication Date
- 2026-05-05
AI Technical Summary
In WebGL-based BIM models, it is difficult for users to accurately pick 3D model components whose mouse click positions are close to but not completely within the model's pixel range.
The method combines ray detection with screen projection. It constructs detection rays to determine whether 3D model components intersect, and picks components when they intersect or are close to each other. This includes bounding box detection and triangle intersection algorithms to ensure accurate picking.
It improves the accuracy of 3D model picking and reduces the difficulty of operation, especially the picking accuracy of point or line segment components.
Smart Images

Figure CN115272605B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of building information technology, specifically to a method, apparatus, device, and storage medium for picking up three-dimensional model components. Background Technology
[0002] Building Information Modeling (BIM) is a new tool in architecture, engineering, and civil engineering, used to represent computer-aided designs that are primarily three-dimensional, object-oriented, and architecturally relevant. BIM technology plays a crucial role in improving productivity, saving costs, and shortening construction periods through the digitization and integration of building data and information models. It possesses five key characteristics: visualization, coordination, simulation, optimization, and the ability to generate drawings. WebGL is a 3D graphics protocol that enables smoother display of 3D scenes and building information models within a browser without the need for browser plugins.
[0003] When displaying a BIM model, a WebGL-based BIM engine needs to select and manipulate the BIM model based on mouse clicks. However, if a user intends to click, but the mouse position is close but not completely within the screen pixel range of the BIM model, the target model cannot be selected. Summary of the Invention
[0004] To address the shortcomings of the existing technology, this invention provides a method, apparatus, device, and storage medium for picking up three-dimensional model components. By combining ray detection with screen projection, it enables the picking of three-dimensional models within a preset pixel distance from the mouse click position, thereby improving the accuracy of picking up three-dimensional models and reducing the difficulty of operation.
[0005] To achieve the above objectives, embodiments of the present invention provide a method for picking up three-dimensional model components. The method includes: constructing a detection ray based on the position of a picking point, and determining whether the detection ray intersects with the three-dimensional model component to be picked; if it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, then obtaining a first model sub-component group of the three-dimensional model component to be picked according to a preset rule; projecting the first model sub-component group onto a display plane to obtain a second model sub-component group; determining whether the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold; and if the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group is less than the preset threshold, then picking up the three-dimensional model component to be picked.
[0006] The step of determining whether the detection ray intersects with the 3D model component to be picked further includes: determining whether the 3D model component to be picked has a bounding box; if the 3D model component to be picked has a bounding box, then acquiring the bounding box and determining whether the detection ray intersects with the bounding box; and if the 3D model component to be picked does not have a bounding box, or the 3D model component to be picked has a bounding box but it is determined that the detection ray does not intersect with the bounding box, then determining that the detection ray does not intersect with the 3D model component to be picked.
[0007] Furthermore, if at least one of the following exists, it is determined that the three-dimensional model component to be picked does not have a bounding box: the three-dimensional model component to be picked is a point component with a single vertex; or if the three-dimensional model component to be picked is a line component with two vertices, the line component is parallel to at least one of a plurality of preset planes.
[0008] The method further includes: when the bounding box exists and it is determined that the detection ray intersects with the bounding box, determining whether the polygon formed by the vertex lines of the three-dimensional model component to be picked intersects with the detection ray.
[0009] Determining whether the polygon formed by the lines connecting the vertices of the three-dimensional model component to be picked intersects with the detection ray includes: determining whether the triangle formed by the lines connecting any three vertices of the three-dimensional model component to be picked intersects with the detection ray; and if all triangles formed by the lines connecting any three vertices do not intersect with the detection ray, then determining that the detection ray does not intersect with the three-dimensional model component to be picked.
[0010] The first model sub-component group for obtaining the three-dimensional model component to be picked according to the preset rules further includes: obtaining the first model sub-component group according to the index data of the three-dimensional model component to be picked, wherein: when the three-dimensional model component to be picked only includes a point sub-component with a single vertex or a line sub-component with two vertices, the first model sub-component group is the point sub-component or the line sub-component respectively; and when the three-dimensional model component to be picked includes three-dimensional model sub-components other than point sub-components or line sub-components, the first model sub-component group includes a combination of line sub-components with two vertices formed after splitting the three-dimensional model component to be picked according to the index data.
[0011] Embodiments of the present invention also provide a device for picking up three-dimensional model components. The device includes: an acquisition module, configured to acquire a first group of model sub-components of the three-dimensional model component to be picked up according to a preset rule when it is determined that a detection ray does not intersect with the three-dimensional model component to be picked up; a projection module, configured to project the first group of model sub-components onto a display plane to obtain a second group of model sub-components; and a determination module, configured to pick up the three-dimensional model component to be picked up when it is determined that the distance between the pick point position in the display plane and at least one sub-component in the second group of model sub-components is less than a preset threshold. Further, the device also includes a judgment module, configured to construct a detection ray based on the pick point position and determine whether the detection ray intersects with the three-dimensional model component to be picked up.
[0012] Embodiments of the present invention also provide a computer device, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the computer program to implement the steps of the three-dimensional model component picking method described in any of the above embodiments.
[0013] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the three-dimensional model component picking method described in any of the above embodiments.
[0014] The advantage of this invention is that by using ray detection combined with screen projection, it is possible to pick up a 3D model within a preset pixel distance from the mouse click position. In particular, when the 3D model is only a point or line segment component, it is possible to pick up the 3D model component, thereby improving the accuracy of the user in picking up the 3D model and reducing the difficulty of operation. Attached Figure Description
[0015] The technical solution and other beneficial effects of the present invention will become apparent from the following detailed description of specific embodiments of the invention, in conjunction with the accompanying drawings.
[0016] Figure 1 A flowchart illustrating the method for picking up three-dimensional model components provided in the first embodiment of the present invention is shown.
[0017] Figure 2 This diagram illustrates another flowchart of the method for picking up three-dimensional model components provided in the first embodiment of the present invention.
[0018] Figures 3 to 6 The following are schematic diagrams illustrating application scenarios one through four of the three-dimensional model component picking method provided in the first embodiment of the present invention.
[0019] Figure 7A schematic diagram of the structure of the three-dimensional model component picking device provided in the second embodiment of the present invention is shown.
[0020] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention is shown. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0022] The terms "first," "second," "third," etc. (if present) in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the objects described in this way can be used interchangeably where appropriate. In the description of this invention, "a plurality of" means two or more, unless otherwise expressly and specifically defined. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware circuits or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0023] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection, an electrical connection, or a connection that allows for communication; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0024] To make the objectives, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0025] Figure 1A flowchart illustrating the method for picking up three-dimensional model components provided in the first embodiment of the present invention is shown. The method for picking up three-dimensional model components provided in this embodiment can be applied to computer devices. The computer device can be an electronic device with an installed drawing application, such as a smartphone, tablet computer, laptop computer, desktop computer, or personal digital assistant. This embodiment does not limit the specific form of the computer device.
[0026] Furthermore, the 3D model component picking method provided in the first embodiment of the present invention can be executed by a 3D model component picking device as provided in the second embodiment. This device can be implemented as part or all of a computer device through software, hardware, or a combination of both. The following method embodiments will use a computer device as an example to illustrate the execution subject, enabling the picking of 3D model components within a preset pixel distance from the mouse click position, for example, in a WebGL environment. This improves the accuracy of the user's picking of 3D model components and reduces the difficulty of operation.
[0027] refer to Figure 1 The method for picking up three-dimensional model components provided in the first embodiment of the present invention includes the following steps:
[0028] Step S10: Construct a detection ray based on the pickup point position, and determine whether the detection ray intersects with the three-dimensional model component to be picked;
[0029] Step S20: If it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, then the first model sub-component group of the three-dimensional model component to be picked is obtained according to the preset rules.
[0030] Step S30: Project the first model sub-component group onto the display plane to obtain the second model sub-component group;
[0031] Step S40: Determine whether the distance between the pickup point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold.
[0032] Step S50: If the distance between the pickup point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold, then the three-dimensional model component to be picked is picked.
[0033] Each step of the method described in this embodiment will be further described below.
[0034] In step S10, a Building Information Model (BIM model) can be loaded into a browser provided by a computer device using architectural software and displayed on the computer device's two-dimensional screen. After the BIM model is loaded, the data of the model components is stored in memory in the form of vertices and indices. The memory can be located in the browser, the computer's local hard drive, or a remote server; no specific limitation is made here. For each BIM model component, a unique identifier (i.e., id value), a set of vertex information, and a set of index information are recorded. Adding the BIM model component and the camera object to the three-dimensional scene (i.e., three-dimensional space) is a prerequisite for mouse picking. The three-dimensional scene refers to the three-dimensional space defined by the coordinate system of the camera viewpoint with the viewpoint (i.e., the camera) as the origin.
[0035] In this embodiment, the vertex information of the model component can be obtained through the stored index information, and the model component can be identified as a model component with multiple vertices, a point component with a single vertex, or a line component with two vertices. Specifically, the index value in the vertex data of the model component corresponds to the method of obtaining vertex information. For example, in the vertex array [v, v, v], where v represents a vertex, the index value is a type array, and its storage size determines the type of data obtained. For example, if the storage size is 1, one point is obtained from the vertex array to construct a point component; if the storage size is 2, two points are taken and connected to form a line segment; if the storage size is 3, three points are taken and connected sequentially to form an angle.
[0036] Figure 3 and Figure 4 Schematic diagrams illustrating application scenarios one and two of the three-dimensional model component picking method provided in the first embodiment of the present invention are shown respectively. Specifically, as... Figure 3 and Figure 4 As shown, camera 1 is the origin of the viewpoint in three-dimensional space, model component 2 is the model component displayed in three-dimensional space, and model component 3 is the corresponding model component displayed in screen space 4 (i.e., a two-dimensional plane) after model component 1 has undergone coordinate transformation, projection, and other operations. After loading the scene and generating the relevant data of the BIM model component, clicking on model component 3 displayed on the screen with the mouse records the screen coordinates of the mouse click position (i.e., the pick point position).
[0037] After obtaining the screen coordinates of the mouse click position, it is determined whether the detection ray intersects with the model component 2 to be picked. If the detection ray intersects with the model component 2, the model component 2 is picked directly. If the detection ray does not intersect with the model component 2, a further determination is needed using a subsequent projection method to determine whether to pick the model component 2. Figure 2This diagram illustrates another step in the method for picking up a three-dimensional model component provided in the first embodiment of the present invention. Specifically, it shows the steps for determining whether to pick up a model component using a ray-detection method, mainly including:
[0038] Step S11: Determine whether the model component has a bounding box. If it does, obtain the bounding box of the model component. If it does not, it is considered that the detection ray does not intersect with the 3D model component to be picked, and further determine whether to pick the model component by projection method.
[0039] Step S12: Determine whether the detection ray intersects with the acquired bounding box;
[0040] Step S121: When the detection ray intersects with the bounding box, it is further determined whether the polygon formed by the vertex connection of the model component intersects with the detection ray. If they intersect, the model component is picked up. If they do not intersect, it is determined that the detection ray does not intersect with the model component to be picked up, and it is necessary to further determine whether to pick up the model component by projection method.
[0041] Step S122: When the detection ray does not intersect with the bounding box, it is determined that the detection ray does not intersect with the model component to be picked up, and the projection method is needed to further determine whether to pick up the model component.
[0042] In this embodiment, with Figure 3 Taking Scene 1 as an example, detection ray 5 is set as a ray generated from camera 1 in the 3D scene as the ray origin O, passing through the mouse click position. This mouse click position can be understood as the screen coordinates of the click position or the projection coordinates of the click position in 3D space. The ray direction D of detection ray 5 can be obtained according to the following steps: transform the 2D screen coordinates D(x, y) of the click position into 3D space according to the camera projection matrix to obtain the corresponding 3D space projection point coordinates P(x', y'), set the default z coordinate value, and finally determine the ray direction D by using the 3D space projection point coordinates and the camera position coordinates.
[0043] In step S11, determining whether the detection ray intersects with the model component 2 to be picked further includes determining whether the model component 2 has a bounding box. If it does, the bounding box of the model component is obtained; if it does not, it is considered that the detection ray does not intersect with the three-dimensional model component to be picked, and the model component 2 is further determined to be picked using a projection method. In this embodiment, the bounding box refers to a cube that can contain an object.
[0044] Figure 5 The diagram illustrates scenario three of the three-dimensional model component picking method provided in the first embodiment of the present invention. Scenario three represents the case where the model component does not have a bounding box, i.e., the bounding box cannot be calculated. Specifically, as shown... Figure 5As shown, the absence of a bounding box (or the absence of a bounding box) in a model component includes at least one of the following situations: the 3D model component to be picked is a point component 41 with a single vertex; or the 3D model component to be picked is a line component 42 with two vertices (i.e., endpoints) and the line component 42 is parallel to at least one of the planes (-X, X, -Y, Y, -Z, Z) in the six directions of the Cartesian coordinate system as described below. It should be understood that the model component can be identified as a model component with multiple vertices, a point component with a single vertex, or a line component with two vertices by the aforementioned index value. When the model component does not have a bounding box, it is impossible to determine whether to pick the model component by judging whether the detection ray intersects with the bounding box (i.e., the ray method fails), so it is necessary to further determine whether to pick the model component by using the projection method.
[0045] In this embodiment, when it is determined that model component 2 has a bounding box, the bounding box of model component 2 is obtained. For ease of understanding, in Figure 3 and Figure 4 In the scenarios shown in Scene 1 and Scene 2, model component 2 is a rectangle, and its bounding box is model component 2 itself. Taking the rectangular bounding box as an example, the six planes of the bounding box can be obtained using the following planar formula:
[0046]
[0047]
[0048]
[0049] In this system, -X, X, -Y, Y, -Z, and Z are planes in six directions of the Cartesian coordinate system, and Pi is the coordinate of the vertex. The space enclosed by the intersection of these six planes is the cuboid that surrounds a model component, i.e., the rectangular bounding box.
[0050] It should be noted that the specific method for obtaining the bounding box of the model component in this step can be set by the designer according to the actual scenario and user needs. Obtaining the bounding box of the model component can be done by obtaining a preset bounding box, such as the bounding box of a pre-defined BIM model; or it can be done by generating a bounding box based on the model component. This embodiment does not impose any restrictions on this as long as the processor can obtain the bounding box of the model component in this step.
[0051] In step S12, it is determined whether the detection ray intersects with the acquired bounding box. In this embodiment, the process of determining whether the detection ray 5 intersects with the bounding box includes: Let O be the starting point of the ray, D be the direction of the ray, N be the plane normal, P0 represent a point on the plane, and P represent any point on the plane (i.e., the intersection point to be determined). When P = P0, 0·N = 0, then the plane equation (P-P0)·N = 0, so (O+D·t-P0)·N = 0, then (O-P0)·N+D·N·t = 0, finally obtaining t = (P0-O)·N / D·N (where D·N≠0). Here, t is a scalar. When t has no solution (i.e., D·N = 0), it is considered that the detection ray 5 has no intersection with the plane. After traversing all planes of the bounding box, if the detection ray 5 has no intersection with any plane, it is determined that the detection ray 5 does not intersect with the bounding box. Figure 4 As shown in Scenario 2. Conversely, when detection ray 5 intersects with at least one plane, it is determined that detection ray 5 intersects with the aforementioned bounding box, as shown in Scenario 2. Figure 3 As shown in Scenario 1.
[0052] Step S121, as follows Figure 3 As shown in Scenario 1, when the detection ray 5 intersects with the bounding box, it is further determined whether the polygon formed by the vertex connection of the model component 2 intersects with the detection ray 5. If they intersect, the operation of picking the model component 2 is directly performed. If they do not intersect, it is determined that the detection ray 5 does not intersect with the model component 2 to be picked, and it is necessary to further determine whether to pick the model component 2 through the projection method.
[0053] The following triangle intersection algorithm can be used to determine whether the polygon formed by the lines connecting the vertices of the model component 2 intersects with the detection ray: Determine whether the triangle formed by the lines connecting any three vertices of the model component 2 intersects with the detection ray 5; and when none of the triangles formed by the lines connecting any three vertices intersect with the detection ray 5, determine that the detection ray does not intersect the 3D model component to be picked. This triangle intersection algorithm can employ triangle intersection algorithms well-known to those skilled in the art, such as the centroid method or the same-direction method. Taking the centroid method of triangle intersection as an example, the three vertices of the triangle are 3D coordinate points A, B, and C obtained from the vertex list through the index information of the model component. Therefore, any point P in the plane (i.e., the intersection point to be determined) can be represented by the following equation:
[0054] P = A + u*(CA) + v*(BA)
[0055] If the coefficients u or v are negative, it's equivalent to moving in the opposite direction, i.e., the BA or CA direction. So, if we want P to be inside triangle ABC, when u = 0 and v = 0, it's point A; when u = 0 and v = 1, it's point B; and when u = 1 and v = 0, it's point C. Rearranging the equation, we get PA = u(CA) + v(BA). Let v0 = CA, v1 = BA, v2 = PA, then v2 = u*v0 + v*v1. Multiplying both sides of the equation by v0 and v1 respectively, we get two equations:
[0056] (v2)·v0=(u*v0+v*v1)·v0; and
[0057] (v2)·v1=(u*v0+v*v1)·v1
[0058] Note that u and v are numerical values, while v0, v1, and v2 are vectors, so the dot product can be expanded to obtain:
[0059] v2·v0=u*(v0·v0)+v*(v1·v0); and
[0060] v2·v1=u*(v0·v1)+v*(v1·v1)
[0061] Solving this equation yields:
[0062] u=((v1·v1)(v2·v0)-(v1·v0)(v2·v1)) / ((v0·v0)(v1·v1)-(v0·v1)(v1·v0))
[0063] v=((v0·v0)(v2·v1)-(v0·v1)(v2·v0)) / ((v0·v0)(v1·v1)-(v0·v1)(v1·v0))
[0064] To find u and v, we need to satisfy the following three conditions:
[0065] u>=0
[0066] v>=0
[0067] u+v<=1
[0068] If the detection ray intersects the triangle, it will intersect the model component. This method is used to determine the information of all intersecting model components, and the ray is picked and operated as needed.
[0069] In step S122, when the detection ray 5 does not intersect with the bounding box, it is determined that the detection ray 5 does not intersect with the model component 2 to be picked, and it is necessary to determine whether to pick up the model component 2 through subsequent projection method.
[0070] In step S20, when it is determined that the detection ray does not intersect with the 3D model component to be picked, that is, when the intersection algorithm of the detection ray and the bounding box and the triangle intersection algorithm still fail to obtain the result of picking the model component, it is necessary to perform the projection method to determine whether to pick model component 2. Specifically, the first model sub-component group is obtained according to the index data of the model component to be picked, wherein: when the model component to be picked only includes a point component with a single vertex or a line component with two vertices, the first model sub-component group is the point component or the line component respectively; and when the model component to be picked includes 3D model components other than point components or line components, the first model sub-component group includes a combination of line components with two vertices formed after splitting the 3D model component to be picked according to the index data. Specifically, two points in the vertex array are connected to form a line segment according to the index value.
[0071] In step S30, the first model sub-component group is projected onto a display plane, such as a screen, to obtain the second model sub-component group. For example, when the model component to be picked up only includes a point component with a single vertex or a line component with two vertices, the coordinates of its vertices in three-dimensional space are transformed to screen coordinates through a camera projection matrix to obtain the projected line segment on the screen; when the model component to be picked up includes three-dimensional model components other than point components or line components, similarly, the coordinates of the two endpoints (i.e., vertices) of the line segment in the split first model sub-component group in three-dimensional space are transformed to screen coordinates through a camera projection matrix to obtain the projected line segment on the screen, wherein the transformation formula from model space to screen space is:
[0072] Screen coordinates P_screen = P_world·M_camera^(-1)·M_projection;
[0073] Where P_world is the world coordinate point of the endpoint of the line segment, M_camera is the camera matrix, and M_projection is the projection matrix.
[0074] In step S40, when the distance between the pickup point position in the display plane and at least one sub-component in the second model sub-component is determined to be less than a preset threshold, the three-dimensional model component is picked. Specifically, Figure 6 This diagram illustrates an application scenario four of the three-dimensional model component picking method provided in the first embodiment of the present invention. For example... Figure 6As shown, the coordinates of endpoints A and B of line segment 31 of model component 2 in 3D space are transformed to screen coordinates (endpoint A' and endpoint B') through the camera projection matrix. The distance d between the screen position D where the mouse is clicked and the transformed projected line segment 31 is used for judgment. If the distance d is less than a preset pixel distance, the component selection result is considered successful, and the result of picking model component 2 is returned. When all line segment components in model component 2 are traversed, and the distance d between their projected line segments and the screen position D where the mouse is clicked is greater than the preset pixel distance, the result of determining that the component selection failed is obtained, and the result of not picking model component 2 is returned. Those skilled in the art should understand that the distance from the screen position point D to the projected line segment can be calculated using the tangent method or similar calculation methods well known to those skilled in the art; this embodiment does not impose any limitations on this.
[0075] Figure 7 A schematic diagram of a three-dimensional model component picking device 100 provided in a second embodiment of the present invention is shown. The device 100 includes: an acquisition module 10, configured to acquire a first group of model sub-components of the three-dimensional model component to be picked according to a preset rule when it is determined that a detection ray does not intersect with the three-dimensional model component to be picked; a projection module 20, configured to project the first group of model sub-components onto a display plane to obtain a second group of model sub-components; and a determination module 30, configured to pick the three-dimensional model component to be picked when it is determined that the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component is less than a preset threshold. The device 100 further includes a judgment module 40, configured to construct a detection ray based on the picking point position and determine whether the detection ray intersects with the three-dimensional model component to be picked.
[0076] It should also be understood that the relevant features of the second embodiment and the first embodiment can be referenced and learned from each other, and will not be described in detail here.
[0077] This invention combines ray detection and projection detection to achieve accurate pickup when the detection ray is located outside the model component but very close to it, and to accurately pickup linear and point components that cannot be detected by the detection ray.
[0078] Figure 8A schematic diagram of a computer device 200 provided in an embodiment of the present invention is shown. The computer device includes a processor 310, a memory 320, a network interface 330, a display screen 340, and an input device 350 connected via a system bus 300. The processor 310 of the computer device 200 provides computing and control capabilities. The memory 320 of the computer device 200 includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface 330 of the computer device 200 is used for communication with external computer devices via a network connection. When the computer program is executed by the processor 310, it implements a method for picking up three-dimensional model components. The display screen 340 of the computer device 200 can be a liquid crystal display screen or an electronic ink display screen. The input device 350 of the computer device 200 can be a touch layer covering the display screen 340, or buttons, a trackball, or a touchpad provided on the casing of the computer device 200, or an external keyboard, touchpad, or mouse, etc.
[0079] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0080] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor executes the computer program to perform the following steps:
[0081] A detection ray is constructed based on the pickup point location, and it is determined whether the detection ray intersects with the 3D model component to be picked. If it is determined that the detection ray does not intersect with the 3D model component to be picked, a first model sub-component group of the 3D model component to be picked is obtained according to a preset rule. The first model sub-component group is projected onto a display plane to obtain a second model sub-component group. It is determined whether the distance between the pickup point location in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold. If the distance between the pickup point location in the display plane and at least one sub-component in the second model sub-component group is less than the preset threshold, the 3D model component to be picked is picked.
[0082] For specific limitations and implementation methods of the above steps, please refer to Embodiment 1 above, which will not be repeated here.
[0083] In another embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the following steps for a method of picking up three-dimensional model components:
[0084] A detection ray is constructed based on the pickup point location, and it is determined whether the detection ray intersects with the 3D model component to be picked. If it is determined that the detection ray does not intersect with the 3D model component to be picked, a first model sub-component group of the 3D model component to be picked is obtained according to a preset rule. The first model sub-component group is projected onto a display plane to obtain a second model sub-component group. It is determined whether the distance between the pickup point location in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold. If the distance between the pickup point location in the display plane and at least one sub-component in the second model sub-component group is less than the preset threshold, the 3D model component to be picked is picked.
[0085] For specific limitations and implementation methods of the above steps, please refer to Embodiment 1 above, which will not be repeated here.
[0086] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0087] The foregoing has provided a detailed description of a method, apparatus, device, and storage medium for picking up three-dimensional model components according to embodiments of the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of the present invention. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for picking up components of a three-dimensional model, characterized in that, The method includes: A detection ray is constructed based on the pick point location, and it is determined whether the detection ray intersects with the 3D model component to be picked. If it is determined that the detection ray intersects with the three-dimensional model component to be picked, then the three-dimensional model component to be picked is picked. If it is determined that the detection ray does not intersect with the 3D model component to be picked, then according to the preset rules and the index data of the 3D model component to be picked, the first model sub-component group of the 3D model component to be picked is obtained; wherein, when the 3D model component to be picked includes 3D model sub-components other than point sub-components or line sub-components, the first model sub-component group includes a combination of line sub-components with two vertices formed after splitting the 3D model component to be picked according to the index data; The first model sub-component group is projected onto the display plane to obtain the second model sub-component group; Determine whether the distance between the pickup point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold; and If the distance between the pickup point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold, then the three-dimensional model component to be picked is picked.
2. The method for picking up three-dimensional model components as described in claim 1, characterized in that, The step of determining whether the detection ray intersects with the 3D model component to be picked further includes: Determine whether the 3D model component to be picked has a bounding box; If the 3D model component to be picked has a bounding box, then the bounding box is acquired and it is determined whether the detection ray intersects with the bounding box; and If the 3D model component to be picked does not have a bounding box, or if the 3D model component to be picked has a bounding box but it is determined that the detection ray does not intersect with the bounding box, then it is determined that the detection ray does not intersect with the 3D model component to be picked.
3. The method for picking up three-dimensional model components as described in claim 2, characterized in that, If at least one of the following exists, then the 3D model component to be picked is determined to have no bounding box: The 3D model component to be picked is a point-like component with a single vertex; or When the three-dimensional model component to be picked is a linear component with two vertices, the linear component is parallel to at least one of a plurality of preset planes.
4. The method for picking up three-dimensional model components as described in claim 2, characterized in that, The method further includes: when the bounding box exists and it is determined that the detection ray intersects with the bounding box, determining whether the polygon formed by the vertex lines of the three-dimensional model component to be picked intersects with the detection ray.
5. The method for picking up three-dimensional model components as described in claim 4, characterized in that, Determining whether the polygon formed by the lines connecting the vertices of the three-dimensional model component to be picked intersects with the detection ray includes: determining whether the triangle formed by the lines connecting any three vertices of the three-dimensional model component to be picked intersects with the detection ray; and if all triangles formed by the lines connecting any three vertices do not intersect with the detection ray, then determining that the detection ray does not intersect with the three-dimensional model component to be picked.
6. The method for picking up three-dimensional model components as described in claim 1, characterized in that, When the three-dimensional model component to be picked includes only a point sub-component with a single vertex or a line sub-component with two vertices, the first model sub-component group is the point sub-component or the line sub-component respectively.
7. A device for picking up three-dimensional model components, characterized in that, The device includes: The acquisition module is used to acquire a first model sub-component group of the three-dimensional model component to be picked, based on preset rules and the index data of the three-dimensional model component to be picked, when it is determined that the detection ray does not intersect with the three-dimensional model component to be picked. The detection ray is constructed based on the position of the picking point. Wherein, when the three-dimensional model component to be picked includes three-dimensional model sub-components other than point sub-components or line sub-components, the first model sub-component group includes a combination of line sub-components with two vertices formed after splitting the three-dimensional model component to be picked according to the index data. A projection module is used to project the first model sub-component group onto a display plane to obtain a second model sub-component group; and The determination module is used to pick up the three-dimensional model component to be picked up when the distance between the pick point position in the display plane and at least one of the sub-components in the second model sub-component is less than a preset threshold, or when the detection ray intersects with the three-dimensional model component to be picked up.
8. The three-dimensional model component picking device as described in claim 7, characterized in that, The device also includes a judgment module for constructing a detection ray based on the pickup point position and determining whether the detection ray intersects with the three-dimensional model component to be picked.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps in the method for picking up three-dimensional model components as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Interactive object pickup method based on underground three-dimensional space
CN107748643A