A method, system, product, device and storage medium for constructing a virtual building
By mapping the initial model units to a cubic mesh scene on a mobile platform, performing intersection tests and segmentation rendering, the mismatch between the smoothness of the building software and the degree of editing freedom is solved, achieving efficient memory utilization and improved editing freedom.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2026-03-17
AI Technical Summary
Existing mobile platform-deployed building software suffers from a mismatch between smooth operation and editing freedom in virtual building construction. Too many basic units consume memory, leading to a decrease in smooth operation, while reducing the number of basic units reduces editing freedom.
By mapping the initial model units to a virtual scene composed of multiple cubic meshes, performing intersection tests and editing operations, dividing the data into multiple data blocks, and rendering the non-empty data blocks, the number of rendering instances is reduced, thus lowering memory usage.
It improves the smoothness of operation and the adaptability of editing freedom for building software deployed on mobile platforms, reduces memory usage, and enhances users' editing freedom.
Smart Images

Figure CN121349335B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, system, product, device and storage medium for constructing virtual buildings. Background Technology
[0002] With the widespread adoption of mobile platforms, developers have begun to explore deploying building software (such as interior design software or games with building mechanics) on mobile platforms, enabling users to construct virtual buildings with a high degree of freedom in a virtual space, thereby better meeting users' needs for creative expression.
[0003] However, existing building software deployed on mobile platforms often suffers from a mismatch between smooth operation and editing freedom. Specifically, to meet users' creative expression needs, current building software constructs as many basic building units as possible, making it easy for users to select the necessary units for creation. However, a large number of basic units consumes a significant amount of the limited memory on mobile platforms. Furthermore, when the virtual building is complex and requires a large number of basic units, the instantiation and rendering of the virtual building also leads to excessive memory consumption, resulting in a decrease in the smoothness of the building software during the presentation process. On the other hand, reducing the number of basic units to avoid memory consumption would reduce editing freedom. Therefore, improving the compatibility between smooth operation and editing freedom in building software deployed on mobile platforms has become an urgent problem to be solved. Summary of the Invention
[0004] In view of the above problems, this application provides a method, system, product, device, and storage medium for constructing virtual buildings, aiming to improve the compatibility between the smoothness of operation and the degree of editing freedom of construction software deployed on mobile platforms. The specific solution is as follows:
[0005] The first aspect of this application provides a method for constructing a virtual building, comprising:
[0006] In response to a first unit selection command sent by the interactive interface, at least one initial model unit corresponding to the unit identifier in the first unit selection command is mapped to a virtual scene. The virtual scene is composed of multiple cubic meshes. The initial model unit is a complete building or a building fragment. The building fragment is obtained by dividing the complete building.
[0007] Based on the click coordinates in the editing information sent by the interactive interface and the intersection test of each of the cube grids, the target cube grid where the modification area of the initial model unit is located is determined based on the result of the intersection test; at least the target cube grid is subjected to an editing operation corresponding to the editing operation identifier in the editing information to obtain a model unit, wherein the target cube grid is any one of the cube grids;
[0008] The virtual scene, including the model unit, is divided into multiple data blocks based on a preset segmentation size. The model slices of the model unit in each non-empty data block are rendered to obtain a virtual building. The data block types include empty data blocks and non-empty data blocks. The empty data block does not include the model slices, while the non-empty data block includes the model slices. The data block includes at least one cube mesh.
[0009] In one possible implementation, the process of generating the building fragments includes:
[0010] Obtain a virtual model of the complete building; map the virtual model of the complete building onto a preset three-dimensional mesh space, the preset three-dimensional mesh space being composed of multiple meshes;
[0011] In response to a vertex state modification command sent from the operation interface, the vertex state of each vertex of each mesh is modified, and the virtual model of the complete building is segmented and extracted based on the modified vertex states to obtain multiple building fragments of the complete building. When the vertex state is active, it indicates that the vertex is located inside the complete building, and when the vertex state is inactive, it indicates that the vertex is located outside the complete building. The active vertex is used to mark the segmentation position of the building fragment.
[0012] In one possible implementation, the method for constructing the virtual building further includes:
[0013] Obtain the building adjustment curve trajectory and the second unit selection instruction sent by the interactive interface;
[0014] The coordinates of each vertex of at least one of the initial model units corresponding to the unit identifier in the second unit selection instruction are substituted into the curve equation corresponding to the building adjustment curve trajectory to calculate the transformation matrix corresponding to each vertex coordinate. The transformation matrix includes the coordinates, normal vector and tangent vector of the adjustment curve trajectory at the vertex coordinate position. The transformation matrix represents the correction amount of the vertex coordinates fitting the building adjustment curve trajectory.
[0015] Based on the transformation matrix, the marker points of the initial model unit are corrected to obtain a deformable model unit that fits the trajectory of the building adjustment curve, and the deformable model unit is rendered to the virtual scene. The marker points are the boundary points and / or center points of the initial model unit.
[0016] In one possible implementation, before rendering the deformable model unit to the virtual scene, the method further includes:
[0017] The deformable model unit is mapped to a preset segmentation space, which is composed of multiple segmentation meshes;
[0018] Each of the multiple segmented meshes containing the deformable model unit in the preset segmented space is determined as a mesh to be processed, and each mesh to be processed is randomly processed to update the deformable model unit. The random processing includes:
[0019] The first random algorithm is invoked to randomly offset the coordinates of a first number of fixed points in each of the grids to be processed, and the offset amount is a preset value in a random direction;
[0020] And / or invoke a second random algorithm to randomly delete a second number of the grids to be processed in each of the grids to be processed;
[0021] And / or invoke a random segmentation algorithm to randomly segment a third number of the grids to be processed in each of the grids to be processed.
[0022] In one possible implementation, when the type of the building adjustment curve trajectory is a matting type, rendering the deformable model unit to the virtual scene includes:
[0023] The preset compute shader in the graphics processor is invoked to traverse each pixel of the deformable model and the curve parameter value corresponding to each pixel is parsed.
[0024] Delete the pixels whose curve parameter values are within the range of the curve parameters of the adjusted curve trajectory, and render the pixels whose curve parameter values are not within the range of the curve parameters to the virtual scene.
[0025] In one possible implementation, the model slice is a binary string.
[0026] A second aspect of this application provides a virtual building construction system, comprising:
[0027] The unit mapping module is used to respond to the first unit selection command sent by the interactive interface and map at least one initial model unit corresponding to the unit identifier in the first unit selection command to the virtual scene. The virtual scene is composed of multiple cubic meshes. The initial model unit is a complete building or a building fragment. The building fragment is obtained by dividing the complete building.
[0028] The unit editing module is used to perform an intersection test between the click coordinates in the editing information sent by the interactive interface and each of the cube grids, and to determine the target cube grid where the modification area of the initial model unit is located based on the result of the intersection test; at least the target cube grid is subjected to an editing operation corresponding to the editing operation identifier in the editing information to obtain a model unit, wherein the target cube grid is any one of the cube grids;
[0029] The model rendering module is used to divide the virtual scene including the model unit into multiple data blocks based on a preset segmentation size, and to render the model slices of the model unit in each non-empty data block to obtain a virtual building. The data block type includes empty data blocks and non-empty data blocks. The empty data block does not include the model slices, and the non-empty data block includes the model slices. The data block includes at least one of the cube meshes.
[0030] In one possible implementation, the virtual building construction system further includes a fragment generation module, which is configured during the generation of building fragments to:
[0031] Obtain a virtual model of the complete building; map the virtual model of the complete building onto a preset three-dimensional mesh space, the preset three-dimensional mesh space being composed of multiple meshes;
[0032] In response to a vertex state modification command sent from the operation interface, the vertex state of each vertex of each mesh is modified, and the virtual model of the complete building is segmented and extracted based on the modified vertex states to obtain multiple building fragments of the complete building. When the vertex state is active, it indicates that the vertex is located inside the complete building, and when the vertex state is inactive, it indicates that the vertex is located outside the complete building. The active vertex is used to mark the segmentation position of the building fragment.
[0033] In one possible implementation, the virtual building construction system further includes:
[0034] The simulation fitting module is used to obtain the building adjustment curve trajectory and the second unit selection instruction sent by the interactive interface; to substitute the vertex coordinates of at least one of the initial model units corresponding to the unit identifier in the second unit selection instruction into the curve equation corresponding to the building adjustment curve trajectory, so as to calculate the transformation matrix corresponding to each vertex coordinate. The transformation matrix includes the coordinates, normal vector, and tangent vector of the building adjustment curve trajectory at the vertex coordinate position. The transformation matrix represents the correction amount of the vertex coordinates fitting the building adjustment curve trajectory; based on the transformation matrix, the marker points of the initial model unit are corrected to obtain a deformed model unit that fits the adjustment curve trajectory, and the deformed model unit is rendered to the virtual scene. The marker points are the boundary points and / or center points of the initial model unit.
[0035] In one possible implementation, the simulation fitting module is further configured as follows:
[0036] Before rendering the deformable model unit to the virtual scene, the deformable model unit is mapped to a preset segmentation space, which is composed of multiple segmentation meshes;
[0037] Each of the multiple segmented meshes containing the deformable model unit in the preset segmented space is determined as a mesh to be processed, and each mesh to be processed is randomly processed to update the deformable model unit. The random processing includes:
[0038] The first random algorithm is invoked to randomly offset the coordinates of a first number of fixed points in each of the grids to be processed, and the offset amount is a preset value in a random direction;
[0039] And / or invoke a second random algorithm to randomly delete a second number of the grids to be processed in each of the grids to be processed;
[0040] And / or invoke a random segmentation algorithm to randomly segment a third number of the grids to be processed in each of the grids to be processed.
[0041] In one possible implementation, the simulation fitting module is configured to render the deformable model unit to the virtual scene as follows:
[0042] When the type of the building adjustment curve trajectory is the cutout type, the preset calculation shader in the graphics processor is called to traverse each pixel of the deformed model and parse the curve parameter value corresponding to each pixel.
[0043] Delete the pixels whose curve parameter values are within the range of the curve parameters of the adjusted curve trajectory, and render the pixels whose curve parameter values are not within the range of the curve parameters to the virtual scene.
[0044] In one possible implementation, the model slice is a binary string.
[0045] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the method for constructing a virtual building according to the first aspect or any implementation thereof.
[0046] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0047] The memory is used to store computer programs;
[0048] The processor is used to execute the computer program so that the electronic device can implement the method for constructing a virtual building according to the first aspect or any implementation thereof.
[0049] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to construct a virtual building according to the first aspect or any implementation thereof.
[0050] By employing the aforementioned technical solutions, this application provides a method, system, product, device, and storage medium for constructing virtual buildings. By configuring a unit selection command sent via an interactive interface, at least one initial model unit corresponding to the unit identifier in the unit selection command is mapped to a virtual scene composed of multiple cubic meshes. An intersection test is performed between the click coordinates in the editing information sent via the interactive interface and the virtual scene, and the target cubic mesh containing the modification area of the initial model unit is determined based on the intersection test results. At least one editing operation corresponding to the editing operation identifier in the editing information is performed on the target cubic mesh to obtain the model unit, allowing the user to freely edit the initial model unit. This reduces memory usage without requiring the construction of a large number of model units, while increasing editing freedom. Subsequently, by configuring the virtual scene including the model unit to be divided into multiple data blocks based on a preset segmentation size, and configuring the rendering of model slices in each non-empty data block, this application reduces the number of instances to be rendered compared to existing technologies, further reducing the memory usage on mobile platforms during rendering. Therefore, this application's improvement of the compatibility between the smoothness of operation and editing freedom of construction software deployed on mobile platforms has become an urgent problem to be solved. Attached Figure Description
[0051] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0052] Figure 1 A flowchart illustrating a method for constructing a virtual building as provided in this application;
[0053] Figure 2 This application provides a schematic diagram of the construction process of a three-dimensional planar iterator;
[0054] Figure 3 A schematic diagram of an initial model unit provided in this application;
[0055] Figure 4 A schematic diagram of a model unit provided in this application;
[0056] Figure 5 A schematic diagram of a preset three-dimensional mesh space provided in this application;
[0057] Figure 6 A schematic diagram of a building fragment provided for this application;
[0058] Figure 7 A schematic diagram of an initial model unit provided in this application;
[0059] Figure 8 A schematic diagram of a deformable model element provided in this application;
[0060] Figure 9 A schematic diagram of an initial model unit provided in this application;
[0061] Figure 10 A schematic diagram of an updated deformation model element provided in this application;
[0062] Figure 11 A block diagram of a virtual building construction system provided in this application. Detailed Implementation
[0063] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0064] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0065] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0066] The first aspect of this application provides a method for constructing a virtual building, such as... Figure 1 As shown, the method for constructing this virtual building includes:
[0067] S101. In response to the first unit selection instruction sent by the interactive interface, at least one initial model unit corresponding to the unit identifier in the first unit selection instruction is mapped to the virtual scene. The virtual scene is composed of multiple cubic meshes. The initial model unit is a complete building or a building fragment. The building fragment is obtained by dividing the complete building.
[0068] It should be noted that in practical application scenarios, the above-mentioned interactive interface can be a human-computer interaction (HCI) interface that interacts with users to exchange information, such as the game interface of game software or the operation interface of modeling software.
[0069] It should be noted that, in practical application scenarios, the aforementioned first unit selection instruction can be an instruction generated by the interactive interface based on the user's click operation on the initial model unit displayed on the interactive interface. The generation method of the aforementioned first unit selection instruction may include the following steps A1 to A3.
[0070] Step A1: Collect the coordinates of the user's click location on the interactive interface. Then trigger step A2.
[0071] Step A2: Query the target initial model unit display area where the clicked location coordinates are located. Then trigger step A2.
[0072] In one possible implementation, the target initial model unit display area in step A2 above can be a set of pixel coordinates of a rectangular area in the interactive interface. An interactive interface can include multiple initial model unit display areas.
[0073] Step A3: Based on the preset mapping relationship list, extract the unit identifier of the initial model unit corresponding to the target initial model unit display area determined in Step A2, and generate the first unit selection instruction based on the unit identifier.
[0074] In one possible implementation, the preset mapping relationship list in step A3 above stores the unit identifier of each initial model unit and the set of pixel coordinates of the corresponding initial model unit display area.
[0075] It should be noted that, in actual application scenarios, the division size of the above-mentioned 3D grid can be set according to the actual application scenario and scaled proportionally according to the display ratio of the current interactive interface.
[0076] It should be noted that in practical applications, the position of the initial model unit in the virtual scene is randomized due to user dragging and other operations. Furthermore, existing technologies often use unstructured meshes (such as triangles, quadrilaterals, and polygons) to divide the virtual scene for fitting complex shapes. This leads to differences in the standards for determining the position of different unstructured meshes relative to the virtual scene, resulting in relative coordinate offsets and affecting the accuracy of subsequent model editing. This application, however, maps at least one initial model unit corresponding to the unit identifier in the first unit selection instruction to a virtual scene composed of multiple cubic meshes. This utilizes identical cubic meshes to equally divide the virtual scene, unifying the reference for global coordinates, avoiding relative coordinate offsets, and improving the accuracy of subsequent model editing.
[0077] S102. Based on the click coordinates in the editing information sent by the interactive interface and the intersection test of each cube grid, determine the target cube grid where the modification area of the initial model unit is located based on the result of the intersection test; perform at least one editing operation on the target cube grid corresponding to the editing operation identifier in the editing information to obtain the model unit, where the target cube grid is any one of the cube grids.
[0078] It should be noted that, in practical applications, the aforementioned intersection test methods are commonly used in computer graphics to detect whether multiple geometric objects (points, lines, surfaces, and volumes) intersect (i.e., intersect in space). This application achieves the determination of the location of the modification area in the initial model unit that the user expects to edit by configuring the click coordinates in the editing information sent based on the interactive interface and each cube mesh for intersection testing.
[0079] It should be noted that in practical application scenarios, the intersection test between the click coordinates in the editing information sent through the interactive interface and the virtual scene can be achieved through a preset intersection test algorithm. Considering that the virtual scene in this solution is a three-dimensional scene, the developers of this application have replaced the two-dimensional plane iterator with a three-dimensional plane iterator based on the existing two-dimensional intersection test algorithm. There are various ways to construct the three-dimensional plane iterator; one example is provided here:
[0080] like Figure 2 The diagram shown illustrates the construction process of a three-dimensional planar iterator. The specific steps are as follows:
[0081] Step S201: Obtain the coordinates of each vertex of the incoming ray and the cube mesh. Then trigger step S202.
[0082] In one possible implementation, the aforementioned incoming ray can be a ray originating from the visual center point of the interactive interface and passing through the click coordinates when a developer clicks on the interface in the development scenario. The coordinates of each vertex of the aforementioned cube mesh can be the coordinates of each vertex of the cube mesh that the developer expects to select in the development scenario within the virtual space.
[0083] In one possible implementation, to further optimize the 3D plane iterator, the vertex coordinates of the input ray and the cube mesh can be obtained in multiple sets, and the process can be executed multiple times based on each set. Figure 2 The steps shown are for optimizing the internal parameters of the 3D plane iterator.
[0084] Step S202: Based on the vertex coordinates of the cube mesh in step S201, construct the detection range representing the spatial position of the cube mesh. Then trigger step S203.
[0085] Step S203: Determine whether the incoming ray intersects with the detection range. If yes, trigger step S204. If no, trigger step S211.
[0086] Those skilled in the art will understand that step S203 above can be implemented using existing intersection detection algorithms, such as the slab algorithm for ray-axis aligned bounding box (AABB) intersection detection. This application does not impose excessive limitations or elaborate on the specific detection process of the above slab algorithm.
[0087] Step S204: Determine the rays intersecting the plane based on the intersection. This triggers step S205.
[0088] Step S205: Initialize the three-dimensional plane iterator and call the three-dimensional plane iterator to calculate the distance between the intersection of the current plane and the ray and the plane intersection in the current plane group. Then trigger step S206.
[0089] It should be noted that the aforementioned current plane group can be a combination of planes of a cube mesh in the three directions of the X, Y, and Z axes, including front-back plane groups, top-bottom plane groups, and left-right plane groups. The aforementioned current plane can be a plane in a plane group, such as the front or back in the front-back plane group.
[0090] Step S206: Determine the plane containing the minimum value of the three distances calculated in step S205 as the target plane, and extract the intersection information of the intersection points within the target plane.
[0091] In one possible implementation, the intersection information in step S206 above includes the spatial coordinates and normal vector of the intersection.
[0092] Step S207: Call the preset predicate function to determine whether the intersection information obtained in step S206 meets the verification conditions. If yes, then trigger step S211; otherwise, trigger step S208.
[0093] Step S208: Optimize the internal parameters of the 3D plane iterator based on the difference between the intersection information and the threshold in the verification conditions. This triggers step S209.
[0094] Step S209: Determine whether the optimized 3D plane iterator exceeds the detection range. If yes, trigger step S211; otherwise, trigger step S210.
[0095] It should be noted that, in practical application scenarios, the specific implementation of step S209 above can be whether the optimized three-dimensional plane iterator is only used to calculate the intersection of the effective ray relative to the three sets of plane groups.
[0096] Step S210: Update the current plane to another plane in the current plane group. And trigger step S205.
[0097] Step S211, End.
[0098] It should be noted that, in practical applications, the types of editing operations mentioned above include at least adding, deleting, and rotating.
[0099] It should be noted that in practical applications, there are multiple ways to perform the above-mentioned editing operation on the target cube mesh corresponding to the editing operation identifier in the editing information to obtain the model unit. Here, one example is provided:
[0100] like Figure 3 The diagram shows a schematic of the initial model unit. The cube formed by black lines, indicated by the black arrow, is the target cube mesh. The cubes formed by the two black lines adjacent to the target cube mesh are the adjacent cube meshes of the target cube mesh. If a deletion-type edit operation is performed on the target cube mesh, this can be achieved by setting the state of each vertex of the target cube mesh to an inactive state. The inactive state indicates that the cube mesh containing that node is located outside the initial model unit (i.e., deleted). After performing the deletion-type edit operation, the schematic diagram of the obtained model unit is as follows. Figure 4 As shown. It should be noted that after deleting the target cube mesh, there may be image gaps for the adjacent cube meshes. Therefore, while performing the editing operation corresponding to the editing operation identifier in the editing information on at least the target cube mesh, the adjacent cube meshes of the target cube mesh can also be edited. Specifically, the adjacent cube meshes are copied and added in situ, and the initial model units in the copied adjacent cube meshes are rotated axially, with the rotation direction pointing towards the contact surface between the target cube mesh and the adjacent cube meshes.
[0101] S103. Based on the preset segmentation size, the virtual scene including model units is divided into multiple data blocks, and the model slices of the model units in each non-empty data block are rendered to obtain a virtual building. The data block type includes empty data blocks and non-empty data blocks. Empty data blocks do not include model slices, while non-empty data blocks do include model slices. Each data block includes at least one cube mesh.
[0102] It should be noted that, in practical applications, the size of the data blocks obtained by segmentation based on the preset segmentation size is not smaller than the size of the cube mesh. Because existing rendering processes typically render the entire virtual scene as a whole, including the already rendered background and the model units to be rendered, this causes the Graphics Processing Unit (GPU) to repeatedly consume memory to render the already rendered background. Furthermore, the large number of objects to be rendered in the entire virtual scene further exacerbates memory consumption, severely impacting the smoothness of mobile platform operation. Therefore, this application configures the virtual scene, including model units, to be segmented into multiple data blocks based on a preset segmentation size, and renders model slices of model units in each non-empty data block. This reduces memory consumption per rendering cycle and minimizes repeated rendering, further reducing memory usage and improving operational smoothness.
[0103] This application configures a unit selection command sent via an interactive interface to map at least one initial model unit corresponding to the unit identifier in the command to a virtual scene composed of multiple cubic meshes. It performs an intersection test between the click coordinates in the editing information sent via the interactive interface and the virtual scene, and determines the target cubic mesh where the modification area of the initial model unit is located based on the intersection test results. At least one editing operation corresponding to the editing operation identifier in the editing information is performed on the target cubic mesh to obtain the model unit, allowing the user to freely edit the initial model unit. This reduces memory usage without requiring the construction of a large number of model units, while increasing editing freedom. Subsequently, by configuring the virtual scene including the model unit to be divided into multiple data blocks based on a preset segmentation size, and configuring the rendering of model slices in each non-empty data block, this application reduces the number of instances to be rendered compared to existing technologies, further reducing the memory usage on mobile platforms during rendering. Therefore, this application's improvement of the compatibility between the smoothness of operation and editing freedom of building software deployed on mobile platforms has become an urgent problem to be solved.
[0104] In one possible implementation, the process of generating the aforementioned architectural fragments includes:
[0105] Obtain a virtual model of the complete building; map the virtual model of the complete building onto a preset 3D mesh space, which consists of multiple meshes;
[0106] In response to the vertex state modification operation command sent by the operation interface, the vertex state of each vertex in each grid is modified, and the virtual model of the complete building is segmented and extracted based on the modified vertex state to obtain multiple building fragments of the complete building. When the vertex state is active, it indicates that the vertex is located inside the complete building, and when the vertex state is inactive, it indicates that the vertex is located outside the complete building. The active vertices are used to mark the segmentation position of the building fragments.
[0107] It should be noted that, in practical application scenarios, the above explanation is provided in conjunction with one possible implementation of this application to facilitate understanding of the generation process of the aforementioned building fragments:
[0108] like Figure 5 The image shown is a schematic diagram of a preset three-dimensional grid space. Figure 5 The virtual model of the complete building has been mapped onto the preset three-dimensional mesh space. It can be seen that some vertices of the mesh are located outside the complete building, and some vertices of the mesh are located inside the complete building. At this time, the vertex states of the mesh are all inactive.
[0109] Subsequently, operators manually annotated and modified the vertex states of each grid on the interface. Based on these modifications, the virtual model segmentation direction of the complete building within each grid was determined and segmented. This resulted in the following: Figure 6 The building fragments shown.
[0110] In one possible implementation, the steps of modifying the vertex states of each vertex in the aforementioned meshes and segmenting and extracting the virtual model of the complete building based on the modified vertex states can also be implemented through an operation script. The operation script activates the vertex states of mesh vertices located inside the complete building based on a preset activation rule. The preset activation rule can be: traversing each mesh in a preset 3D mesh space, identifying meshes with at least one vertex located outside the complete building and at least one vertex located inside the complete building as meshes to be processed, identifying a mesh plane in the meshes to be processed that includes one vertex in an inactive state and one vertex in an active state as a cutting surface, and segmenting and extracting the virtual model of the complete building based on the cutting surface.
[0111] It should be noted that, in practical applications, since the vertices in the aforementioned active states are located on the segmentation plane and within the complete building, they represent the segmentation locations of the building fragments. Furthermore, the coordinates of at least one active vertex can be used to determine the unit identifier of the building fragment representing its location.
[0112] In one possible implementation, the method for constructing a virtual building provided in the first aspect of this application further includes:
[0113] Receive the building adjustment curve trajectory and the second unit selection instruction sent by the interactive interface;
[0114] The coordinates of each vertex of at least one initial model unit corresponding to the unit identifier in the second unit selection instruction are substituted into the curve equation corresponding to the building adjustment curve trajectory to calculate the transformation matrix corresponding to each vertex coordinate. The transformation matrix includes the coordinates, normal vector and tangent vector of the adjustment curve trajectory at the vertex coordinate position. The transformation matrix represents the correction amount of the vertex coordinates fitting to the building adjustment curve trajectory.
[0115] The marker points of the initial model unit are corrected based on the transformation matrix to obtain a deformable model unit that fits the trajectory of the building adjustment curve. The deformable model unit is then rendered into the virtual scene. The marker points are the boundary points and / or center points of the initial model unit.
[0116] It should be noted that, in practical application scenarios, the building adjustment curve trajectory sent by the above-mentioned interactive interface can be the trajectory of the user adjusting the rendered virtual building again in the interactive interface, or it can be the trajectory drawn independently in the virtual scene.
[0117] Those skilled in the art will understand that, in practical applications, the curve equation corresponding to the aforementioned building adjustment curve trajectory can be generated using a curve generation algorithm based on the coordinates of each trajectory point of the building adjustment curve trajectory sent through the interactive interface. Mr. Qu stated that there are various types of algorithms, including but not limited to: polynomial fitting algorithms, spline fitting algorithms, and Bézier curve algorithms. This application does not impose excessive limitations or elaborate on the specific types of the aforementioned curve generation algorithms, nor on the specific process of obtaining the aforementioned curve equation.
[0118] It should be noted that in practical applications, the aforementioned transformation matrix can be a composite transformation matrix, which is composed of translation, rotation, scaling, and other matrices combined through matrix multiplication. This application calculates the transformation matrix corresponding to each vertex coordinate and uses the transformation matrix to characterize the correction amount by which the vertex coordinates fit the building adjustment curve trajectory. This reduces the number of initial model units while correcting the marker points of the initial model units based on the transformation matrix, obtaining deformable model units that fit the building adjustment curve trajectory, further improving editing freedom.
[0119] To facilitate understanding of the above-mentioned deformable model elements, a possible implementation of this application is described here:
[0120] like Figure 7 The diagram shows the initial model unit corresponding to the unit identifier in the second unit selection instruction. It is a standard cylindrical shape. Assuming the building adjustment curve trajectory is an "S" shaped curve, then after the above processing, the schematic diagram of the obtained deformable model unit can be shown as follows. Figure 8 As shown, the black curve pointed to by the black arrow is the trajectory of the building adjustment curve.
[0121] In one possible implementation, before rendering the deformable model unit to the virtual scene, the following is also included:
[0122] The deformable model elements are mapped to a preset segmentation space, which consists of multiple segmentation meshes.
[0123] The multiple segmented meshes containing the deformable model elements in the preset segmented space are determined as the meshes to be processed, and each mesh to be processed is randomly processed to update the deformable model elements. The random processing includes:
[0124] The first random algorithm is called to randomly offset the coordinates of the first number of fixed points in each grid to be processed. The offset amount is a preset value in a random direction.
[0125] And / or invoke a second random algorithm to randomly delete a second number of grids in each grid to be processed;
[0126] And / or invoke a random segmentation algorithm to randomly segment the third number of grids in each grid to be processed.
[0127] It should be noted that in practical applications, although the deformable model units change the shape of the model to fit the trajectory freely drawn by the user, thus increasing the degree of editing freedom, the details of the model still maintain their state at the time of construction. For example: Figure 9 The image shows the initial model unit of the city wall, where the bricks are uniformly arranged. This application, however, configures multiple segmented meshes containing the deformable model units within a pre-defined segmented space as meshes to be processed, and randomly processes each mesh to update the deformable model units. This random modification of the deformable model units further enhances the degree of editing freedom. For example, as... Figure 10 As shown, this is for Figure 9 The diagram shows the updated and deformed model units obtained after applying the above random processing strategies to the initial model units of the city wall. It can be seen that the bricks of the city wall are not evenly distributed, and there are some missing pieces and different sizes, which is closer to the texture of a real city wall.
[0128] In one possible implementation, when the type of the building adjustment curve trajectory is a matting type, the deformable model unit is rendered to the virtual scene, including:
[0129] The preset compute shader in the graphics processor is called to traverse each pixel of the deformable model and parse the curve parameter value corresponding to each pixel.
[0130] Delete pixels whose curve parameter values are within the range of curve parameters for adjusting the curve trajectory, and render pixels whose curve parameter values are not within the range of curve parameters to the virtual scene.
[0131] In one possible implementation, the model slices are binary strings.
[0132] It should be noted that this application configures the model slices as binary strings, thereby reducing the amount of data in the model slices during the waiting period before rendering, thus reducing memory usage.
[0133] The second aspect of this application provides a virtual building construction system, such as... Figure 11 As shown, the construction system for this virtual building includes:
[0134] The unit mapping module 1101 is used to respond to the first unit selection instruction sent by the interactive interface and map at least one initial model unit corresponding to the unit identifier in the first unit selection instruction to the virtual scene. The virtual scene is composed of multiple cubic meshes. The initial model unit is a complete building or a building fragment. The building fragment is obtained by dividing the complete building.
[0135] The unit editing module 1102 is used to perform intersection tests on the click coordinates and each cube grid based on the editing information sent by the interactive interface, and to determine the target cube grid where the modification area of the initial model unit is located based on the results of the intersection tests; at least the target cube grid is subjected to the editing operation corresponding to the editing operation identifier in the editing information to obtain the model unit, wherein the target cube grid is any one of the cube grids;
[0136] The model rendering module 1103 is used to divide a virtual scene including model units into multiple data blocks based on a preset segmentation size, and to render the model slices of the model units in each non-empty data block to obtain a virtual building. The data block types include empty data blocks and non-empty data blocks. Empty data blocks do not contain model slices, while non-empty data blocks do contain model slices. Each data block includes at least one cubic mesh.
[0137] In one possible implementation, the virtual building construction system provided in the second aspect of this application further includes: a fragment generation module, which is configured during the generation of building fragments as follows:
[0138] Obtain a virtual model of the complete building; map the virtual model of the complete building onto a preset 3D mesh space, which consists of multiple meshes;
[0139] In response to the vertex state modification operation command sent by the operation interface, the vertex state of each vertex in each grid is modified, and the virtual model of the complete building is segmented and extracted based on the modified vertex state to obtain multiple building fragments of the complete building. When the vertex state is active, it indicates that the vertex is located inside the complete building, and when the vertex state is inactive, it indicates that the vertex is located outside the complete building. The active vertices are used to mark the segmentation position of the building fragments.
[0140] In one possible implementation, the virtual building construction system provided in the second aspect of this application further includes:
[0141] The simulation fitting module is used to obtain the building adjustment curve trajectory and the second unit selection command sent by the interactive interface; the coordinates of each vertex of at least one initial model unit corresponding to the unit identifier in the second unit selection command are substituted into the curve equation corresponding to the building adjustment curve trajectory to calculate the transformation matrix corresponding to each vertex coordinate. The transformation matrix includes the coordinates, normal vector, and tangent vector of the building adjustment curve trajectory at the vertex coordinate position. The transformation matrix represents the correction amount of the vertex coordinate fitting to the building adjustment curve trajectory; the marker points of the initial model unit are corrected based on the transformation matrix to obtain the deformed model unit that fits the adjustment curve trajectory, and the deformed model unit is rendered to the virtual scene. The marker points are the boundary points and / or center points of the initial model unit.
[0142] In one possible implementation, the above-mentioned simulation fitting module is further configured as follows:
[0143] Before rendering the deformable model unit to the virtual scene, the deformable model unit is mapped to a preset segmentation space, which consists of multiple segmentation meshes;
[0144] The multiple segmented meshes containing the deformable model elements in the preset segmented space are determined as the meshes to be processed, and each mesh to be processed is randomly processed to update the deformable model elements. The random processing includes:
[0145] The first random algorithm is called to randomly offset the coordinates of the first number of fixed points in each grid to be processed. The offset amount is a preset value in a random direction.
[0146] And / or invoke a second random algorithm to randomly delete a second number of grids in each grid to be processed;
[0147] And / or invoke a random segmentation algorithm to randomly segment the third number of grids in each grid to be processed.
[0148] In one possible implementation, the simulation fitting module is configured to:
[0149] When the curve trajectory of the building is adjusted to the cutout type, the preset calculation shader in the graphics processor is called to traverse each pixel of the deformed model and parse the curve parameter value corresponding to each pixel.
[0150] Delete pixels whose curve parameter values are within the range of curve parameters for adjusting the curve trajectory, and render pixels whose curve parameter values are not within the range of curve parameters to the virtual scene.
[0151] In one possible implementation, the model slices are binary strings.
[0152] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement a method for constructing a virtual building according to the first aspect or any implementation thereof.
[0153] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0154] Memory is used to store computer programs;
[0155] The processor is used to execute computer programs to enable electronic devices to implement the method for constructing virtual buildings according to the first aspect or any implementation thereof.
[0156] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to construct a virtual building according to the first aspect or any implementation thereof.
[0157] It should also be noted that 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. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0158] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, 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 is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0159] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0160] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A method of constructing a virtual building, characterized by, The method comprises the following steps: In response to a first unit selection instruction sent by an interactive interface, mapping at least one initial model unit corresponding to a unit identifier in the first unit selection instruction to a virtual scene, the virtual scene being composed of a plurality of cubic grids, the initial model unit being a complete building or a building fragment, the building fragment being obtained after the complete building is segmented; Based on the click coordinates in the editing information sent by the interactive interface and each of the cubic grids, performing intersection testing, and determining a target cubic grid in which a modification area of the initial model unit is located based on the result of the intersection testing; Performing at least an editing operation corresponding to an editing operation identifier in the editing information on the target cubic grid, obtaining a model unit, the target cubic grid being any one of the cubic grids; Based on a preset segmentation size, segmenting the virtual scene including the model unit into a plurality of data blocks, and rendering model slices of the model unit in each non-empty data block, obtaining a virtual building, the type of the data block including an empty data block and the non-empty data block, the model slice not being included in the empty data block, the model slice being included in the non-empty data block, the data block including at least one of the cubic grids; Obtaining a building adjustment curve track and a second unit selection instruction sent by the interactive interface; Bringing each vertex coordinate of at least one initial model unit corresponding to a unit identifier in the second unit selection instruction into a curve equation corresponding to the building adjustment curve track to calculate a transformation matrix corresponding to each vertex coordinate, the transformation matrix including coordinates, a normal vector and a tangent vector of the adjustment curve track at the position of the vertex coordinate, the transformation matrix representing a correction amount of the vertex coordinate fitting the building adjustment curve track; Based on the transformation matrix, correcting a marker point of the initial model unit to obtain a deformed model unit fitting the building adjustment curve track, and rendering the deformed model unit to the virtual scene, the marker point being a boundary point and / or a center point of the initial model unit.
2. The method of constructing a virtual building according to claim 1, wherein, The generation process of the building fragment comprises the following steps: Obtaining a virtual model of the complete building; mapping the virtual model of the complete building to a preset three-dimensional grid space, the preset three-dimensional grid space being composed of a plurality of grids; In response to a vertex state modification operation instruction sent by an operation interface, modifying the vertex state of each vertex of each grid, and based on the modified vertex state of each vertex, segmenting and extracting the virtual model of the complete building to obtain a plurality of building fragments of the complete building, the vertex state being an active state when representing that the vertex is located inside the complete building, the vertex state being an inactive state when representing that the vertex is located outside the complete building, the vertex in the active state being used to mark the segmentation position of the building fragment.
3. The method of claim 1, wherein, Before rendering the deformed model unit to the virtual scene, the method further comprises the following steps: Mapping the deformed model unit to a preset segmentation space, the preset segmentation space being composed of a plurality of segmentation grids; The plurality of each of the segmentation grids where the deformation model unit in the preset segmentation space is located is determined as a to-be-processed grid, and each of the to-be-processed grids is randomly processed to update the deformation model unit, and the random processing includes: a first random algorithm is called to randomly perform coordinate offset on each fixed point coordinate of a first number of each of the to-be-processed grids, and the offset amount of the coordinate offset is a preset value in a random direction; and / or a second random algorithm is called to randomly perform grid deletion on a second number of each of the to-be-processed grids; and / or a random segmentation algorithm is called to randomly perform grid segmentation on a third number of each of the to-be-processed grids.
4. The method of constructing a virtual building according to any one of claims 1 or 3, wherein, When the type of the building adjustment curve track is a cutout type, the rendering of the deformation model unit to the virtual scene includes: a pre-designed calculation shader in a graphics processing unit is called to traverse each pixel point of the deformation model, and each curve parameter value corresponding to each of the pixel points is parsed; the pixel point with the curve parameter value in the curve parameter range of the adjustment curve track is deleted, and the pixel point with the curve parameter value not in the curve parameter range is rendered to the virtual scene.
5. The method of claim 1, wherein, The model slice is a binary string.
6. A construction system of virtual buildings, characterized by It includes: a unit mapping module, configured to map at least one initial model unit corresponding to a unit identifier in a first unit selection instruction sent by an interactive interface to a virtual scene in response to the first unit selection instruction, the virtual scene being composed of a plurality of cubic grids, the initial model unit being a complete building or a building fragment, the building fragment being obtained by segmenting the complete building; a unit editing module, configured to perform intersection testing based on a click coordinate in editing information sent by the interactive interface and each of the cubic grids, and determine a target cubic grid where a modification area of the initial model unit is located based on a result of the intersection testing; perform at least an editing operation corresponding to an editing operation identifier in the editing information on the target cubic grid to obtain a model unit, the target cubic grid being any one of the cubic grids; a model rendering module, configured to segment the virtual scene including the model unit into a plurality of data blocks based on a preset segmentation size, and render a model slice of the model unit in each non-empty data block to obtain a virtual building, the type of the data block including an empty data block and the non-empty data block, the empty data block not including the model slice, the non-empty data block including the model slice, and the data block including at least one of the cubic grids; a simulation fitting module, configured to obtain a building adjustment curve track and a second unit selection instruction sent by the interactive interface; Each vertex coordinate of at least one initial model unit corresponding to the unit identification in the second unit selection instruction is brought into a curve equation corresponding to the building adjustment curve track to calculate a transformation matrix corresponding to each of the vertex coordinates, the transformation matrix including coordinates, a normal vector and a tangent vector of the building adjustment curve track at the vertex coordinate position, and the transformation matrix representing a correction amount of the vertex coordinate fitting to the building adjustment curve track; Based on the transformation matrix, a mark point of the initial model unit is corrected to obtain a deformed model unit fitting to the adjustment curve track, and the deformed model unit is rendered to the virtual scene, the mark point being a boundary point and / or a center point of the initial model unit.
7. A computer program product, characterised in that, The computer readable instructions, when executed on an electronic device, cause the electronic device to implement the construction method of the virtual building according to any one of claims 1 to 5.
8. An electronic device, comprising: The memory is configured to store a computer program, and the processor is configured to execute the computer program to enable the electronic device to implement the construction method of the virtual building according to any one of claims 1 to 5. The memory is configured to store a computer program, and the processor is configured to execute the computer program to enable the electronic device to implement the construction method of the virtual building according to any one of claims 1 to 5. The storage medium carries one or more computer programs, and when the one or more computer programs are executed by an electronic device, the electronic device can implement the construction method of the virtual building according to any one of claims 1 to 5.
9. A computer storage medium, characterized in that
Citation Information
Patent Citations
Grid pickup method, device and equipment based on multiple screens and medium
CN117032617A
Map data processing method and device based on model reconstruction, equipment and medium
CN120707771A