Dynamic modeling method and system for three-dimensional model
By acquiring coordinate point data in Unity in real time and generating triangles according to clockwise rules, the problem of manual dependence in the dynamic construction of 3D models is solved, realizing efficient and flexible 3D model generation and rendering, breaking the bottleneck of traditional modeling, and improving development efficiency and model generation accuracy.
Patent Information
- Application Number
- CN202511354397.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-22
- Publication Date
- 2026-01-09
AI Technical Summary
In Unity 3D scene development, existing technologies rely on manual collaboration when dynamically constructing geometric models and implementing interactive functions, resulting in high costs, low efficiency, and insufficient flexibility. Furthermore, it is difficult to generate 3D models of arbitrary shapes through code. Traditional methods require manually arranging the vertex order and triangle connections, which can easily lead to rendering anomalies.
By recognizing interactive operations, coordinate point data is obtained in real time, the geometric center point is calculated, and vertices are connected in clockwise order to generate planar triangular faces. The vertex list is copied and offset to generate the target plane, and finally the vertices are connected in order to form the side triangular faces, thus realizing the dynamic modeling of the 3D model.
It enables dynamic construction of 3D models without the need for external modeling tools, improving development efficiency, ensuring the correctness of model rendering, supporting user interaction to generate arbitrary shapes, reducing communication costs and debugging steps, and improving the flexibility of model generation and rendering adaptability.
Smart Images

