CN118115648A - Vector element identification method, device and equipment - Google Patents

Vector element identification method, device and equipment Download PDF

Info

Publication number
CN118115648A
CN118115648A CN202311830394.9A CN202311830394A CN118115648A CN 118115648 A CN118115648 A CN 118115648A CN 202311830394 A CN202311830394 A CN 202311830394A CN 118115648 A CN118115648 A CN 118115648A
Authority
CN
China
Prior art keywords
target
rendering
vertex
coordinates
triangle
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311830394.9A
Other languages
Chinese (zh)
Inventor
马之强
侯涛
王忆源
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Everything Mirror Beijing Computer System Co ltd
Original Assignee
Everything Mirror Beijing Computer System Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Everything Mirror Beijing Computer System Co ltd filed Critical Everything Mirror Beijing Computer System Co ltd
Priority to CN202311830394.9A priority Critical patent/CN118115648A/en
Publication of CN118115648A publication Critical patent/CN118115648A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Generation (AREA)

Abstract

The present disclosure relates to a method, an apparatus, and a device for identifying a vector element; the method relates to the technical field of computer information processing, and solves the problem that the identification cost of a single vector element in large-order vector elements is high; the method comprises the following steps: obtaining geometric information of a plurality of vector elements; triangulating the vector elements according to the geometric information of the plurality of vector elements to generate a combined rendering grid body rendered in the three-dimensional scene; determining a target triangle index of a target triangle where the preset ray intersects a target mesh body in the merging rendering mesh body; and determining the identification of the target vector element according to the target triangle index. The scheme of the present disclosure may be applicable to the identification of a single vector element of large order vector elements.

Description