Figure CN121304969A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automatic modeling technology, and in particular to a dynamic modeling method for three-dimensional models. Background Technology
[0002] Currently, in 3D scene development using Unity and other technologies, dynamically constructing geometric models and implementing interactive functions faces significant bottlenecks due to the reliance on manual collaboration in traditional modeling workflows. Any function involving models requires modelers to pre-create the model; programmers cannot directly generate geometric structures. Even simple functions require two people working together. This lengthy process, from requirements communication and model design to program integration, is not only time-consuming and labor-intensive but also often leads to misunderstandings due to developers' unclear understanding of model requirements in language or documentation. This results in discrepancies in size and shape between the modeled results and the program's expectations, necessitating repeated debugging and adjustments, further increasing communication costs. Simultaneously, existing technologies struggle to dynamically generate 3D models of arbitrary shapes based on real-time input. For dynamic scene elements such as user-interactively drawn geometry, multiple approximate models must be prepared in advance. It's impossible to dynamically generate vertex data and construct models based on real-time input such as mouse movements, severely limiting the flexibility of interactive functions. Furthermore, Unity's 3D model rendering has strict requirements for the organization of vertex coordinates and triangle indices. Traditional methods require manually arranging vertex order and triangle connection relationships. Failure to follow engine conventions such as clockwise rendering direction can easily lead to abnormal model display, further increasing development complexity. The core issue is that the modeling process heavily relies on external tools and human intervention, lacking the ability to automatically generate model data directly from user interaction. Therefore, achieving code controllability across the entire process from data acquisition and geometric calculation to model rendering, and systematically addressing the technical challenges of high cost, low efficiency, insufficient flexibility, and complex rendering adaptation in existing technologies, is a promising research direction. Summary of the Invention
[0003] In view of this, this invention proposes a dynamic modeling method and system for 3D models, which can achieve dynamic construction of 3D models without the need for external modeling tools through interactively driven real-time acquisition of vertex data, algorithmic geometric calculation, and triangle generation, significantly improving development efficiency and ensuring the correctness of model rendering. This invention provides the following technical solution: A dynamic modeling method for a 3D model, the method comprising: The system identifies interactive operations and acquires coordinate point data in the 3D scene in real time based on the interactive operations to complete the assignment of multiple vertices and form a vertex list. Calculate the geometric center point of multiple vertices based on the vertex list; Connect the vertices in the vertex list to the geometric center point in clockwise order to generate a planar triangle face index array and form an initial plane; Copy the vertex list of the initial plane and offset it by the target value in the specified direction to generate the target plane; Connect the vertices of the initial plane and the target plane in sequence to generate side triangles, thus completing the modeling of the 3D model.
[0004] Optionally, the identification of interactive operations, and the acquisition of coordinate point data in the 3D scene in real time based on the interactive operations to complete the assignment of multiple vertices and form a vertex list, includes: Listen for mouse input events using Unity's Input class, including but not limited to mouse press, mouse release, and mouse drag, and trigger specific modeling modes in response to preset shortcut key combinations; Convert screen coordinates into rays in a 3D scene, and interact with colliders in the scene through ray detection to obtain the world coordinates of the collision points as vertex data; The acquired world coordinate data is directly assigned to the corresponding elements of the vertex array to form a vertex list.
[0005] Optionally, calculating the geometric center point of multiple vertices based on the vertex list includes: Initialize the three accumulation variables to 0, traverse each vertex in the vertex list, and accumulate its X, Y, and Z coordinates into the corresponding accumulation variables respectively; Divide the accumulated variables by the number of vertices to obtain the average coordinates; A three-dimensional vector is constructed using the calculated average coordinates, which serves as the geometric center point of the vertex list.
[0006] Optionally, the step of connecting the vertices in the vertex list to the geometric center point in clockwise order to generate a planar triangle index array and form an initial plane includes: Calculate the direction vector of each vertex relative to the center point, calculate the polar angle based on the direction vector, and establish a mapping relationship between the polar angle of the vertex and the index; Sort the vertex indices in ascending order based on the polar angle values to ensure that the vertices are arranged in a clockwise direction. Traverse the sorted vertex indices, combine the center point index with the indices of the two adjacent vertices in turn, add them to the index list, and store the index list in the initialized dynamic list; The dynamic list storing the index list is converted into a fixed-length integer array, and the integer array is assigned to Unity's Mesh.triangles property to form the initial plane.
[0007] Optionally, the step of copying the vertex list of the initial plane and offsetting it by a target value along a specified direction to generate the target plane includes: Create a new vertex array of the same length as the vertex list of the initial plane, and completely copy the vertex coordinates of the initial plane; Obtain the three-dimensional offset vector based on user interaction or preset parameters; Perform vector multiplication between the three-dimensional offset vector and the target value to obtain the actual offset; Iterate through the copied vertex array, perform vector addition on each vertex, and complete the coordinate offset; A new list of vertices is constructed using the offset vertex array, serving as the geometric representation of the target plane.
[0008] Optionally, the step of sequentially connecting the vertices of the initial plane and the vertices of the target plane to generate side triangles to complete the modeling of the 3D model includes: Determine the offset correspondence between the initial plane vertex list and the target plane vertex list; The lateral triangle is formed by connecting the i-th vertex of the initial plane, the i-th vertex of the target plane, and the (i+1)-th vertex of the target plane in sequence, and the lateral triangle index is generated at the same time. Initialize a dynamic list to store the indices of the side triangles, iterate through all the side triangles generated by all vertices, and add all the indices of the side triangles to the dynamic list; The side triangle indices are merged with the triangle indices of the initial plane and the target plane to form a complete 3D model.
[0009] This invention further discloses a dynamic modeling system for three-dimensional models, comprising: The vertex assignment module is used to identify interactive operations and acquire coordinate point data in the 3D scene in real time based on the interactive operations to complete vertex assignment and form a vertex list. The center point calculation module is used to calculate the geometric center point of the vertex list based on the vertex list; The plane generation module is used to connect the vertices in the vertex list to the geometric center point in clockwise order to generate a plane triangle index array and form an initial plane; the plane generation module is also used to copy the vertex list of the initial plane and offset it by a target value in a specified direction to generate a target plane; The modeling module is used to connect the vertices of the initial plane and the vertices of the target plane in sequence to generate side triangles, thereby completing the modeling of the 3D model.
[0010] The present invention further discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method.
[0011] The present invention further discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described method.
[0012] The present invention further discloses a computer program product, including a computer program that implements the above-described method when executed by a processor.
[0013] According to the technical solution of this invention, coordinate point data is captured in real time in a Unity 3D scene by recognizing interactive operations to form a vertex list. The geometric center point is calculated by combining the CenterPosition algorithm and the vertices are connected according to the clockwise rule to generate an initial planar triangle. Then, the target plane is generated by copying the planar vertices and offsetting them along the specified direction. Finally, the upper and lower planar vertices are connected in sequence to construct the side triangles to complete the dynamic modeling of the 3D model. This solution directly converts the user's interaction trajectory into vertex data and geometric calculation logic, allowing programmers to independently complete the entire process of modeling from planar to solid without relying on modelers. It completely skips the communication costs and repeated debugging of traditional manual modeling. The clockwise triangle rendering rule ensures that the front and back of the model are displayed correctly. The model's height and other geometric dimensions are precisely controlled by parameterized offset values to achieve a "what you think is what you get" dynamic modeling effect. This significantly improves the development efficiency of Unity scenes while avoiding resource waste caused by misunderstandings of requirements. It provides a low-cost and highly flexible model generation solution for interactive 3D applications. Attached Figure Description
[0014] For illustrative and not limiting purposes, the present invention will now be described in conjunction with embodiments and accompanying drawings, wherein: Figure 1 This is a flowchart illustrating the dynamic modeling method for three-dimensional models in an embodiment of the present invention. Figure 2 This is a schematic diagram of the structure of the dynamic modeling system for the three-dimensional model in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of the electronic device in an embodiment of the present invention; Figure 4 This is a schematic diagram of the algorithm code for calculating the geometric center point in an embodiment of the present invention; Figure 5 This is a schematic diagram of the code for the initial plane and target plane vertex generation algorithm in an embodiment of the present invention; Figure 6 This is a schematic diagram of the code for the algorithm for generating the side triangles in an embodiment of the present invention; Figure 7 This is a schematic diagram of the code for the three-dimensional model data persistence algorithm in an embodiment of the present invention. Detailed Implementation
[0015] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application 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 application, and not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application.
[0016] It should be noted that, where there is no conflict, the embodiments and features of the embodiments in this application can be combined with each other. The embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0017] refer to Figure 1 This embodiment discloses a dynamic modeling method for three-dimensional models, which includes the following steps: S100: Recognize interactive operations, and acquire coordinate point data in the three-dimensional scene in real time according to the interactive operations to complete the assignment of multiple vertices and form a vertex list.
[0018] In the 3D modeling scene of an open-pit mine, the system captures the user's interactive operations on the open-pit mine terrain or equipment in real time through the Unity engine's input system to achieve vertex data acquisition of geometric models such as ore body boundaries and transportation roads. For example, when the user needs to draw the outline of a step in the open-pit mine, they can drag the mouse in the scene by holding down the left mouse button. Unity's Input.GetMouseButton(0) event is continuously triggered, and the system synchronously converts the screen coordinates into scene rays through Camera.ScreenPointToRay. It uses Physics.Raycast to detect the collision point between the ray and the open-pit mine terrain model, and assigns the world coordinates of the collision point (exemplary: Vector3(x,y,z)) directly to the vertex array to form a continuous vertex list.
[0019] In practice, users can switch modeling modes by right-clicking the mouse in the open-pit mine scene, such as "ore body outline drawing" and "road centerline drawing". The preset shortcut key Ctrl+1 can trigger the high-precision vertex acquisition mode, which generates additional vertices between adjacent vertices of the mouse drag trajectory through a linear interpolation algorithm to smooth the curve outline of the open-pit mine slope. For example, when drawing the circular ore storage bin base of the open-pit mine, the user holds down the left mouse button and drags around the center of the circle. The system obtains the coordinates of dozens of vertices in real time, forming a circular vertex list, which provides basic data for the subsequent generation of the cylindrical model. Throughout the process, the vertex list is dynamically updated with the interactive operation until the user releases the mouse button (Input.GetMouseButtonUp(0)) and the data is locked, completing the vertex assignment of the specific structure of the open-pit mine.
[0020] S200: Calculate the geometric center point of multiple vertices based on the vertex list.
[0021] refer to Figure 4 This demonstrates the algorithm for calculating the geometric center point. In the 3D modeling scenario of an open-pit mine, after acquiring the vertex data of the ore body outline or equipment structure, the system automatically calculates the geometric center point using the CenterPosition algorithm, providing a benchmark for subsequent modeling. Taking the drawing of a rectangular platform of an open-pit mine spoil heap as an example, after obtaining the vertex list (such as the transList array storing 10 3D coordinate points), the system executes the following core calculation logic: First, it initializes three accumulation variables sumX, sumY, and sumZ to 0. By traversing the vertex list: foreach(TransformtransintransList), the X, Y, and Z coordinates of each vertex are accumulated into the corresponding variables respectively. Then, the accumulated values are divided by the number of vertices (IntindexCount) to obtain the average value, i.e., X=sumX / IntindexCount, Y=sumY / IntindexCount, Z=sumZ / IntindexCount. Finally, a 3D vector newVector3(X,Y,Z) is constructed as the geometric center point.
[0022] In practical applications, this center point is used as the reference for subsequent geometric transformations. For example, when generating a model of an open-pit mine transportation road, the system first calculates the center point of the road centerline vertex list, and uses this as the origin to construct a normal vector perpendicular to the ground, ensuring that the subsequently generated road plane correctly conforms to the terrain. For irregularly shaped open-pit mine ore body contours, the system uses this algorithm to accurately calculate the geometric center, providing a basic positioning point for subsequent ore body layer modeling, reserve calculation, etc. In this embodiment, the algorithm is implemented in C# within the Unity engine, ensuring computational efficiency and geometric accuracy, enabling subsequent steps in the open-pit mine modeling process, such as plane generation and side connection, to be performed in an orderly manner based on a unified coordinate reference.
[0023] S300: Connect the vertices in the vertex list to the geometric center point in clockwise order to generate a planar triangle index array and form an initial plane.
[0024] Based on the acquired vertex list (such as the polygonal vertices of the edge of a step) and the coordinates of the center point, an initial plane is constructed using clockwise triangular face generation logic. Specifically, first, the direction vector of each vertex relative to the center point is calculated (e.g., direction=vertex-centerPoint). Then, Unity's Mathf.Atan2(direction.z,direction.x) function is used to calculate the polar angle, establishing a mapping relationship between the vertex polar angle and the index. For example, when drawing the elliptical edge of an open-pit mine, the polar angle of each vertex corresponds to its orientation on the ellipse circumference. After sorting the polar angles in ascending order, it is ensured that the vertices are arranged clockwise.
[0025] After sorting, the system initializes a dynamic list `indices` to store the triangle face indices. It then iterates through the sorted vertex indices, combining the center point index (fixed at 0) with the indices of its two adjacent vertices to form the triangle face indices. Taking a pentagonal platform as an example, after sorting the five vertices, five triangle faces are generated through a loop. Each triangle face contains a center point and two adjacent vertices, ultimately forming a closed polygonal plane. Modular operations ensure that the first and last vertices are correctly connected, preventing index out-of-bounds errors.
[0026] Finally, the dynamic list is converted into a fixed-length integer array and assigned to Unity's `Mesh.triangles` property, completing the initial plane construction. This process ensures that the vertices of the triangles are in a clockwise order, allowing Unity to correctly identify the front of the model and avoiding display anomalies caused by backface masking. For example, when generating the base plane of an open-pit mine spoil heap slope, this method can quickly convert the user-drawn irregular vertex list into a renderable triangular mesh, laying the foundation for subsequent generation of the 3D slope model.
[0027] S400: Copy the vertex list of the initial plane and offset the target value along the specified direction to generate the target plane.
[0028] refer to Figure 5 The code for the initial and target plane vertex generation algorithms is shown. Based on an already generated initial plane (such as the ore body contour surface at a certain mining level), the system generates the target plane (such as the parallel contour surface of an upper step) through vertex copying and offset operations. Specifically, the system first creates a new array (newVerts) with the same length as the initial plane vertex list (verts array). It then iterates through and copies the coordinates of each vertex (e.g., newVerts[i] = verts[i]) to ensure data independence. Subsequently, based on user-preset parameters (such as the mining height difference) or interactively specified direction vectors (such as the vertically upward Vector3(0,1,0)), the system performs vector multiplication with the target value to obtain the actual offset (e.g., offset = newVector3(0,8,0)).
[0029] In open-pit mine bench modeling, the system iterates through the copied vertex array and performs vector addition on each vertex (e.g., newVerts[i] += offset) to complete the coordinate offset. For example, when a user needs to create a new mining platform above an existing bench, the system automatically offsets all vertices of the current platform by 8 meters along the positive Y-axis to generate the vertex data for the upper platform.
[0030] Ultimately, the system uses the offset vertex array (newVerts) to construct a new planar mesh, maintaining the vertex order consistent with the initial plane, providing a foundation for subsequent side connection steps. For example, when generating a multi-level stepped model of an open-pit mine spoil heap, multiple parallel and equidistant platform planes can be quickly created by repeatedly performing the "copy-offset" operation. Combined with subsequent side connection steps, a complete three-dimensional stepped slope structure is formed. This method is implemented using Unity's Vector3 vector operations, ensuring computational efficiency and making the generation of multi-layered structures in the open-pit mine modeling process more automated and accurate.
[0031] S500: Connect the vertices of the initial plane and the target plane in sequence to generate the side triangles to complete the modeling of the three-dimensional model.
[0032] Figure 6 The code example shown illustrates the generation of side triangles. After generating vertex data for the initial plane (such as the current mining horizontal profile) and the target plane (such as the upper step profile), a specific algorithm connects the vertices of the two planes to form side triangles, ultimately constructing a complete 3D model. The specific implementation is as follows: The system first establishes an index mapping relationship between the initial plane vertex list (originalVerts) and the target plane vertex list (targetVerts), where targetVerts[i] is the corresponding point of originalVerts[i] after offset along a specified direction.
[0033] Subsequently, the system generates the side triangle indices according to the following rules: For each vertex originalVerts[i] of the initial plane, the quadrilateral side is formed by connecting the triangles twice. Taking the rectangular step of an open-pit mine as an example, first, originalVerts[i], targetVerts[i], and targetVerts[i+1] are connected to form the first triangle, as follows: Figure 6 The logic of indices.Add(i), indices.Add(i+count), and indices.Add(i+count+1) is then used to connect originalVerts[i], targetVerts[i+1], and originalVerts[i+1] to form a second triangle, as shown below. Figure 6 The functions `indices.Add(i)`, `indices.Add(i+count+1)`, and `indices.Add(i+1)` are used. Modular operations (`(i+1)%vertexCount`) ensure the correct connection of the first and last vertices, forming a closed side face. In actual open-pit mine modeling, the system iterates through all vertex pairs, generates a list of side face triangle indices using the above method, and merges it with the triangle indices of the initial plane and the target plane, as shown below. Figure 6 The `int[]indices = new int[allPoints.Count*6]` is ultimately assigned to Unity's `Mesh.triangles` property, completing the 3D model construction. For example, when generating multi-level spoil heap steps, the system quickly constructs a complete model of multiple steps by repeatedly executing the "planar copy-offset-side connection" process, ensuring that the side connections between each level are correct and conform to Unity's clockwise rendering rules, avoiding problems such as missing faces or incorrect normals in the model. This method is implemented through Unity's Vector3 vector operations and array operations, ensuring efficient computation and making the generation of 3D structures in the open-pit mine modeling process more automated and accurate.
[0034] After the 3D model of the open-pit mine is completed, the system uses the Unity rendering pipeline to achieve efficient rendering and interactive display of the model.
[0035] refer to Figure 7 This example demonstrates how to serialize a specified object using the `Serialize` method and then save its serialized data to a specified target location. A given key is used to identify the object's serialized data. In an open-pit mine 3D modeling system, Unity's `RuntimeSerialization` mechanism is used to achieve full lifecycle management of dynamic model data. Its core technical solution involves... Figure 7The Serialize method shown performs deep serialization of objects generated during the modeling process (such as vertex lists, triangle indices, material parameters, etc.). Specifically, it uses reflection to traverse all serializable fields of the target object (such as Vector3 arrays, int index arrays, Material properties), converting them into platform-independent binary byte streams and associating them with user-specified key-value pairs as data identifiers. Finally, it stores the serialized byte stream and key-value pairs in the specified target location. This solution constructs an efficient data mapping relationship through a key-value index system and uses a dictionary structure to achieve time-complexity read and write operations on serialized data. It not only meets the real-time saving requirements of the open-pit mine model state but also enables quick retrieval of historical version data through key-value pairs to roll back the modeling state. At the technical implementation level, the serialization process strictly follows the Unity object serialization specification, ensuring that complex objects such as dynamically generated Mesh components and material instances can be completely restored, while the flexible design of the target location provides a data foundation for multi-platform collaborative modeling. This solution deeply integrates persistent storage of modeling data, cross-platform exchange, performance optimization, and external system integration requirements. Meanwhile, the standardized binary data format can be directly exported as JSON or interfaced with the mining ERP system, realizing the seamless connection of modeling data from the design end to the production end, and providing underlying data support for the digital management of open-pit mines.
[0036] In summary, this invention provides a Unity-based dynamic modeling method and system for 3D models. It acquires coordinate point data from a 3D scene in real-time by recognizing interactive operations to form a vertex list. The CenterPosition algorithm is used to calculate the geometric center point, and vertices are connected clockwise to generate an initial plane. The vertex list is then copied and offset along a specified direction to generate a target plane. Finally, the vertices of the two planes are connected sequentially to generate side triangles, completing the 3D model construction. Simultaneously, leveraging Unity's RuntimeSerialization mechanism, model object fields are serialized into binary data using reflection and stored in a specified location with key-value identifiers, achieving persistence and rapid recovery of modeling data. The rendering process integrates a general rendering pipeline, configuring material textures, lighting, shadows, and post-processing effects, and improving performance through GPU instantiation, occlusion culling, and other optimization techniques. This solution breaks through the bottleneck of traditional modeling relying on manual collaboration, directly transforming user interaction into an automated modeling process. Through algorithms, it ensures accurate geometric structure and correct rendering direction, parametric offset enables flexible control of model size, serialization mechanism supports cross-platform data exchange and historical version management, and rendering pipeline optimization ensures high-fidelity display and smooth interaction in complex scenes. It significantly improves 3D modeling efficiency and data management capabilities, providing a low-cost, high-performance solution for dynamic modeling and digital applications in fields such as open-pit mines.
[0037] refer to Figure 2This embodiment further discloses a dynamic modeling system for three-dimensional models, including: The vertex assignment module 21 is used to identify interactive operations and acquire coordinate point data in the 3D scene in real time according to the interactive operations to complete vertex assignment and form a vertex list. It includes: listening to mouse input events through Unity's Input class, including but not limited to mouse press, mouse release and mouse drag, and responding to preset shortcut key combinations to trigger a specific modeling mode; converting screen coordinates into rays in the 3D scene, interacting with colliders in the scene through ray detection, and acquiring the world coordinates of the collision points as vertex data; and directly assigning the acquired world coordinate point data to the corresponding elements of the vertex array to form a vertex list.
[0038] The center point calculation module 22 is used to calculate the geometric center point of the vertex list based on the vertex list; including: initializing three accumulated variables to 0, traversing each vertex in the vertex list, and accumulating its X, Y, and Z coordinates into the corresponding accumulated variables respectively; dividing the accumulated variables by the number of vertices respectively to obtain the average coordinates; and using the calculated average coordinates to construct a three-dimensional vector as the geometric center point of the vertex list.
[0039] The plane generation module 23 is used to connect the vertices in the vertex list to the geometric center point in a clockwise order to generate a plane triangle index array and form an initial plane. This includes: calculating the direction vector of each vertex relative to the center point; calculating the polar angle based on the direction vector; establishing a mapping relationship between the polar angle of the vertex and the index; sorting the vertex indices in ascending order according to the polar angle values to ensure that the vertices are arranged in a clockwise direction; traversing the sorted vertex indices, sequentially combining the center point index with the indices of two adjacent vertices, adding them to the index list, and storing the index list in an initialized dynamic list; converting the dynamic list containing the index list into a fixed-length integer array, and assigning the integer array to Unity's Mesh.triangles property to form the initial plane.
[0040] The plane generation module 23 is further configured to copy the vertex list of the initial plane by offsetting the target value along a specified direction to generate the target plane; including: creating a new vertex array with the same length as the vertex list of the initial plane, and completely copying the vertex coordinates of the initial plane; obtaining a three-dimensional offset vector based on user interaction or preset parameters; performing vector multiplication between the three-dimensional offset vector and the target value to obtain the actual offset; traversing the copied vertex array and performing vector addition on each vertex to complete the coordinate offset; and using the offset vertex array to construct a new vertex list as the geometric representation of the target plane.
[0041] Modeling module 24 is used to sequentially connect the vertices of the initial plane and the target plane to generate side triangles to complete the modeling of the 3D model; including: determining the offset correspondence between the vertex list of the initial plane and the vertex list of the target plane; sequentially connecting the i-th vertex of the initial plane, the i-th vertex of the corresponding target plane, and the (i+1)-th vertex of the target plane to form side triangles, and generating side triangle indexes; initializing a dynamic list to store the side triangle indexes, traversing all the side triangles generated by the vertices, and adding all the side triangle indexes to the dynamic list; merging the side triangle indexes with the triangle indexes of the initial plane and the target plane to form a complete 3D model.
[0042] Figure 3 A schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, such as... Figure 3 As shown, the electronic device 50 includes: a processor 501, a memory 502, and a bus 503; The processor 501 and the memory 502 communicate with each other via the bus 503; the processor 501 is used to call the program instructions in the memory 502 to execute the methods provided in the above-described embodiments.
[0043] This embodiment provides a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to execute the methods provided in the above-described embodiments.
[0044] Those skilled in the art will understand that all or part of the steps of the above-described method implementation can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above-described method implementation. The aforementioned storage medium includes various storage media capable of storing program code, such as ROM, RAM, magnetic disk, or optical disk.
[0045] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0046] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of each embodiment or some parts of the embodiments.
[0047] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A dynamic modeling method for a three-dimensional model, characterized in that, The method includes: The system identifies interactive operations and acquires coordinate point data in the 3D scene in real time based on the interactive operations to complete the assignment of multiple vertices and form a vertex list. Calculate the geometric center point of multiple vertices based on the vertex list; Connect the vertices in the vertex list to the geometric center point in clockwise order to generate a planar triangle face index array and form an initial plane; Copy the vertex list of the initial plane and offset it by the target value in the specified direction to generate the target plane; Connect the vertices of the initial plane and the target plane in sequence to generate the side triangles, thus completing the modeling of the 3D model.
2. The dynamic modeling method for three-dimensional models according to claim 1, characterized in that, The identification of interactive operations, and the acquisition of coordinate point data in the 3D scene in real time based on the interactive operations to complete the assignment of multiple vertices and form a vertex list, includes: listening to mouse input events through Unity's Input class, including but not limited to mouse press, mouse release and mouse drag, and responding to preset shortcut key combinations to trigger specific modeling modes; Convert screen coordinates into rays in a 3D scene, and interact with colliders in the scene through ray detection to obtain the world coordinates of the collision points as vertex data; The acquired world coordinate data is directly assigned to the corresponding elements of the vertex array to form a vertex list.
3. The dynamic modeling method for three-dimensional models according to claim 1, characterized in that, The calculation of the geometric center point of multiple vertices based on the vertex list includes: Initialize the three accumulation variables to 0, traverse each vertex in the vertex list, and accumulate its X, Y, and Z coordinates into the corresponding accumulation variables respectively; Divide the accumulated variables by the number of vertices to obtain the average coordinates; A three-dimensional vector is constructed using the calculated average coordinates, which serves as the geometric center point of the vertex list.
4. The dynamic modeling method for a three-dimensional model according to claim 1, characterized in that, The step of connecting the vertices in the vertex list with the geometric center point in clockwise order to generate a planar triangle index array and form an initial plane includes: calculating the direction vector of each vertex relative to the center point, calculating the polar angle based on the direction vector, and establishing a mapping relationship between the polar angle of the vertex and the index; Sort the vertex indices in ascending order based on the polar angle values to ensure that the vertices are arranged in a clockwise direction. Traverse the sorted vertex indices, combine the center point index with the indices of the two adjacent vertices in turn, add them to the index list, and store the index list in the initialized dynamic list; The dynamic list storing the index list is converted into a fixed-length integer array, and the integer array is assigned to Unity's Mesh.triangles property to form the initial plane.
5. The dynamic modeling method for a three-dimensional model according to claim 1, characterized in that, The process of copying the vertex list of the initial plane and offsetting it by the target value along a specified direction to generate the target plane includes: Create a new vertex array with the same length as the vertex list of the initial plane, and completely copy the vertex coordinates of the initial plane; obtain the three-dimensional offset vector based on user interaction or preset parameters; Perform vector multiplication between the three-dimensional offset vector and the target value to obtain the actual offset; Iterate through the copied vertex array, perform vector addition on each vertex, and complete the coordinate offset; A new list of vertices is constructed using the offset vertex array, serving as the geometric representation of the target plane.
6. The dynamic modeling method for a three-dimensional model according to any one of claims 1-5, characterized in that, The step of sequentially connecting the vertices of the initial plane and the vertices of the target plane to generate side triangles to complete the modeling of the 3D model includes: determining the offset correspondence between the vertex list of the initial plane and the vertex list of the target plane; The lateral triangle is formed by connecting the i-th vertex of the initial plane, the i-th vertex of the target plane, and the (i+1)-th vertex of the target plane in sequence, and the lateral triangle index is generated at the same time. Initialize a dynamic list to store the indices of the side triangles, iterate through all the side triangles generated by all vertices, and add all the indices of the side triangles to the dynamic list; The side triangle indices are merged with the triangle indices of the initial plane and the target plane to form a complete 3D model.
7. A dynamic modeling system for a three-dimensional model, characterized in that, include: The vertex assignment module is used to identify interactive operations and acquire coordinate point data in the 3D scene in real time based on the interactive operations to complete vertex assignment and form a vertex list. The center point calculation module is used to calculate the geometric center point of the vertex list based on the vertex list; The plane generation module is used to connect the vertices in the vertex list to the geometric center point in clockwise order to generate a plane triangle index array and form an initial plane; the plane generation module is also used to copy the vertex list of the initial plane and offset it by a target value in a specified direction to generate a target plane; The modeling module is used to connect the vertices of the initial plane and the vertices of the target plane in sequence to generate side triangles, thereby completing the modeling of the 3D model.
8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1-6.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1-6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-6.