Vector element identification method, device and equipment
Technical Field
The disclosure belongs to the technical field of computer information processing, and particularly relates to a method, a device and equipment for identifying vector elements.
Background
The conventional vector element monomer recognition is mainly realized by ray detection recognition or by using a space division algorithm to construct spatial indexes such as quadtrees/octrees and the like. However, when vector elements of relatively large orders of magnitude (e.g., millions) are involved, a large number of interactions are involved due to the need to construct a grid collision volume for each vector element, introduce databases and services, and consume significant computer memory and processor resources, which is costly and cumbersome to implement.
Disclosure of Invention
The embodiment of the disclosure aims to provide a method, a device and equipment for identifying vector elements, which can be suitable for identifying single vector elements in large-order vector elements.
In a first aspect, an embodiment of the present disclosure provides a method for identifying a vector element, including:
Obtaining geometric information of a plurality of vector elements;
triangulating the vector elements according to the geometric information of the plurality of vector elements to generate a combined rendering grid body rendered in the three-dimensional scene;
determining a target triangle index of a target triangle where the preset ray intersects a target mesh body in the merging rendering mesh body;
And determining the identification of the target vector element according to the target triangle index.
Optionally, triangulating the vector elements according to geometric information of the plurality of vector elements to generate a merged rendering mesh volume rendered in the three-dimensional scene, including:
performing triangular mesh division according to geometric information of a plurality of vector elements to obtain a plurality of triangular meshes;
Setting coordinates of each triangular vertex in the triangular grids to obtain a plurality of triangular grids with coordinates;
And merging the triangular grids with the coordinates to generate a merged rendering grid body rendered in the three-dimensional scene.
Optionally, merging the plurality of triangular meshes with coordinates to generate a merged rendering mesh body rendered in the three-dimensional scene, including:
Converting the identification coordinates in the triangular grids with the coordinates according to the target types to obtain a plurality of triangular grids with the coordinates of the target types;
combining a plurality of triangular grids with target type coordinates to obtain rendering data;
and performing rendering processing on the rendering data by using a preset rendering pipeline to generate a combined rendering grid body rendered in the three-dimensional scene.
Optionally, determining the target triangle index of the target triangle where the preset ray intersects the target mesh body in the merged rendering mesh body includes:
Adding collision bodies to the combined rendering grid body to obtain the combined rendering grid body supporting collision detection;
And according to the intersection of the preset ray and the target mesh body in the merging rendering mesh body supporting collision detection, obtaining a target triangle index of the target triangle.
Optionally, determining the identification of the target vector element according to the target triangle index includes:
Inquiring to obtain vertex coordinates of the target triangle according to the target triangle index;
And determining the identification of the target vector element according to the vertex coordinates.
Optionally, the method further comprises:
determining the vertex index to be modified according to the vertex index, the geometric position information and the click position information of the target triangle;
updating the geometric position information of the corresponding vertex according to the vertex index which needs to be modified;
And rendering the target grid body of the target vector element updated with the geometric position information.
Optionally, determining the vertex index to be modified according to the vertex index and the geometric position information of the target triangle and the click position information includes:
Determining vertex information to be modified according to the geometric position information and click position information of the target triangle;
And searching according to the vertex information to be modified and the vertex index of the target triangle to obtain the vertex index to be modified.
In a second aspect, an embodiment of the present disclosure provides an apparatus for identifying a vector element, including:
the acquisition module is used for acquiring geometric information of a plurality of vector elements;
the generating module is used for triangulating the vector elements according to the geometric information of the vector elements to generate a combined rendering grid body rendered in the three-dimensional scene;
The determining module is used for determining a target triangle index of a target triangle where the preset ray intersects with a target mesh body in the merging rendering mesh body;
and the identification module is used for determining the identification of the target vector element according to the target triangle index.
Optionally, the generating module includes:
The first generation sub-module is used for carrying out triangular mesh division according to the geometric information of the vector elements to obtain a plurality of triangular meshes;
The second generation submodule is used for carrying out coordinate setting on each triangular vertex in the plurality of triangular grids to obtain a plurality of triangular grids with coordinates;
and the third generation sub-module is used for merging the plurality of triangular grids with coordinates to generate a merged rendering grid body for rendering in the three-dimensional scene.
Optionally, the third generating submodule includes:
the first generation subunit is used for converting the identification coordinates in the triangular grids with the coordinates according to the target types to obtain a plurality of triangular grids with the coordinates of the target types;
the second generation subunit is used for merging a plurality of triangular grids with target type coordinates to obtain rendering data;
And the third generation subunit is used for performing rendering processing on the rendering data by using a preset rendering pipeline to generate a combined rendering grid body for rendering in the three-dimensional scene.
Optionally, the determining module includes:
The first determining sub-module is used for adding collision bodies to the combined rendering grid body to obtain the combined rendering grid body supporting collision detection;
And the second determining submodule is used for obtaining a target triangle index of the target triangle according to the intersection of the preset ray and the target grid body in the merging rendering grid body supporting collision detection.
Optionally, the identification module includes:
the first recognition sub-module is used for inquiring and obtaining vertex coordinates of the target triangle according to the target triangle index;
and the second recognition sub-module is used for determining the identification of the target vector element according to the vertex coordinates.
Optionally, the apparatus further includes:
The judging module is used for determining the vertex index to be modified according to the vertex index and the geometric position information of the target triangle and the click position information;
The updating module is used for updating the geometric position information of the corresponding vertex according to the vertex index which is modified as required;
and the rendering module is used for rendering the target grid body of the target vector element updated with the geometric position information.
Optionally, the judging module includes:
the first judging sub-module is used for determining vertex information to be modified according to the geometric position information and click position information of the target triangle;
And the second judging sub-module is used for searching according to the vertex information needing to be modified and the vertex index of the target triangle to obtain the vertex index needing to be modified.
In a third aspect, embodiments of the present disclosure provide a computing device comprising: a processor, a memory storing a computer program which, when executed by the processor, performs the steps of the method for identifying vector elements as in the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable storage medium having instructions stored thereon, which when run on a computer, cause the computer to perform the steps of the method of identifying vector elements as in the first aspect.
The technical scheme of the disclosure at least comprises the following effects:
In the embodiment of the disclosure, the vector elements are triangulated through geometric information of a plurality of vector elements to generate the merging rendering grid body, the target triangle index is determined according to the merging rendering grid body and the preset rays, the identification of the target vector elements is further determined, and the single identification of the vector elements is realized at low cost, so that the method and the device can be suitable for identifying single vector elements in large-order (such as million-level) vector elements.
Drawings
FIG. 1 is a flow chart of a method of identifying vector elements provided by an embodiment of the present disclosure;
fig. 2 is a flowchart of generating a merged rendering mesh volume rendered in a three-dimensional scene by triangulating vector elements according to geometric information of a plurality of vector elements in the method for identifying vector elements provided in an embodiment of the present disclosure;
Fig. 3 is a flowchart of merging a plurality of triangular meshes with coordinates to generate a merged rendering mesh body rendered in a three-dimensional scene in the method for identifying a vector element according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of determining a target triangle index of a target triangle where a preset ray intersects a target mesh body in a merged rendering mesh body in a method for identifying vector elements provided by an embodiment of the present disclosure;
FIG. 5 is a flowchart of determining the identity of a target vector element according to a target triangle index in a method for identifying a vector element provided by an embodiment of the present disclosure;
fig. 6 is a flowchart of determining a vertex index to be modified according to vertex index and geometric position information of a target triangle and click position information in the method for identifying a vector element according to an embodiment of the present disclosure;
FIG. 7 is a flow chart of one particular embodiment of a method of identifying vector elements provided by embodiments of the present disclosure;
Fig. 8 is a schematic diagram of triangles that form vector elements before merging in the method for identifying vector elements according to the embodiment of the present disclosure;
Fig. 9 is a schematic diagram of a merged triangle mesh in the method for identifying vector elements according to the embodiment of the disclosure;
fig. 10 is a schematic structural diagram of a device for identifying vector elements according to an embodiment of the present disclosure;
FIG. 11 is a schematic structural diagram of a computing device provided by an embodiment of the present disclosure;
fig. 12 is a schematic diagram of a hardware architecture of a computing device provided to implement an embodiment of the present disclosure.
Detailed Description
Technical solutions in the embodiments of the present disclosure will be clearly described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. All other embodiments obtained by one of ordinary skill in the art based on the embodiments in this disclosure are within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, where appropriate, such that embodiments of the disclosure may be practiced in sequences other than those illustrated and described herein, and that the objects identified by "first," "second," etc. are generally of the same type and are not limited to the number of objects, e.g., the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
Fig. 1 is a flowchart of a method for identifying a vector element according to an embodiment of the disclosure, and referring to fig. 1, the method may include the following steps:
Step 101, obtaining geometric information of a plurality of vector elements;
in the three-dimensional rendering, geometric information of vector elements generally refers to attributes such as spatial coordinates (x, y, z), shape (e.g., line, plane), size, and direction of the elements. For example, a simple geometric shape such as a square or cuboid would have the coordinates of its vertices.
102, Triangulating the vector elements according to the geometric information of a plurality of vector elements to generate a combined rendering grid body rendered in a three-dimensional scene;
Fig. 2 is a flowchart of generating a merged rendering mesh body rendered in a three-dimensional scene by triangulating vector elements according to geometric information of a plurality of vector elements in the method for identifying vector elements provided in the embodiment of the present disclosure, and referring to fig. 2, step 102 may include, when specifically implemented:
Step 1021, performing triangular mesh division according to the geometric information of the vector elements to obtain a plurality of triangular meshes;
Here, the process of converting the geometry of a vector element into a series of triangles is performed, because triangles are basic units of most graphics hardware processes, one vector element may be divided into a plurality of triangles, one vector element may be used as a triangle mesh, and a million-level vector element is formed by a plurality of triangle meshes. For example, a square may be divided into two triangles. One example is: assume a rectangle whose four vertex coordinates are (x 1, y 1), (x 2, y 2), (x 3, y 3), (x 4, y 4), respectively. This rectangle may be divided into two triangles, each triangle being defined by three vertices of the rectangle. Triangulating generally involves decomposing complex geometries into smaller triangles that can be more easily processed by a computer graphics system.
Step 1022, performing coordinate setting on each triangle vertex in the plurality of triangle grids to obtain a plurality of triangle grids with coordinates;
Specifically, the coordinate setting of each triangle vertex in the plurality of triangle meshes may be: and setting a first coordinate for describing material information and a second coordinate for describing element identification for each triangle vertex in the multiple triangular grids to obtain multiple triangular grids with coordinates.
It should be noted that, the first coordinate and the second coordinate herein refer to UV coordinates, and UV coordinates are a coordinate system for defining how the 3D model surface material is mapped. The UV coordinates describe which point in the texture image each point on the model surface corresponds to. UV coordinates are assigned to each triangle vertex to ensure that the material maps correctly onto the model. One example is: for each triangle in the rectangle, each vertex is assigned a UV coordinate that determines how the texture image is overlaid onto the triangle. The UV coordinates of the description element identification may be a method to mark different geometric elements (such as a building, a tree, a signal lamp, etc.), so that the corresponding vector elements can be identified according to the UV coordinates of the description element identification in the rendering process, and then identified and processed.
The first coordinates describing the texture information and the second coordinates describing the element identification are different and all have unique uses, and the first coordinates describing the texture information are used for texture mapping to determine the visual appearance of the model surface. The second coordinates describing element identification are used to identify different model parts or attributes in the shader program, which can be used to achieve complex rendering effects. In practical applications, how these UV coordinates are set depends on the specific model structure, texture and rendering requirements. Setting the first coordinates describing the material information and the second coordinates describing the element identification provides great flexibility so that a single model can exhibit diversified material effects and complex rendering logic.
Assuming a simple 3D model is being processed, such as a cube, two sets of UV coordinates need to be set for each of its vertices:
UV coordinates describing the texture information are set in order to use this set of UV coordinates for mapping the texture to the surface of the model. The implementation method comprises the following steps: for each face of the cube (decomposed into two triangles), each vertex is assigned one UV coordinate, which is typically in the range of (0, 0) to (1, 1), representing a position on the texture image, for example, for one face of the cube, the vertices of the two triangles may be assigned the following UV coordinates: (0, 0), (1, 1) and (0, 0), (1, 1), (0, 1).
The UV coordinates describing the element identification are set in order to use the set of UV coordinates for identifying different parts or properties of the model, such as different physical properties, animation states, etc. The implementation method comprises the following steps: each vertex of the model is assigned an additional set of UV coordinates representing the identity or type of the element, e.g., if one part of the cube is wood and the other part is metal, the vertices of the wood part may be assigned one set of UV coordinates (e.g., (0.1,0.1)), and the vertices of the metal part may be assigned another set of UV coordinates (e.g., (0.2,0.2)).
Assuming a simple 3D model (a vector element), such as a square plane, it needs to be transformed into a triangular mesh and UV coordinates set for it. First, triangular meshing is performed, wherein the geometric information of the square plane includes four vertex coordinates of the square plane, which are (0, 0), (1, 1), (0, 1), respectively. The triangular mesh division includes: the square is divided into two triangles, for example: triangle a consists of points (0, 0), (1, 1) and triangle B consists of points (0, 0), (1, 1), (0, 1). UV coordinates are then set for the triangle vertices, which define the corresponding positions of the triangle vertices on the texture image. It is assumed that a standard texture map is used, whose coordinates range from (0, 0) to (1, 1). Setting UV coordinates for triangle a includes: UV coordinates are set for the vertices of triangle a, for example, UV coordinates corresponding to vertex (0, 0) may be (0, 0), UV coordinates corresponding to vertex (1, 0) may be (1, 0), and UV coordinates corresponding to vertex (1, 1) may be (1, 1). Also, UV coordinates are set for the vertices of triangle B, for example: the UV coordinates corresponding to the vertex (0, 0) may be (0, 0), the UV coordinates corresponding to the vertex (1, 1) may be (1, 1), and the UV coordinates corresponding to the vertex (0, 1) may be (0, 1). Through these processes, the vertices of each triangle have been assigned UV coordinates. This means that when texture is applied to this model, the texture image will map to the corresponding triangle vertices according to these UV coordinates. In this embodiment, the texture will be uniformly covered over the entire square surface.
Step 1023, merging the triangular grids with coordinates to generate a merged rendering grid body rendered in the three-dimensional scene.
Fig. 3 is a flowchart of merging a plurality of triangular meshes with coordinates to generate a merged rendering mesh body rendered in a three-dimensional scene in the method for identifying vector elements according to the embodiment of the present disclosure, and referring to fig. 3, when step 1023 is specifically implemented, the method may include:
Step 10231, converting the identification coordinates in the triangular grids with the coordinates according to the target type to obtain a plurality of triangular grids with the coordinates of the target type;
Specifically, the identification coordinates of the vector element (integer int 32) are converted to floating point (float) and embedded into the UV coordinates of the last vertex of the triangle. Here, "last vertex" refers to any one of three vertices constituting a specific triangle, but the same vertex (e.g., the third vertex of each triangle) is generally selected for unification and simplification of the processing. The "last" is typically opposite, and in graphics processing, triangles are defined by three vertices, and in the disclosed embodiment, the "last vertex" typically refers to the last vertex selected when processing the vertices, typically the third vertex, this choice being to maintain consistency, ensuring that the ID data in each triangle is stored in the same location. The U value may be selected as a channel for storing an ID (identification coordinates) while the V value remains unused or used for other data. The method for storing the U value can be as follows:
Determining vertexes, wherein in each triangle, a unified vertex is selected as a 'last vertex', such as a third vertex of each triangle;
Conversion and storage converts the ID of the vector element from int32 to float and stores this value in the U coordinate of the selected vertex. Thus, each triangle will carry the identification information of the vector element to which it belongs. The vector element ID converted into the floating point number is directly stored in the U value of the last vertex, not otherwise stored. The purpose of this is to tightly combine the identification information with the mesh data so that it can be easily accessed during rendering and processing. This approach allows the IDs of the vector elements to be extracted directly from the rendering grid without the need for additional data structures.
This approach effectively integrates additional identification information into the three-dimensional rendering data while maintaining the simplicity of the data structure and the efficiency of processing. In this way, individual vector elements can be easily identified and processed at the time of rendering while supporting dynamic geometric editing and interaction.
Step 10232, merging a plurality of triangular grids with target type coordinates to obtain rendering data;
Specifically, merging the multiple triangular grids with the target type coordinates may be: combining a plurality of triangular grids with target type coordinates to obtain combined data; combining the plurality of triangular grids with the target type coordinates means combining the triangles of all the processed vector elements with related UV coordinate data, namely combining all the data such as the triangular grids, the UV coordinates describing the material information and the UV coordinates describing the element identification to obtain rendering data;
Step 10233, performing rendering processing on the rendering data by using a preset rendering pipeline to generate a merged rendering grid body rendered in the three-dimensional scene.
Specifically, the rendering data is transferred to a preset rendering pipeline, which may be a custom rendering pipeline, which is responsible for processing the rendering data and generating corresponding mesh volumes in the three-dimensional scene. One example is: in a 3D city model, the triangular mesh and UV coordinates (including the first coordinates describing the material information and the second coordinates describing the element identification) of a plurality of buildings (one building is a vector element) are combined and a complete 3D city landscape is generated through the rendering pipeline. By merging triangular meshes and using a preset rendering pipeline, a 3D scene containing a plurality of geometric objects can be effectively rendered, while maintaining high rendering efficiency and graphics quality.
Custom rendering pipelines generally refer to the customization of rendering pipelines by a user according to particular needs. Such customization may include adding, deleting, or modifying various components of the rendering pipeline, such as vertex shaders, fragment shaders, and the like. The following are key aspects that may be involved in custom rendering pipelines:
vertex Shader (Vertex Shader): vertex shaders are the first step in processing vertex data. In custom rendering pipelines, specific logic may be added to process vertex data, such as transforming coordinates, processing lighting and material properties, etc.
Fragment shader (FRAGMENT SHADER): the fragment shader handles how each pixel is rendered. Custom shading logic may be added here, such as special texture mapping, lighting effects, transparency processing, etc.
Geometry Shader (Geometry Shader): the geometry shader processes the entire primitive (e.g., triangle). In some cases, a geometry shader may be used to generate new primitives or to adjust the shape of existing primitives.
Tessellation shader (Tessel lation Shader): tessellation shaders are used to add geometric detail. This is useful when it is necessary to dynamically change the level of model detail at run-time depending on the location of the observer.
Compute Shader (computer Shader): the compute shader does not directly participate in graphics rendering, but is used to perform general purpose graphics processor computations. In some advanced custom rendering pipelines, a compute shader may be used to handle complex computing tasks such as particle systems, physical simulations, and the like.
In the custom rendering pipeline, a user may choose to add, modify, or delete any of the above components as desired. This flexibility allows the user to optimize the rendering process, achieve a particular visual effect, or adapt to particular hardware and performance requirements. For example, for some applications, it may be desirable to handle storage and retrieval of vector element IDs in a vertex shader, or to achieve specific visual effects in a fragment shader.
Step 103, determining a target triangle index of a target triangle where the preset ray intersects with a target mesh body in the merging rendering mesh body;
fig. 4 is a flowchart of determining a target triangle index of a target triangle where a preset ray intersects a target mesh body in a merged rendering mesh body in the method for identifying a vector element according to an embodiment of the present disclosure, referring to fig. 4, step 103 may include, when specifically implemented:
Step 1031, adding collision bodies to the combined rendering grid body to obtain the combined rendering grid body supporting collision detection;
Here, the collision volume refers to a collision detection mechanism added to the merged rendering mesh volume. The purpose of adding a collision volume is typically to achieve physical interactions, such as collision detection or physical response, in a rendering environment. Regarding the addition rules, these may vary depending on the particular application and need, but generally include the following aspects:
Quantity: the number of collision volumes depends on the number and complexity of vector elements that are required to physically interact. Sometimes, to optimize performance, multiple small grids may be incorporated into a large collision volume.
Position: the collision volume generally coincides with the position of its corresponding geometry. This means that the collision volume should closely surround or cover its corresponding mesh volume to ensure accurate physical interaction.
Shape: the shape of the collision body should be as closely matched as possible to its corresponding mesh body. In some cases, a simplified shape (e.g., box, sphere, or cylinder) may be used to represent a more complex geometry for improved performance.
Physical properties: depending on the application requirements, it may also be necessary to set physical properties of the collision body, such as mass, coefficient of friction and coefficient of elasticity.
Step 1032, obtaining the target triangle index of the target triangle according to the intersection of the preset ray and the target mesh in the merging rendering mesh supporting collision detection.
Here, ray detection is used to identify the batch rendering mesh volume and corresponding triangle index. Through the indexes, the ID information of the corresponding monomer element is queried in the rendering data.
In particular, in a three-dimensional graphics engine, the underlying rendering logic generally handles how three-dimensional objects are rendered onto a two-dimensional screen. This involves the entire conversion process from the basic three-dimensional model data (mesh object) to the final pixel. To obtain the corresponding mesh object and triangle index from a particular point in the three-dimensional scene (e.g., a mouse click location), a ray casting (RAY CAST ING) or ray tracing (RAY TRACING) technique is typically used. The following is a brief description of this process:
ray casting (RAY CAST ING)
Ray generation: a ray (preset ray) is emitted from the point of view of the observer (usually the camera position), which is determined by the position of the mouse on the screen. In the 3D world, this requires converting the coordinates of the screen space into coordinates of the 3D world space.
Collision detection: the rays interact with objects in the scene. This process involves traversing objects in the scene, checking whether the rays intersect them. For each object, the algorithm needs to determine whether the ray passes through the bounding box (Bounding Box) or geometry of the object.
And (3) index identification: if a ray intersects an object, rendering logic will determine which particular triangle in the object the ray intersects. This is done by calculating the potential intersection point of the ray with each triangle.
And (3) information extraction: once the intersection point is found, index information may be extracted from the intersecting triangle. In three-dimensional graphics systems, each triangle is typically defined by a vertex index, which may be used to identify the particular triangle.
Ray tracing (RAY TRACING)
The direct interaction of rays and objects is considered, and complex effects such as ray reflection and refraction can be processed. In ray-tracing based systems, intersection testing is typically more detailed, but the basic principle is similar to ray casting.
The ray tracing implementation method comprises the following steps:
graphics library (graphics API): implementation of these functions typically relies on interfaces provided by graphics APIs, such as open graphics library (OpenGL), application program interface (DirectX), drawing application program interface (Vulkan), and the like.
Scene management: most 3D engines have some form of scene management system that can efficiently organize and traverse objects in a scene.
Mathematical operation: detection of ray intersections with objects involves complex mathematical calculations, such as linear algebra operations and geometric algorithms.
By the method, the specific objects and the triangle indexes in the scene can be acquired based on the bottom rendering logic of the three-dimensional engine, so that accurate interaction and data retrieval are realized.
Step 104, determining the identification of the target vector element according to the target triangle index.
Fig. 5 is a flowchart of determining an identifier of a target vector element according to a target triangle index in the method for identifying a vector element according to an embodiment of the present disclosure, and referring to fig. 5, when step 104 is specifically implemented, the method may include:
Step 1041, inquiring to obtain vertex coordinates of the target triangle according to the target triangle index;
specifically, according to the intersection of the preset ray and the target mesh body in the merging and rendering mesh body supporting collision detection, the distance between all the vertexes of the target mesh body and the intersection point can be found, the vertex closest to the intersection point is found, and in most graphic APIs, each vertex has a unique index corresponding to the vertex, so that the index of the vertex can be retrieved from the data structure of the merging and rendering mesh body, and the vertex coordinates of the target triangle can be obtained;
Step 1042, determining the identification of the target vector element according to the vertex coordinates.
Here, since the previous step sets the first coordinates describing the material information and the second coordinates describing the element identification for each triangle vertex, the identification of the target vector element to which the vertex belongs can be obtained from the vertex coordinates, thereby determining the target vector element.
Referring to fig. 1, the method for identifying a vector element provided in the embodiment of the present disclosure further includes:
step 105, determining the vertex index to be modified according to the vertex index and the geometric position information of the target triangle and the click position information;
Fig. 6 is a flowchart of determining a vertex index to be modified according to vertex index and geometric position information and click position information of a target triangle in the method for identifying a vector element according to the embodiment of the present disclosure, and referring to fig. 6, when step 105 is specifically implemented, the method may include:
Step 1051, determining vertex information to be modified according to the geometric position information and click position information of the target triangle;
Step 1052, retrieving according to the vertex information to be modified and the vertex index of the target triangle, to obtain the vertex index to be modified.
Step 106, updating the geometric position information of the corresponding vertex according to the vertex index which needs to be modified;
Specifically, a simple three-dimensional editing application scenario is assumed. In this scenario, the shape of the model may be selected and modified by clicking on a point on the three-dimensional model. The following are steps of how this process is implemented:
A simple three-dimensional model, such as a cube, is provided whose vertex positions can be modified by clicking.
Acquiring a click position: when clicking on a screen, first, a point corresponding to the click position in three-dimensional space is determined. This typically involves converting two-dimensional screen coordinates to three-dimensional world coordinates, which can be accomplished by ray casting.
Ray casting and collision detection: a ray is issued from the camera location passing through the click location. It is detected whether the ray intersects any portion of the model. If there is an intersection, a specific location of the intersection is determined.
Determining the nearest vertex: once the intersection point is located, the next step is to find the vertex in the model that is closest to this intersection point. This is typically accomplished by calculating the distance between the intersection point and all vertices of the model, and finding the nearest vertex. For example, if the coordinates of the intersection point are (x, y, z) and each vertex of the model also has similar coordinates (x v,yv,zv), the Euclidean distance d of each vertex to the intersection point can be calculated: and selecting the vertex with the smallest distance as the vertex needing to be modified. Wherein a threshold value may be set, which is regarded as the nearest vertex only when the distance between the vertex and the intersection point is smaller than the threshold value, to improve accuracy and operation convenience.
Obtaining vertex indexes: once the nearest vertex is determined, the index of that vertex may be retrieved from the data structure of the model. In most graphics APIs, each vertex has a unique index corresponding to it.
Vertex position modification: the position of the vertex is modified as needed. For example, the vertex may be moved toward the ray intersection or moved based on the entered information. To enhance the user experience, visual or other forms of feedback may be provided near a vertex
Through the steps, the vertex index to be modified can be judged based on the vertex position information and the click position information, so that a user is allowed to intuitively edit the three-dimensional model.
Step 107, rendering the target mesh body of the target vector element with the updated geometric position information.
Here, the corresponding rendering data geometry information is modified as needed, and then the rendering update interface is called to render the target mesh body of the target vector element of which the geometry position information is updated, so as to update the data.
According to the method for identifying the vector elements, the vector elements are triangulated through geometric information of a plurality of vector elements, the merging rendering grid body is generated, the target triangle index is determined according to the merging rendering grid body and the preset rays, the identification of the target vector elements is further determined, the monomerized identification of the vector elements is realized at low cost, and the method can be suitable for identifying single vector elements in large-order (such as millions) vector elements.
All the above optional technical solutions may be combined arbitrarily to form an optional embodiment of the present disclosure, which is not described here in detail.
Referring to fig. 7, a specific embodiment of the method for identifying a vector element provided in the embodiment of the present disclosure is:
Generating batch rendering data according to the geometric information of the vector elements, writing the vector element ID into the rendering data, generating a custom batch rendering grid body component and adding a collision body. The method specifically comprises the following steps: the geometric information of a plurality of vector elements is read, triangular mesh division is carried out, the ID (int 32) of the vector elements is converted into float and stored in the UV coordinates of the last vertex of the triangle, and only U values are needed to be stored; and merging the converted rendering data of the single elements in batches, transmitting the merged rendering data into a custom rendering pipeline, generating a grid body capable of being rendered in the three-dimensional scene, and supporting collision detection.
When the monomer is identified, the ray is used for detecting the batch of rendering grid bodies and corresponding triangle indexes, and the ID information (identification coordinates) of the corresponding monomer elements is queried in the rendering data through the rendering grid bodies and the triangle indexes. The method specifically comprises the following steps: the ray detection mode is used for shooting rays from the clicking position of the mouse to be intersected with the rendering grid body generated in the last step, the corresponding grid body object and the triangle index intersected with the rays can be obtained based on the bottom rendering logic of the three-dimensional engine, and the mode is based on the operation of pixels, so that the time complexity is basically constant. According to the triangle index, inquiring UV of the last vertex of the corresponding triangle, and converting U value from float to int32 to obtain the ID of the element. Referring to fig. 8 and 9, triangles 1, 2, and 3 represent vector element 1, triangles 4, and 5 represent vector element 2, triangles 6, 7, and 8 represent vector element 3, UV coordinates of vertices 3, 6, and 9 store ID information of vector element 1, UV coordinates of vertices 12, and 15 store ID information of vector element 2, and so on, corresponding vertex indexes can be obtained from triangle indexes, and ID information of vector elements can be obtained from UV coordinates.
When dynamic geometric editing is carried out, the geometric information of the corresponding rendering data is modified according to the need, and then the rendering update interface is called to update the rendering data. The method specifically comprises the following steps: after the triangle indexes are obtained, vertex indexes and position information of corresponding triangle vertexes can be obtained, vertex indexes to be modified can be judged according to the vertex position information and click position information, geometric position information of the corresponding vertexes is modified according to the vertex indexes, then rendering data are updated, and a rendering grid body in a three-dimensional scene is updated to realize dynamic geometric editing.
Fig. 10 is a schematic structural diagram of an apparatus for identifying vector elements according to an embodiment of the present disclosure, and referring to fig. 10, the apparatus 1000 may include:
an obtaining module 1001, configured to obtain geometric information of a plurality of vector elements;
A generating module 1002, configured to triangulate the vector elements according to geometric information of the plurality of vector elements, and generate a merged rendering grid body that is rendered in the three-dimensional scene;
A determining module 1003, configured to determine a target triangle index of a target triangle where the preset ray intersects a target mesh body in the merged rendering mesh body;
the identifying module 1004 is configured to determine an identifier of the target vector element according to the target triangle index.
Optionally, the generating module 1002 includes:
The first generation sub-module is used for carrying out triangular mesh division according to the geometric information of the vector elements to obtain a plurality of triangular meshes;
The second generation submodule is used for carrying out coordinate setting on each triangular vertex in the plurality of triangular grids to obtain a plurality of triangular grids with coordinates;
and the third generation sub-module is used for merging the plurality of triangular grids with coordinates to generate a merged rendering grid body for rendering in the three-dimensional scene.
Optionally, the third generating submodule includes:
the first generation subunit is used for converting the identification coordinates in the triangular grids with the coordinates according to the target types to obtain a plurality of triangular grids with the coordinates of the target types;
the second generation subunit is used for merging a plurality of triangular grids with target type coordinates to obtain rendering data;
And the third generation subunit is used for performing rendering processing on the rendering data by using a preset rendering pipeline to generate a combined rendering grid body for rendering in the three-dimensional scene.
Optionally, the determining module 1003 includes:
The first determining sub-module is used for adding collision bodies to the combined rendering grid body to obtain the combined rendering grid body supporting collision detection;
And the second determining submodule is used for obtaining a target triangle index of the target triangle according to the intersection of the preset ray and the target grid body in the merging rendering grid body supporting collision detection.
Optionally, the identifying module 1004 includes:
the first recognition sub-module is used for inquiring and obtaining vertex coordinates of the target triangle according to the target triangle index;
and the second recognition sub-module is used for determining the identification of the target vector element according to the vertex coordinates.
Optionally, the apparatus 1000 further includes:
A judging module 1005, configured to determine, according to the vertex index and the geometric position information of the target triangle and the click position information, a vertex index to be modified;
An updating module 1006, configured to update geometric position information of the corresponding vertex according to the vertex index that needs to be modified;
A rendering module 1007 is configured to render a target mesh body of the target vector element with the updated geometric position information.
Optionally, the determining module 1005 includes:
the first judging sub-module is used for determining vertex information to be modified according to the geometric position information and click position information of the target triangle;
And the second judging sub-module is used for searching according to the vertex information needing to be modified and the vertex index of the target triangle to obtain the vertex index needing to be modified.
According to the vector element identification device in the embodiment of the disclosure, the vector elements are triangulated through geometric information of a plurality of vector elements, the merging rendering grid body is generated, the target triangle index is determined according to the merging rendering grid body and the preset rays, the identification of the target vector elements is further determined, and the vector element individuation identification is realized at low cost, so that the vector element identification device can be suitable for identifying single vector elements in large-order (such as millions) vector elements.
It should be noted that: in the vector element recognition device provided in the above embodiment, only the division of the above functional modules is used for illustration, and in practical application, the above functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the device for identifying the vector elements provided in the above embodiment and the method embodiment for identifying the vector elements belong to the same concept, and detailed implementation processes of the device are shown in the method embodiment, and are not repeated here.
The vector element identification apparatus provided in the embodiments of the present disclosure can implement each process implemented by the method embodiments of fig. 1 to 9, and in order to avoid repetition, a description is omitted here.
As shown in fig. 11, the embodiment of the disclosure further provides a computing device 1100, which includes a processor 1101 and a memory 1102 storing a computer program, where the computer program when executed by the processor performs the processes of the above embodiment of the method for identifying vector elements, and the same technical effects can be achieved, and for avoiding repetition, a detailed description is omitted herein. It should be noted that the computing devices in the embodiments of the present disclosure include mobile electronic devices and non-mobile electronic devices.
Fig. 12 is a schematic diagram of a hardware architecture of a computing device implementing an embodiment of the present disclosure.
The computing device 1200 includes, but is not limited to: radio frequency unit 1201, network module 1202, audio output unit 1203, input unit 1204, sensor 1205, display unit 1206, user input unit 1207, interface unit 1208, memory 1209, and processor 1210.
Those skilled in the art will appreciate that the computing device 1200 may also include a power source (e.g., a battery) for powering the various components, which may be logically connected to the processor 1210 by a power management system to perform functions such as managing charge, discharge, and power consumption by the power management system. The electronic device structure shown in fig. 12 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than illustrated, or may combine certain components, or may be arranged in different components, which are not described in detail herein.
It should be appreciated that in embodiments of the present disclosure, the input unit 1204 may include a graphics processor (Graphics Process ing Uni t, GPU) 12041 and a microphone 12042, the graphics processor 12041 processing image data of still pictures or video obtained by an image capturing apparatus (e.g., an image capturing device) in a video capturing mode or an image capturing mode. The display unit 1206 may include a display panel 12061, and the display panel 12061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 1207 includes a touch panel 12071 and other input devices 12072. The touch panel 12071 is also called a touch screen. The touch panel 12071 may include two parts, a touch detection device and a touch controller. Other input devices 12072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and so forth, which are not described in detail herein. Memory 1209 may be used to store software programs as well as various data including, but not limited to, application programs and an operating system. Processor 1210 may integrate an application processor that primarily processes operating systems, user interfaces, applications, etc., with a modem processor that primarily processes wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 1210.
The embodiment of the present disclosure further provides a computer readable storage medium, on which instructions are stored, which when executed on a computer, cause the computer to execute each process of the above-described vector element identification method embodiment, and achieve the same technical effects, so that repetition is avoided, and no further description is provided herein.
Wherein the processor is a processor in the computing device in the above embodiments. Readable storage media include computer readable storage media such as Read-Only Memory (ROM), random access Memory (RandomAccess Memory, RAM), magnetic or optical disks, and the like.
The embodiment of the disclosure further provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction, implement each process of the foregoing embodiment of the method for identifying a vector element, and achieve the same technical effect, so that repetition is avoided, and no further description is given here.
It should be understood that the chips referred to in the embodiments of the present disclosure may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Furthermore, it should be noted that the scope of the methods and apparatus in the embodiments of the present disclosure is not limited to performing the functions in the order shown or discussed, but may also include performing the functions in a substantially simultaneous manner or in an opposite order depending on the functions involved, e.g., the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solutions of the present disclosure may be embodied essentially or in part in the form of a computer software product stored on a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) including instructions for causing a terminal (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods of the various embodiments of the present disclosure.
The embodiments of the present disclosure have been described above with reference to the accompanying drawings, but the present disclosure is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those of ordinary skill in the art without departing from the spirit of the disclosure and the scope of the claims, which are all within the protection of the present disclosure.

Claims (10)

1. A method of identifying vector elements, comprising:
Obtaining geometric information of a plurality of vector elements;
triangulating the vector elements according to the geometric information of the plurality of vector elements to generate a combined rendering grid body rendered in the three-dimensional scene;
Determining a target triangle index of a target triangle where a preset ray intersects a target mesh body in the merging rendering mesh bodies;
And determining the identification of the target vector element according to the target triangle index.
2. The method of claim 1, wherein triangulating vector elements based on geometric information of the plurality of vector elements to generate a merged rendering mesh volume rendered in a three-dimensional scene, comprising:
performing triangular mesh division according to the geometric information of the vector elements to obtain a plurality of triangular meshes;
Setting coordinates of each triangular vertex in the plurality of triangular grids to obtain a plurality of triangular grids with coordinates;
And merging the triangular grids with the coordinates to generate a merged rendering grid body rendered in the three-dimensional scene.
3. The method of claim 2, wherein merging the plurality of triangular meshes with coordinates to generate a merged rendering mesh volume rendered in a three-dimensional scene, comprises:
converting the identification coordinates in the triangular grids with the coordinates according to the target types to obtain a plurality of triangular grids with the coordinates of the target types;
combining a plurality of triangular grids with target type coordinates to obtain rendering data;
And performing rendering processing on the rendering data by using a preset rendering pipeline to generate a combined rendering grid body for rendering in the three-dimensional scene.
4. The method of claim 1, wherein determining a target triangle index for a target triangle for which a preset ray intersects a target one of the merged rendering mesh volumes comprises:
Adding a collision body to the combined rendering grid body to obtain a combined rendering grid body supporting collision detection;
and according to the intersection of the preset ray and the target mesh body in the merging rendering mesh body supporting collision detection, obtaining a target triangle index of the target triangle.
5. The method of claim 1, wherein determining the identity of the target vector element from the target triangle index comprises:
inquiring to obtain vertex coordinates of the target triangle according to the target triangle index;
and determining the identification of the target vector element according to the vertex coordinates.
6. The method of identifying vector elements according to claim 1, further comprising:
determining the vertex index to be modified according to the vertex index, the geometric position information and the click position information of the target triangle;
updating the geometric position information of the corresponding vertex according to the vertex index which is modified as required;
And rendering the target grid body of the target vector element updated with the geometric position information.
7. The method of claim 6, wherein determining the vertex index to be modified based on the vertex index and the geometric position information and the click position information of the target triangle comprises:
determining vertex information to be modified according to the geometric position information and click position information of the target triangle;
And searching according to the vertex information to be modified and the vertex index of the target triangle to obtain the vertex index to be modified.
8. A vector element identification apparatus, comprising:
the acquisition module is used for acquiring geometric information of a plurality of vector elements;
The generating module is used for triangulating the vector elements according to the geometric information of the vector elements and generating a combined rendering grid body for rendering in the three-dimensional scene;
the determining module is used for determining a target triangle index of a target triangle where the preset ray intersects with the target mesh body in the merging rendering mesh body;
and the identification module is used for determining the identification of the target vector element according to the target triangle index.
9. A computing device, comprising: a processor, a memory storing a computer program which, when executed by the processor, performs the method of any one of claims 1 to 7.
10. A computer readable storage medium storing instructions which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 7.
CN202311830394.9A 2023-12-27 2023-12-27 Vector element identification method, device and equipment Pending CN118115648A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311830394.9A CN118115648A (en) 2023-12-27 2023-12-27 Vector element identification method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311830394.9A CN118115648A (en) 2023-12-27 2023-12-27 Vector element identification method, device and equipment

Publications (1)

Publication Number Publication Date
CN118115648A true CN118115648A (en) 2024-05-31

Family

ID=91220194

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311830394.9A Pending CN118115648A (en) 2023-12-27 2023-12-27 Vector element identification method, device and equipment

Country Status (1)

Country Link
CN (1) CN118115648A (en)

Similar Documents

Publication Publication Date Title
US20240054715A1 (en) Reduced acceleration structures for ray tracing systems
KR102003655B1 (en) Determining the Start Node for Tree Traversal for Shadow Lays in Graphics Processing
US20230053462A1 (en) Image rendering method and apparatus, device, medium, and computer program product
EP0713594B1 (en) Object-oriented rendering system
WO2002045025A9 (en) Multiple processor visibility search system and method
CN113674389B (en) Scene rendering method and device, electronic equipment and storage medium
CN110503718B (en) Three-dimensional engineering model lightweight display method
CN111127615A (en) Data scheduling method and device of three-dimensional model and electronic equipment
US20060066616A1 (en) Diffuse photon map decomposition for parallelization of global illumination algorithm
US10347034B2 (en) Out-of-core point rendering with dynamic shapes
CN117237502A (en) Three-dimensional rendering method, device, equipment and medium
Schäfer et al. Local Painting and Deformation of Meshes on the GPU
US20040012587A1 (en) Method and system for forming an object proxy
CN118115648A (en) Vector element identification method, device and equipment
Mateo et al. Hierarchical, Dense and Dynamic 3D Reconstruction Based on VDB Data Structure for Robotic Manipulation Tasks
CN113379814B (en) Three-dimensional space relation judging method and device
CN116188565A (en) Position area detection method, device, apparatus, storage medium and program product
CN114328769A (en) WebGL-based Beidou grid drawing method and device
Xu Construction of a Responsive Web Service for Smooth Rendering of Large SSC Dataset: and the Corresponding Preprocessor for Source Data
Byrne et al. Applications of the VOLA format for 3D data knowledge discovery
EP4386684A1 (en) Method for 3d visualization of sensor data
WO2024093610A1 (en) Shadow rendering method and apparatus, electronic device, and readable storage medium
WO2024027237A1 (en) Rendering optimization method, and electronic device and computer-readable storage medium
Wang et al. 3D Scene Management Method Combined with Scene Graphs.
Vyatkin et al. Comparison of Volume Rendering Methods Using GPU and Specialized Volumetric Accelerator

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination