Method and device for exporting geometry and material of BIM (Building Information Modeling) model
By dividing and merging meshes in the BIM model and adopting a dynamic texture mapping strategy, the problems of material information loss and missing UV coordinates are solved, data redundancy is reduced, the rendering performance and visual effects of the model are improved, and broader platform compatibility is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG HUAZHIYUAN TECH CO LTD
- Filing Date
- 2025-11-18
- Publication Date
- 2026-04-10
AI Technical Summary
When exporting BIM models from Revit to a Web 3D rendering platform, issues such as lost material information, missing UV coordinates, mismatched coordinate systems, and data redundancy result in a lack of realism and poor visual effects in the model display.
By extracting the geometry, material identifiers, and material information of the BIM model, the mesh is divided and merged based on the material identifiers. A dynamic texture mapping strategy is used to generate texture coordinates, and vertex deduplication is performed to generate dual-format material files and model data files.
Ensures accurate texture mapping, reduces data redundancy, improves rendering performance and visual effects, and provides broader compatibility.
Smart Images

Figure CN121837535A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of BIM model data export, in particular to a BIM model geometry and material export method and device. BACKGROUND
[0002] Currently, when exporting BIM models from Revit to Web 3D and other rendering platforms, the following problems exist: 1. Material information loss: The material structure of Revit differs from that of other platforms, resulting in incorrect transmission of material information and lack of realism when displaying models on the Web.
[0003] 2. Missing texture (UV) coordinates: The exported model lacks correct UV coordinate information, resulting in incorrect mapping of texture maps to the surface of the geometry and affecting visual effects.
[0004] 3. Coordinate system mismatch: Revit uses a right-handed coordinate system with the Y-axis pointing upwards, while Web 3D rendering usually uses a different coordinate system, resulting in incorrect model orientation when directly exported.
[0005] 4. Data redundancy: The exported geometry has a large number of duplicate vertices, increasing file size and rendering burden.
[0006] 5. Texture file loss: The texture file path referenced in the material is lost during export, requiring manual handling of texture files. SUMMARY
[0007] The present application mainly provides a BIM model geometry and material export method and device to solve the problems of material information loss, UV coordinate loss, and data redundancy when exporting models in the prior art.
[0008] To solve the above technical problems, one technical solution adopted by the present application is to provide a BIM model geometry and material export method. The method includes: extracting the geometry, material identifier, and material information of the BIM model; dividing the faces of each geometry based on the material identifier to obtain multiple merged meshes; generating corresponding texture coordinates for the vertices of the faces of each geometry based on a dynamic texture mapping strategy; performing vertex deduplication on each merged mesh to obtain a vertex list; generating a dual-format material file and a model data file based on the material information, the vertex list, and the corresponding texture coordinates.
[0009] In an optional implementation of an embodiment of the present application, the material information includes a texture scaling factor. The generating of the corresponding texture coordinates for the vertices of the face of each of the geometric bodies based on the dynamic texture mapping strategy comprises: For each face of the geometric bodies, determining a face type based on a normal direction of the face; Selecting a corresponding dynamic texture mapping strategy based on the face type, and determining a texture coordinate origin and a scaling reference based on a boundary of the face and the texture scaling coefficient; Calculating the texture coordinates corresponding to the vertices based on the dynamic texture mapping strategy, the texture coordinate origin and the scaling reference.
[0010] In an optional implementation of the embodiments of the present application, the face type comprises a horizontal face, an X-axis direction vertical face, a Y-axis direction vertical face and an inclined face; The calculating of the texture coordinates corresponding to the vertices based on the dynamic texture mapping strategy, the texture coordinate origin and the scaling reference comprises: In response to the face type being the horizontal face, calculating a U value based on an X-axis coordinate component of the vertex, and calculating a V value based on a Y-axis coordinate component of the vertex; In response to the face type being the X-axis direction vertical face, calculating a U value based on a Y-axis coordinate component of the vertex, and calculating a V value based on a Z-axis coordinate component of the vertex; In response to the face type being the Y-axis direction vertical face, calculating a U value based on an X-axis coordinate component of the vertex, and calculating a V value based on a Z-axis coordinate component of the vertex; In response to the face type being the inclined face, calculating the texture coordinates based on projection coordinates of the vertex in a local coordinate system projection of the face.
[0011] In an optional implementation of the embodiments of the present application, the calculation function of the texture coordinates is: Formula 1; Wherein, t is the U value or the V value of the texture coordinates; vertex is the coordinate component; min is the texture coordinate origin; uvScale is the texture scaling coefficient; unitScale is the unit conversion coefficient; k is an adjustment coefficient; is the scaling reference.
[0012] In an optional implementation of the embodiments of the present application, the vertex de-duplication for each of the merged meshes to obtain a vertex list comprises: For each of the merged meshes, creating and initializing a vertex list; traverse the vertex list, calculate the three-axis coordinate difference value of the current vertex and each vertex in the vertex list, and determine whether each three-axis coordinate difference value is less than a first preset tolerance value; In response to the three-axis coordinate difference values being less than the first preset tolerance value, the current vertex is de-duplicated; In response to the three-axis coordinate difference values not being less than the first preset tolerance value, the current vertex is added to the vertex list; Until the traversal of all vertices of the merged mesh is completed, the de-duplicated vertex list is obtained.
[0013] In an optional embodiment of the embodiment of the application, in response to the three-axis coordinate difference values being less than the first preset tolerance value, the method further comprises: determining whether a texture coordinate difference value of the current vertex and the vertex in the vertex list is less than a second preset tolerance value; In response to the texture coordinate difference value being less than the second preset tolerance value, the current vertex is de-duplicated; In response to the texture coordinate difference value not being less than the second preset tolerance value, the current vertex is added to the vertex list.
[0014] In an optional embodiment of the embodiment of the application, the dividing each geometric body surface based on the material identifier to obtain a plurality of merged meshes comprises: triangulating each geometric body surface to obtain a plurality of meshes; merging all meshes of the same material identifier to obtain the merged mesh.
[0015] In an optional embodiment of the embodiment of the application, after the vertex list is obtained, the method further comprises: based on the configurable coordinate conversion parameters and the target coordinate system of the target platform, converting the coordinates of all vertices to the target coordinate system to obtain the coordinate-converted vertex list, and automatically adjusting the center point of the BIM model.
[0016] In an optional embodiment of the embodiment of the application, the material information further comprises a texture map path; The generating a double-format material file and a model data file based on the material information, the vertex list and the corresponding texture coordinates comprises: copying each texture file based on the texture map path and renaming to obtain a renamed texture file; converting the material information into MTL format and JSON format at the same time to generate an MTL material file and a JSON file, respectively; generating the model data file based on the vertex list and the corresponding texture coordinates.
[0017] To solve the above technical problems, another technical solution adopted by the present application is to provide a BIM model geometry and material export device, characterized in that it comprises: A model extraction module is configured to extract the geometry, material identifier and material information of a BIM model. A material merging module is configured to divide the faces of each geometry based on the material identifier to obtain a plurality of merged meshes. A texture mapping module is configured to generate corresponding texture coordinates for the vertices of each face of the geometry based on a dynamic texture mapping strategy. A vertex deduplication module is configured to perform vertex deduplication on each merged mesh to obtain a vertex list. A file generation module is configured to generate a dual-format material file and a model data file based on the material information, the vertex list and the corresponding texture coordinates.
[0018] The present application has the following advantages: Unlike the prior art, the present application discloses a BIM model geometry and material export method and device. The method divides the faces of each geometry based on the material identifier to obtain a plurality of merged meshes, and performs vertex deduplication on each merged mesh to reduce data redundancy and improve rendering performance. The dynamic texture mapping strategy is used to generate corresponding texture coordinates for the vertices of each face to ensure correct texture mapping and improve visual effects. The dual-format material file is generated to completely retain all material properties, including color, physical properties, texture path, etc., and the dual format can support various 3D software and renderers to provide wider compatibility. BRIEF DESCRIPTION OF DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor. Figure 1 is a flowchart of an embodiment of the BIM model geometry and material export method provided by the present application; Figure 2 is a flowchart of automatic model export of an embodiment of the BIM model geometry and material export method provided by the present application; Figure 3 is a structural diagram of an embodiment of the BIM model geometry and material export device provided by the present application; Figure 4 is a structural diagram of an embodiment of the storage medium provided by the present application; Figure 5 is a structural schematic diagram of an embodiment of the computer device provided in the present application. DETAILED DESCRIPTION
[0020] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative effort belong to the scope of protection of the present application.
[0021] The terms “first”, “second”, “third” in the embodiments of the present application are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with “first”, “second”, “third” can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of “a plurality of” is at least two, for example, two, three, etc., unless otherwise explicitly and specifically limited. In addition, the terms “include” and “have” and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, product or device.
[0022] In this document, the reference to “an embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The appearance of the phrase in various places in the specification does not necessarily all refer to the same embodiment, nor does it necessarily refer to a separate or alternative embodiment. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] The present application provides a BIM model geometry and material export method, referring to Figure 1 , Figure 1 is a flowchart of an embodiment of the BIM model geometry and material export method provided in the present application. The BIM model geometry and material export method comprises: S10: Extracting the geometry, material identifier and material information of the BIM model.
[0024] BIM model (Building Information Modeling, building information model) is a digital model containing building geometry information and attribute information.
[0025] Autodesk Revit is a building information modeling software developed by Autodesk, Inc. The core concept of Revit is to design and document around an intelligent, three-dimensional digital model. The essence of a Revit model is a BIM model.
[0026] In this application, BIM models are extracted from Revit software. All elements (RevitElement) in the BIM model can be traversed through the Application Programming Interface (API) of Revit, and the solid geometry of each element can be extracted. Elements are basic objects in Revit, such as walls, floors, doors, windows, and other components. Each element contains one or more solid geometries (referred to as geometries), which represent the three-dimensional solid shape of the component. Each solid geometry is composed of multiple faces (Face, referred to as face), and each face is a region of the surface of the solid geometry. The hierarchical relationship from large to small is element → geometry → face.
[0027] Material ID is a built-in BIM model. Each face in Revit has a material ID, which can be directly extracted as a reference for the material of the face. The material ID points to the material (Material) defined in the Revit document. If the face does not specify a material, it returns an invalid material ID.
[0028] Material information is complete attribute information that can be directly extracted from Revit material, including basic color information (RGB value), physical properties (metallic, roughness, and transparency), texture map path (diffuse, normal, and metallic), self-luminous properties, and texture scaling factors (texture U direction scaling factor uvScaleX and texture V direction scaling factor uvScaleY).
[0029] Material information extraction uses the standard calling method of Revit API. The process includes obtaining basic attributes (such as color and transparency), obtaining rendering assets, and recursively searching for various attributes (such as diffuse and metallic) from rendering assets. The texture map path (relative path or file name) is extracted by traversing the connection properties of the rendering assets.
[0030] In the material information extraction process, the object of material information extraction is not the complete BIM model, but the material actually used by the geometry. When extracting, all geometry referenced material IDs are collected, and only these actually used materials are extracted. Unused materials are filtered out to avoid data redundancy.
[0031] S20: Divide the faces of each geometry based on the material ID to obtain multiple merged meshes.
[0032] In this application, the faces of each geometry are divided based on material identifiers to obtain multiple merged meshes, including: Triangulate the faces of each geometry to obtain multiple meshes; All meshes with the same material identifier are merged to obtain a merged mesh.
[0033] In this application, after extracting all geometry, the faces are grouped according to their material identifiers. Specifically, an element (such as a wall) contains one or more geometry, and each geometry contains multiple faces. These faces are traversed, and faces with the same material identifier are grouped together. For example, a wall may have two materials (wall material and baseboard material), then all faces of this wall will be divided into two groups (wall material group and baseboard material group), and all faces within each group share the same material identifier.
[0034] Iterates through each face, calling Revit's built-in triangulation function to automatically convert faces of any shape (such as curved or polygonal faces) into a triangular mesh. Since a face may contain multiple sides, such as a rectangle with 4 sides, multiple triangles are needed to approximate the shape of a polygon or curved face into a triangle. Therefore, after triangulation, a face will generate a mesh containing multiple triangular meshes.
[0035] The transformed mesh contains all the geometric data of the face. That is, the three-axis coordinates (X, Y, Z) of all vertices in the mesh can be extracted from this mesh. It can also extract each triangle in the mesh, as well as the indices of the three vertices contained in each triangle.
[0036] The meshes corresponding to all faces within a material group defined by the same material identifier are merged into a unified mesh (i.e., merged mesh). During the merging process, vertex deduplication, index updates, and texture coordinate generation are performed.
[0037] By dividing and merging meshes using the same material, the amount of data to be processed in subsequent steps can be effectively reduced, thus improving the efficiency of data processing.
[0038] S30: Based on a dynamic texture mapping strategy, generate corresponding texture coordinates for the vertices of each face of the geometry.
[0039] In this application, the material information includes a texture scaling factor; based on a dynamic texture mapping strategy, corresponding texture coordinates are generated for the vertices of each geometry's face, including: S31: For each face of a geometry, determine the face type based on the direction of the face's normal.
[0040] A normal of a plane is a unit vector that is perpendicular to a particular plane or surface. A polygonal face shares a uniform normal. The normal can be calculated from the first triangle of the face, using the cross product of two edges of the triangle to get a perpendicular vector. The direction of a face is determined by the direction of its normal, for example, a normal of (0, 0, 1) indicates an upward horizontal plane.
[0041] Specifically, the face type can be determined according to the principal component of the normal vector, that is, based on the absolute values of the X, Y, and Z components of the normal, the face type includes a horizontal plane, an X-axis vertical plane, a Y-axis vertical plane, and an inclined plane.
[0042] If the absolute value of the Z component is greater than a preset threshold, the face type is determined to be a horizontal plane; if the absolute value of the Y component is greater than a preset threshold, the face type is determined to be a Y-axis vertical plane; if the absolute value of the X component is greater than a preset threshold, the face type is determined to be an X-axis vertical plane; otherwise, it is determined to be an inclined plane. The value of the preset threshold can be 0.7 corresponding to an angle of about 45 degrees, or can be adaptively adjusted to 0.71 or 0.69, etc., without specific limitation.
[0043] S32: Select a corresponding dynamic texture mapping strategy based on the face type, and determine the texture coordinate origin and scaling reference based on the boundary of the face and the texture scaling factor.
[0044] In this application, the dynamic texture mapping strategy can also be divided into four texture mapping strategies for the four types of faces. The main difference between the strategies is the projection plane. The X-Y plane is used for projection of the horizontal plane, the Y-Z plane is used for projection of the X-axis vertical plane, the X-Z plane is used for projection of the Y-axis vertical plane, and the local coordinate system based on the face normal is used for projection of the inclined plane. In each strategy, different coordinate components are selected as the U and V values of the texture coordinates.
[0045] The boundary of the face refers to the boundary range of the geometric shape of the face, which can be obtained by calculating the maximum and minimum coordinates of each vertex of the face. In the texture mapping process, the texture coordinate origin and scaling reference are calculated according to the boundary range of the face. Specifically, the minimum coordinate component of all vertices of the face is taken as the texture coordinate origin, and the scaling reference is the mapping ratio of the coordinate difference (vertex coordinate component - minimum coordinate component) to the UV value, which is composed of three parts, including the realWorldScaleX / Y of the material (texture scaling factor extracted from the Revit material), the document unit conversion factor (such as converting meters to feet), and a fixed adjustment coefficient for adapting to the display effect of Unity. The scaling reference = texture scaling factor × unit conversion factor × adjustment coefficient, wherein the value of the adjustment coefficient is determined according to the target rendering library, for example, when rendering to Unity, the adjustment coefficient is set to 100.0, and when rendering to WebGL, the adjustment coefficient is set in the range of 1.0~10.0.
[0046] S33: calculating the texture coordinates corresponding to each vertex based on the dynamic texture mapping strategy, the texture coordinate origin and the scaling reference.
[0047] In the present application, the texture coordinates corresponding to each vertex are calculated based on the dynamic texture mapping strategy, the texture coordinate origin and the scaling reference, comprising: in response to the face type being a horizontal face, calculating the U value based on the X-axis coordinate component of the vertex and calculating the V value based on the Y-axis coordinate component of the vertex; in response to the face type being an X-axis direction vertical face, calculating the U value based on the Y-axis coordinate component of the vertex and calculating the V value based on the Z-axis coordinate component of the vertex; in response to the face type being a Y-axis direction vertical face, calculating the U value based on the X-axis coordinate component of the vertex and calculating the V value based on the Z-axis coordinate component of the vertex; in response to the face type being an inclined face, calculating the texture coordinates based on the projection coordinates of the vertex in the local coordinate system projection of the face.
[0048] In the present application, when the face type is a horizontal face, the texture mapping strategy corresponding to the horizontal face is dynamically selected, that is, the X-Y plane projection is used, in which the X-axis coordinate component is selected as the U value of the texture coordinates and the Y-axis coordinate component is selected as the V value of the texture coordinates. Specifically, for each vertex in the face, the U value is calculated based on the X-axis coordinate component of the vertex and the V value is calculated based on the Y-axis coordinate component of the vertex through the extracted vertex three-axis coordinates (X, Y, Z) and the texture coordinate calculation function.
[0049] In the present application, the texture coordinate calculation function is: Formula 1; wherein t is the U value or the V value of the texture coordinates; vertex is the coordinate component; min is the texture coordinate origin; uvScale is the texture scaling coefficient; unitScale is the unit conversion coefficient; k is the adjustment coefficient; is the scaling reference.
[0050] When the face type is a horizontal face, in the texture mapping strategy corresponding to the horizontal face, the calculation formulas of the U value and the V value can be obtained from Formula 1 as follows:
[0051] wherein vertex.X is the X-axis coordinate component; minX is the minimum coordinate component of all vertices of the face on the X-axis, which is the texture coordinate origin; uvScaleX is the texture scaling coefficient (scaling coefficient in the U direction of the texture) extracted from the material information; is the scaling reference.
[0052]
[0053] where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information;
[0054] In the present application, when the face type is an X axis direction vertical face, the corresponding texture mapping strategy of the X axis direction vertical face is dynamically selected, that is, the Y-Z plane projection is used, in which the Y axis coordinate component is selected as the U value of the texture coordinate, and the Z axis coordinate component is selected as the V value of the texture coordinate.
[0055] In the corresponding texture mapping strategy of the X axis direction vertical face, the calculation formulas of the U value and the V value are as follows according to formula 1:
[0056] where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information;
[0057]
[0058] where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information; where vertex.Y is the Y axis coordinate component; minY is the minimum coordinate component of all vertices of the face on the Y axis, as the origin of the texture coordinate; uvScaleX is the texture scaling factor extracted in the material information;
[0059] In the present application, when the face type is a Y axis direction vertical face, the corresponding texture mapping strategy of the Y axis direction vertical face is dynamically selected, that is, the X-Z plane projection is used, in which the X axis coordinate component is selected as the U value of the texture coordinate, and the Z axis coordinate component is selected as the V value of the texture coordinate.
[0060] In the corresponding texture mapping strategy of the Y axis direction vertical face, the calculation formulas of the U value and the V value are as follows according to formula 1:
[0061] Where vertex.X is the X-axis coordinate component; minX is the minimum coordinate component of all vertices of the face on the X-axis, which serves as the origin of the texture coordinates; uvScaleX is the texture scaling factor extracted from the material information. Used as the scaling reference.
[0062]
[0063] in, for Axis coordinate components; For all vertices of this face The smallest coordinate component on the axis is used as the origin of the texture coordinates; The texture scaling factor extracted from the material information; Used as the scaling reference.
[0064] In this application, when the surface type is a sloping surface, the texture mapping strategy corresponding to the sloping surface is dynamically selected, that is, the local coordinate system projection based on the surface normal is used. The U value and V value are calculated by the projection of the vertex in the local coordinate system of the surface. The formula involves the vector dot product and the basis vector of the local coordinate system.
[0065] It is understandable that all the formulas for calculating the U and V values of texture coordinates in the above strategies have the same structure: (vertex coordinate component - minimum coordinate component) × scaling reference. The difference lies in which coordinate component is selected as the U and V values respectively.
[0066] Unlike existing technologies that lack correct texture coordinate information when exporting models, resulting in textures not being properly mapped to the geometric surface and affecting visual effects, the BIM model geometry and material export method provided in this application uses a dynamic texture mapping strategy to accurately calculate the U and V values of texture coordinates for various surface types. This ensures that textures can be accurately mapped to the geometric surface, greatly improving the visual effect and realism of the model.
[0067] S40: For each merged mesh, remove duplicate vertices to obtain a vertex list.
[0068] In this application, after triangulating each face to obtain the mesh corresponding to each face, meshes with the same material identifier are merged. At this time, the coordinates (three-axis coordinates and texture coordinates) of all face vertices are collected in a temporary vertex list, waiting for deduplication.
[0069] In this application, for each merged mesh, vertex deduplication is performed to obtain a vertex list, including: S41: For each merged mesh, create and initialize the vertex list.
[0070] In the process of merging, vertex de-duplication is performed on the merged mesh. At this time, each vertex in the temporary vertex list containing the vertices of all faces is traversed to prepare for de-duplication, and a new vertex list is created and initialized to store the de-duplicated vertices as the unique vertex list after de-duplication.
[0071] S42: Traverse the vertex list to calculate the three-axis coordinate difference value of the current vertex and each vertex in the vertex list, and determine whether each three-axis coordinate difference value is less than the first preset tolerance value.
[0072] For each vertex obtained by traversing the temporary vertex list, de-duplication is performed by a numerical comparison algorithm. The vertex obtained from the temporary vertex list and ready to be compared for de-duplication is referred to as the current vertex. For the current vertex, each vertex in the newly created vertex list is traversed, and the current vertex is compared with each vertex already stored in the vertex list to calculate the three-axis coordinate difference value between them.
[0073] Taking the vertex A already stored in the vertex list as an example, the values of |current vertex vertex A| are calculated respectively. Since the three-axis coordinates (X, Y, Z) need to be compared respectively, |current vertex vertex A| is actually the X-axis coordinate of the current vertex vertex A|, the Y-axis coordinate of the current vertex vertex A|, and the Z-axis coordinate of the current vertex vertex A|. When comparing the current vertex and vertex A by the numerical comparison algorithm, it is determined whether the difference between the X, Y, Z three-axis coordinates of the current vertex and the X, Y, Z three-axis coordinates of vertex A (i.e., the three-axis coordinate difference value, a total of 3 values) is less than the first preset tolerance value.
[0074] By comparing the size relationship between the three-axis coordinate difference value and the first preset tolerance value, it is determined whether the current vertex is a duplicate vertex. Compared with strict numerical comparison, the problem of vertex duplication or omission caused by minor errors is avoided, effectively improving the accuracy and reliability of BIM model geometry vertex processing.
[0075] S43: In response to the three-axis coordinate difference value being less than the first preset tolerance value, de-duplicate the current vertex.
[0076] When the difference between the X, Y, Z three-axis coordinates of the current vertex and the X, Y, Z three-axis coordinates of vertex A is less than the first preset tolerance value, the current vertex and vertex A are considered to be duplicate vertices, and the index of vertex A in the vertex list is returned to complete the de-duplication of the current vertex.
[0077] In this application, in response to the three-axis coordinate difference value being less than the first preset tolerance value, it also includes: determining whether the texture coordinate difference between the current vertex and the vertex in the vertex list is less than a second preset tolerance value; in response to the texture coordinate difference being less than the second preset tolerance value, deduplicating the current vertex; in response to the texture coordinate difference not being less than the second preset tolerance value, adding the current vertex to the vertex list.
[0078] In an embodiment, when performing the deduplication comparison, in addition to comparing the three-axis coordinates, the texture coordinates can also be compared. Taking an example of a vertex (vertex A) already stored in the vertex list, the texture coordinate difference (including U difference and V difference) between the current vertex and vertex A is calculated. When the three-axis coordinate difference between the current vertex and vertex A is less than the first preset tolerance value, it is further determined whether the texture coordinate difference (two values) between the current vertex and vertex A is also less than the second preset tolerance value.
[0079] If the U difference and the V difference are both less than the second preset tolerance value, it indicates that the positions of the two vertices on the texture mapping are also close enough. At this time, the current vertex and vertex A can be considered as duplicate vertices, and the current vertex is deduplicated, i.e., not added to the new vertex list. Conversely, if the texture coordinate difference is not less than the second preset tolerance value, it indicates that the two vertices are close in geometric position but have significant differences in texture mapping. At this time, the current vertex should be added to the vertex list as a new vertex to preserve its unique texture information.
[0080] The first preset tolerance value and the second preset tolerance value can be adjusted according to actual requirements. The first preset tolerance value can be set to 10 -n , and n is the precision. For example, when the precision is 3, the first preset tolerance value is 0.001, and the second preset tolerance value can be set to twice the first preset tolerance value. The first preset tolerance value is mainly used to control the duplicate judgment precision in geometric position, and the second preset tolerance value is used to control the duplicate judgment precision in texture coordinates. By reasonably setting the two tolerance values, the model geometric precision can be ensured, the number of vertices can be effectively reduced, and the processing efficiency of the model can be improved.
[0081] S44: in response to the three-axis coordinate difference not being less than the first preset tolerance value, adding the current vertex to the vertex list.
[0082] When the X, Y, Z three-axis coordinate difference between the current vertex and vertex A is not less than the first preset tolerance value, for example, the X-axis coordinate difference between the current vertex and vertex A is not less than the first preset tolerance value, while the Y, Z-axis coordinate difference is less than the first preset tolerance value, it is considered that the current vertex and vertex A are not duplicate vertices. At this time, the current vertex is added to the vertex list, and the new index of the current vertex in the vertex list is returned.
[0083] S45: Until all vertices of the merged mesh are traversed, the de-duplicated vertex list is obtained.
[0084] In the merging mesh process, each vertex in the temporary vertex list is compared and de-duplicated, and the new vertex after de-duplication is added to the vertex list. This growing vertex list is the only vertex list obtained after de-duplication. The vertex list contains all unique vertices after de-duplication, and the position of each vertex in the vertex list is its index (0, 1, 2,...); the texture coordinate list corresponding to the vertex list contains the texture coordinates corresponding to each vertex, which corresponds to the vertex list.
[0085] In the de-duplication process, triangle index updating is also performed. Triangle index is generated by RevitAPI during face triangulation, and each triangle mesh contains three vertex indexes. During de-duplication, an index mapping table is created to record the mapping relationship between the original vertex index and the de-duplicated vertex index. Traverse each triangle, convert the original vertex index of each triangle to the new index after de-duplication through the mapping table, and then create a new triangle object to store these new indexes. Specifically, the de-duplicated triangle list contains the new index of each triangle after de-duplication, which is an index pointing to the vertex list, forming a mapping relationship between the three vertices of the triangle and the three vertices corresponding to the vertex list, for example, the new index of a certain triangle in the de-duplicated triangle list is (v1, v2, v3), where v1, v2 and v3 are indexes in the vertex list.
[0086] It should be noted that de-duplication is performed on the vertices of all faces with the same material identifier, and the de-duplication process is performed during the merging process of the mesh corresponding to the face. Vertices between different materials will not be compared and de-duplicated.
[0087] Repeat steps S42 and S43 until all vertices of the merged mesh are traversed, and obtain the de-duplicated vertex list (unique vertex), one-to-one corresponding texture coordinate list, and triangle list (index pointing to unique vertex).
[0088] After obtaining the de-duplicated vertex list, the de-duplication effect can also be counted. Specifically, by comparing the total number of original vertices and the number of unique vertices after de-duplication, the number of reduced vertices and the reduction percentage are calculated to determine the de-duplication effect. If the number of reduced vertices is large and the reduction percentage is significant, it indicates that the de-duplication effect is good, effectively reducing the vertex redundancy of the model and improving the processing efficiency of the model. Moreover, by reducing duplicate vertices, the size of the final OBJ file and the memory occupation are directly reduced.
[0089] The geometry derived in the prior art has a large number of repeated vertices, causing data redundancy, increasing file size and rendering burden. The BIM model geometry and material export method provided in the present application, The number of repeated vertices in the model is effectively reduced by vertex deduplication, avoiding data redundancy, significantly reducing the size of the finally exported OBJ file, and also reducing the computational burden in the subsequent rendering process, improving the overall processing efficiency. At the same time, since the deduplication process is carried out within all faces of the same material identifier, the completeness and accuracy of the model material information are ensured, and the visual effect of the model will not be affected by vertex deduplication.
[0090] In the present application, after obtaining the vertex list, it further includes: Based on the configurable coordinate conversion parameters and the target coordinate system of the target platform, the coordinates of all vertices are converted to the target coordinate system to obtain the coordinate-converted vertex list, and the center point of the BIM model is automatically adjusted.
[0091] In the present application, the platform for exporting the BIM model is referred to as the source platform, and the platform for rendering the exported BIM model is referred to as the target platform. The present application takes Revit as an example to illustrate the export of the BIM model, and it can be understood that the BIM model geometry and material export method provided in the present application can also support the export of the BIM model from other software platforms (source platforms).
[0092] The target platform, such as the Unity and WebGL rendering platforms, may have different target coordinate systems, such as the left-handed coordinate system used by Unity (X axis to the right, Y axis upward, Z axis forward) and the right-handed coordinate system used by WebGL (X axis to the right, Y axis upward, Z axis outward). The coordinate system of the source platform may also differ from that of the target platform, such as the right-handed coordinate system used by Revit (X axis to the right, Y axis forward, Z axis upward). The main difference between the three coordinate systems is that Revit uses the Z axis as the upward direction, while Unity and WebGL use the Y axis as the upward direction; the Y axis of Revit corresponds to the Z axis of Unity in the forward direction, but a left-hand system conversion is required; the Z axis of WebGL is opposite to the Z axis of Unity in the forward direction. Therefore, when exporting the BIM model from Revit to Unity, a right-handed coordinate system to left-handed coordinate system conversion is required, and when exporting the BIM model from Revit to WebGL, a right-handed coordinate system conversion is required.
[0093] Specifically, the conversion can be achieved by coordinate axis remapping. When Unity is the target platform, the Z axis of the Revit coordinate system is mapped to the Y axis and the Y axis is mapped to the Z axis during the conversion, while the left-hand system difference is handled; when WebGL is the target platform, the Z axis of the Revit coordinate system is mapped to the Y axis and the direction of the Y axis to the Z axis is adjusted during the conversion.
[0094] Through the configurable coordinate conversion parameters, the user can specify the source coordinate system type, the target coordinate system type, the custom axis mapping rule (such as which axis of the target is mapped to the source X axis) and the scaling ratio (unit conversion coefficient).
[0095] The custom axis mapping rule is achieved by configuring three mapping rules. Specifically, the X, Y and Z axes of the source coordinate system are respectively mapped to which axis of the target coordinate system and its direction, and the configuration includes axis correspondence and symbol mark, and the system recombines the coordinate components according to the mapping rule. For example, for the conversion from Revit to Unity, since the Z axis of Revit is upward and needs to be mapped to the Y axis of Unity which is upward, the Y axis of Revit is forward and needs to be mapped to the Z axis of Unity which is forward, and the handedness conversion from right-hand system to left-hand system is handled, the axis mapping rule can be configured as X axis remains, Y axis is mapped to Z axis and takes inverse, Z axis is mapped to Y axis, and the conversion formula is (X, Z, -Y). For another example, for the conversion from Revit to WebGL, since WebGL is also a right-hand system but the direction of the Z axis is opposite, different mapping rules and symbol processing need to be configured, the axis mapping rule can be configured as X axis remains, Y axis is mapped to Z axis, Z axis is mapped to Y axis and takes inverse, and since both are right-hand systems, no handedness conversion is needed, and the conversion formula is (X, -Z, Y). Through this flexible configuration mode, the system can adapt to the coordinate system difference between different platforms, and ensure the geometric accuracy and direction consistency of the model in the conversion process.
[0096] The user can set the coordinate conversion parameters through a configuration file or an export dialog box, and according to the user-configured coordinate conversion parameters, the coordinate conversion can be achieved by dynamically generating a conversion matrix or performing a corresponding coordinate mapping operation. Moreover, preset configurations can be saved for different target platforms to realize quick switching.
[0097] Among them, the dynamically generated conversion matrix refers to the one calculated in real time according to the configured coordinate conversion parameters (axis mapping, axis direction mark and scaling ratio), which can be converted using matrix multiplication: new coordinates = conversion matrix x original coordinates, and the dynamically generated conversion matrix is suitable for scenarios requiring complex transformation (such as rotation, scaling or mirroring).
[0098] The corresponding coordinate mapping operation is performed, that is, the coordinate components are directly reorganized according to the mapping rule, for example, the mapping rule is configured as X axis remains, Y axis is mapped to Z axis, Z axis is mapped to Y axis and is negated, and the new coordinates obtained by directly performing the coordinate mapping operation are (original X, original Z, -original Y). The corresponding coordinate mapping operation is simpler and more direct, and is suitable for simple axis remapping scenarios.
[0099] After obtaining the vertex list after coordinate conversion, the model center point can also be automatically adjusted. Specifically, the geometric center of the model is determined by calculating the arithmetic mean of the converted coordinates of all vertices, and then the geometric center point coordinates are subtracted from the converted coordinates of each vertex to obtain new vertex coordinates, so that the model takes the geometric center as the origin in the target platform, ensuring that the rotation and scaling operations are performed around the center of the model, and providing a more intuitive operation experience.
[0100] Unlike the prior art, since Revit uses a right-handed coordinate system with the Y axis upward, and Web 3D rendering usually uses a different coordinate system, direct export will cause the model to be in the wrong direction. The BIM model geometry and material export method provided in the present application can dynamically generate a conversion matrix or perform a corresponding coordinate mapping operation through configurable coordinate conversion parameters, effectively solving the problem of model direction error caused by incompatible coordinate systems. Not only does it support complex coordinate transformation requirements such as rotation, scaling, or mirroring, but it can also quickly handle basic conversion scenarios through simple axis remapping. In addition, the function of automatically adjusting the model center point further optimizes the display effect of the model in the target platform.
[0101] S50: Based on the material information, the vertex list, and the corresponding texture coordinates, generate a double-format material file and a model data file.
[0102] In the present application, the material information also includes a texture map path. That is, when extracting the material information, the texture map path (relative path or file name) is extracted, which points to the actual picture file in the Revit material library.
[0103] In the present application, based on the material information, the vertex list, and the corresponding texture coordinates, a double-format material file and a model data file are generated, including: S51: Based on the texture map path, copy each texture file and rename it to obtain a renamed texture file.
[0104] After extracting the material information, the texture files are processed. First, the actual file location is recursively searched in the Revit material library according to the extracted texture map path, and then the found texture files are copied to a subfolder of the export directory and renamed (including removing spaces, adding type prefixes, etc.), and the renamed texture files are stored as independent files, which can be referenced by the texture map path in the material file.
[0105] By copying and renaming the texture file, firstly, the texture files scattered in each directory of the Revit material library can be uniformly copied to the subfolder of the export directory, so that the exported model file, material file and texture file form a self-contained complete data package, which is convenient for deployment and distribution and does not depend on the Revit installation environment; secondly, the space characters in the file name are replaced with underscores through the renaming process, avoiding the problem that some Web servers or 3D engines are not friendly to file paths containing spaces, and if the same name file already exists in the target directory, the texture type prefix (such as diffuse_ or normal_) is added in front of the file name to avoid the conflict and ensure that all texture files can be saved correctly. Moreover, users do not need to manually find, copy the texture file or modify the path, and the entire folder can be directly deployed for use after the export is completed.
[0106] Unlike the prior art in which the texture file path referenced in the material is lost during the export process and the texture file needs to be manually processed. The BIM model geometry and material export method provided in the present application precisely locates and copies the texture file in the Revit material library during the material extraction stage, and simultaneously implements an intelligent renaming strategy, including but not limited to removing spaces in the file name, adding a prefix according to the texture type, etc. Not only does it ensure the close association of the texture file with the model and material file, forming a self-contained data package that does not depend on the Revit installation environment, but it also greatly facilitates the deployment and distribution of the model. More importantly, it completely eliminates the tedious steps of manually finding and copying the texture file, as well as errors caused by path loss or file name conflicts, so that the exported folder can be used for deployment immediately, significantly improving work efficiency and data management accuracy.
[0107] S52: Convert the material information into MTL format and JSON format at the same time to generate MTL material file and JSON file respectively.
[0108] For the extracted material information, conversion is simultaneously performed to MTL and JSON formats, so that the material information is contained in both MTL and JSON files, realizing double-format material file output.
[0109] MTL file (Material Library File, material library file) uses the traditional MTL format to define material properties, such as ambient light (Ka), diffuse reflection (Kd), specular reflection (Ks), glossiness (Ns) and transparency (d) parameters. MTL format is a standard defined in the 1990s, mainly serving traditional 3D modeling software and simple renderers, supporting basic lighting models.
[0110] JSON (JavaScript Object Notation) file is a lightweight data exchange format that uses a modern structured format to define material properties, including color, metallic, smoothness, roughness, transparency, emission, and other complete PBR physical properties, as well as more detailed texture information (all texture types with clearer structure) and texture scaling factors (texture scaling factors are not directly stored in MTL files). It is designed specifically for modern Web rendering engines such as Three.js, supporting physically-based rendering.
[0111] The conversion of material information to MTL format includes color attribute conversion, metallic attribute conversion, smoothness attribute conversion, transparency attribute conversion, self-emission attribute conversion, and texture mapping, etc.
[0112] Color attribute conversion: Convert Revit material color to MTL format ambient light and diffuse reflection properties. Specifically, first extract the RGB color value (0~255) from the Revit material information and normalize it, store it in the color attribute; when generating the MTL file, the diffuse reflection attribute directly uses this normalized RGB value to represent the main color of the material, and the ambient light attribute uses the RGB value multiplied by the brightness coefficient to represent it. The brightness coefficient is set according to actual needs, such as 0.3, that is, take 30% brightness, because in the real light model, the ambient light is usually darker than the diffuse reflection light, which can simulate the weak lighting effect of the ambient light on the object. For example, the RGB of the red material in Revit is (204, 51, 51), and after normalization, it is (0.8, 0.2, 0.2). Write diffuse reflection as (0.8, 0.2, 0.2) in the MTL file, and ambient light as (0.24, 0.06, 0.06).
[0113] Metallic attribute conversion: Convert Revit material metallic to MTL format specular reflection attribute, and use high gloss mapping strategy for metallic materials. Specifically, the metallic attribute conversion is to directly use the Revit metallic value (range 0 to 1) as the three component values of the specular reflection attribute in the MTL file. Specular reflection represents the specular reflection color, such as when the metallic is 0.8, write specular reflection as (0.8, 0.8, 0.8). So that the metallic material will have a higher specular reflection, and the non-metallic material will have a weaker specular reflection.
[0114] High gloss mapping strategy is to use different coefficients to calculate the gloss attribute according to whether the material is a metal type. For metal materials, the formula: Gloss = Smoothness × 800 + 200 can be used, and the result is limited between 100 and 1000, for example, the gloss value of a metal material with a smoothness of 0.5 is 600. For non-metal materials, the formula: Gloss = Smoothness × 500 + 50 can be used, and the result is limited between 10 and 500, for example, the gloss value of a non-metal material with a smoothness of 0.5 is 300. Among them, the constant parameters in the formula can be adjusted according to specific needs, here is only an example. Metal materials use higher coefficients and baseline values because metal surfaces usually have stronger and more concentrated highlights, while non-metal materials have more dispersed and soft highlights. The high gloss mapping strategy can make metal and non-metal materials have different gloss characteristics in rendering that conform to physical laws.
[0115] Smoothness attribute conversion: Convert Revit material smoothness to MTL gloss attribute, use different mapping strategies according to material type (metal material: Gloss = Smoothness × 800 + 200, non-metal material: Gloss = Smoothness × 500 + 50). When implemented, the code first determines whether the material is a metal type, and the specific conversion method can refer to the high gloss mapping strategy described above, which will not be repeated here.
[0116] Transparency attribute conversion: Convert Revit material transparency to MTL transparency attribute, use the inverse mapping formula d = 1.0 - Transparency, where d is MTL transparency and Transparency is Revit transparency. Because Revit and MTL have opposite definitions of transparency, the larger the Transparency value in Revit, the more transparent it is, 0 means completely opaque, and 1 means completely transparent, while in MTL, the larger the d attribute value, the more opaque it is, 1 means completely opaque, and 0 means completely transparent. Therefore, you can subtract the transparency value of Revit from 1 to get the d value of MTL, for example, Revit transparency 0.3 (30% transparent) corresponds to MTL d value 0.7 (70% opaque), Revit transparency 1.0 (completely transparent) corresponds to MTL d value 0 (completely transparent). At the same time, this converted opacity value will also be set to the Alpha channel of Color, ensuring that the transparency information is correctly expressed in both JSON and MTL formats.
[0117] Self-luminous attribute conversion: convert the Revit self-luminous material into the self-luminous attribute of MTL, and use a special illumination model (illum 3). The use of the special illumination model is realized by setting the illum parameter to 3 in the MTL file. The MTL format defines multiple illumination models, and illum 2 is a standard ambient light plus diffuse reflection plus specular reflection model, and illum 3 represents self-luminous plus reflection model, which is used to tell the renderer that the material itself emits light. In the specific implementation, first, it is judged whether the material is a self-luminous material. If it is a self-luminous material, the base color of the material is multiplied by the luminous intensity to write the self-luminous attribute value into the MTL file, for example, a red material RGB (0.8, 0.2, 0.2) and a luminous intensity of 0.5, then write the self-luminous attribute value (0.4, 0.1, 0.1), and set the specular reflection Ks to 0 and the glossiness Ns to 0, because the self-luminous material does not need these reflection attributes, and finally write illum 3 to specify the illumination model. If it is a normal material, write illum 2 to use the standard illumination model. When the renderer reads the MTL file, it will see illum 3 and process it according to the self-luminous model, so that the material is not affected by the scene lighting and displays its own luminous color, simulating the effect of self-luminous objects such as lamps and displays.
[0118] Texture mapping: support standard MTL texture mapping such as diffuse map (map_Kd) and normal map (map_Bump).
[0119] The material information is converted into JSON format, which can be directly converted. Specifically, the material attributes, texture map paths and texture scaling coefficients stored in the material list during the material extraction stage can be directly serialized into a JSON string to generate a JSON format material file without additional conversion.
[0120] After the format conversion is completed, the MTL file contains the basic lighting attributes and the texture map path; the JSON file contains the complete PBR material attributes and the texture map path. Among them, the texture map path is automatically updated to the path relative to the export directory after copying and renaming the texture file.
[0121] Unlike the prior art, due to the differences between the material structure of Revit and the material structure of other platforms, the material information cannot be correctly transmitted, and the model lacks realism when displayed on the Web. The BIM model geometry and material export method provided in the present application exports the material file in MTL and JSON formats, not only handles the basic lighting attributes, but also retains the PBR material attributes completely, so that the model can present a realistic visual effect under different lighting environments. The JSON format supports modern PBR rendering systems, and the MTL format supports traditional renderers and 3D modeling software, providing wider compatibility.
[0122] S53: generating a model data file based on the vertex list and the corresponding texture coordinates.
[0123] An OBJ (object) file is a public 3D geometry definition file format for storing model collection data, which can be referred to as a model data file.
[0124] For the vertex list obtained after the coordinate conversion and adjustment of the model center point, or the vertex list obtained after the vertex deduplication without determining the target platform (i.e., without coordinate conversion), the vertex list and the corresponding texture coordinates, triangle index, and material reference are stored in an OBJ file to generate a model data file.
[0125] A double-format material file establishes a corresponding relationship through a material identifier. An OBJ file can directly reference the material definition in an MTL through a usemtl command. Traditional software and standard Web 3D loaders automatically process the combination of OBJ and MTL. The JSON format provides complete material data for applications requiring advanced rendering effects. By reading a JSON file through custom material loading and application logic, more rich PBR properties are applied to the model according to the material identifier.
[0126] It can be understood that the execution order of the above steps S51-S53 can be sequential or reverse, or parallel execution, and the execution order is not limited.
[0127] Finally, the model files generated after exporting the BIM model include an OBJ file (model data file), an MTL file, a JSON file, and a texture file, forming a complete export data set.
[0128] In this application, when exporting a large BIM model, batch processing can be performed for export, i.e., a large number of elements in the model are processed in batches rather than loading all data at once. For example, 50 elements are processed each time, the geometry and material information of the 50 elements are extracted, and then the next batch is processed. After processing each batch, garbage collection is performed to release memory, avoiding memory overflow when exporting a large BIM model. At the same time, different types of elements such as walls, floors, and doors and windows can also be processed in batches. After processing each type, a log is recorded. Through the batch processing strategy, a large building model containing thousands or even tens of thousands of elements can be processed. During the processing, stable memory occupation is maintained, and the model will not crash or run slowly due to the large size of the model. The export efficiency is greatly improved.
[0129] In an embodiment, refer to Figure 2 , Figure 2is a process schematic diagram of automatic model export of an embodiment of the BIM model geometry and material export method provided by the present application. First, the geometry, material identifier and material information (including texture map path) of the BIM model are extracted, and each face of each geometry is divided based on the material identifier to obtain a plurality of merged meshes; then, for each merged mesh, material processing and geometry processing are performed respectively, the material processing process includes generating the texture coordinates of each vertex, copying and renaming the texture file, and converting the material into JSON and MTL dual-format material files, and the geometry processing process includes vertex deduplication when merging the mesh, target platform coordinate system conversion and center point generation are performed on each vertex in the deduplicated unique vertex list to obtain a converted vertex list; finally, based on the vertex list and the corresponding texture coordinates, an OBJ file is generated, which is output together with the JSON and MTL dual-format material files and the texture file to form a complete export dataset.
[0130] The present application provides a BIM model geometry and material export device, referring to Figure 3 , Figure 3 is a structural schematic diagram of an embodiment of the BIM model geometry and material export device provided by the present application, and the BIM model geometry and material export device comprises: a model extraction module 10 configured to extract the geometry, material identifier and material information of the BIM model; a material merging module 20 configured to divide each face of each geometry based on the material identifier to obtain a plurality of merged meshes; a texture mapping module 30 configured to generate corresponding texture coordinates for the vertices of each face of each geometry based on a dynamic texture mapping strategy; a vertex deduplication module 40 configured to perform vertex deduplication on each merged mesh to obtain a vertex list; a file generation module 50 configured to generate dual-format material files and model data files based on the material information, the vertex list and the corresponding texture coordinates.
[0131] The model extraction module 10, the material merging module 20, the texture mapping module 30, the vertex deduplication module 40 and the file generation module 50 interact to realize the process of BIM model geometry and material export, which can be referred to the specific description of steps S10-S50 above, and the repeated parts will not be described here.
[0132] Referring to Figure 4 , Figure 4 is a structural schematic diagram of an embodiment of the storage medium provided by the present application.
[0133] The storage medium 400 stores program data 410, which, when executed by a processor, realizes the processes of the BIM model geometry and material export device as described above. Figure 1Steps of the described BIM model geometry and material export method.
[0134] The program data 410 is stored in a storage medium 400, including a plurality of instructions for causing a network device (such as a router, a personal computer, a server, etc.) or a processor to perform all or part of the steps of the method described in various embodiments of the present application.
[0135] Optionally, the storage medium 400 can be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0136] Reference Figure 5 , Figure 5 is a structural schematic diagram of an embodiment of the computer device provided by the present application.
[0137] The device 500 includes a processor 520 and a memory 510 connected to each other, and the memory 510 stores a computer program, and the processor 520 executes the computer program to implement the steps of the BIM model geometry and material export method described above.
[0138] Different from the prior art, the present application discloses a BIM model geometry and material export method and device. The method divides the faces of each geometry based on material identification, obtains a plurality of merged meshes, and removes duplicate vertices of each merged mesh to reduce data redundancy and improve rendering performance. Through a dynamic texture mapping strategy, corresponding texture coordinates are generated for the vertices of each face to ensure correct texture mapping and improve visual effects. By generating a double-format material file, all material properties are completely retained, including color, physical properties, texture path, etc., and the double format can support various 3D software and renderers, providing more extensive compatibility.
[0139] Each embodiment in the specification is described in a progressive manner, and the same or similar parts of each embodiment can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the storage medium embodiment and the computer device embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0140] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, network PCs, small computers, distributed computing environments including any of the above systems or devices, etc.
[0141] In several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other manners. For example, the embodiments of the device described above are merely illustrative, and for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0142] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments.
[0143] In addition, each functional unit in the various embodiments of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware, or in the form of a software functional unit.
[0144] The above description is merely an example of the embodiments of the present application, and does not limit the patent scope of the present application, and any equivalent structure or equivalent flow transformation made by using the content of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for exporting BIM model geometry and materials, characterized in that, include: Extract the geometry, material identifiers, and material information from the BIM model; Based on the material identifier, the faces of each geometry are divided to obtain multiple merged meshes; Based on the dynamic texture mapping strategy, corresponding texture coordinates are generated for the vertices of the face of each geometry. For each merged mesh, vertex deduplication is performed to obtain a vertex list; Based on the material information, the vertex list, and the corresponding texture coordinates, a dual-format material file and a model data file are generated.
2. The method for exporting BIM model geometry and materials according to claim 1, characterized in that, The material information includes a texture scaling factor; The dynamic texture mapping strategy generates corresponding texture coordinates for the vertices of each face of the geometry, including: For each face of the geometry, the face type is determined based on the normal direction of the face; Select the corresponding dynamic texture mapping strategy based on the surface type, and determine the texture coordinate origin and scaling reference based on the surface boundary and the texture scaling factor; Based on the dynamic texture mapping strategy, the texture coordinate origin, and the scaling reference, the texture coordinates corresponding to each vertex are calculated.
3. The method for exporting BIM model geometry and materials according to claim 2, characterized in that, The surface types include horizontal surfaces, X-axis vertical surfaces, Y-axis vertical surfaces, and inclined surfaces; The step of calculating the texture coordinates corresponding to each vertex based on the dynamic texture mapping strategy, the texture coordinate origin, and the scaling reference includes: In response to the surface type being the horizontal surface, the U value is calculated based on the X-axis coordinate component of the vertex, and the V value is calculated based on the Y-axis coordinate component of the vertex; In response to the surface type being a plane perpendicular to the X-axis direction, the U value is calculated based on the Y-axis coordinate component of the vertex, and the V value is calculated based on the Z-axis coordinate component of the vertex; In response to the surface type being a surface perpendicular to the Y-axis direction, the U value is calculated based on the X-axis coordinate component of the vertex, and the V value is calculated based on the Z-axis coordinate component of the vertex; In response to the surface type being the inclined surface, the texture coordinates are calculated based on the projected coordinates of the vertex in the local coordinate system projection of the surface.
4. The method for exporting BIM model geometry and materials according to claim 2, characterized in that, The function for calculating the texture coordinates is: , Formula 1; Where t is the U or V value of the texture coordinates; vertex is the coordinate component; min is the origin of the texture coordinates; uvScale is the texture scaling factor; unitScale is the unit conversion factor; and k is the adjustment factor. The scaling reference is denoted as .
5. The method for exporting BIM model geometry and materials according to claim 1, characterized in that, The process of removing duplicate vertices from each merged mesh to obtain a vertex list includes: For each merged mesh, create and initialize a vertex list; Traverse the vertex list, calculate the three-axis coordinate difference between the current vertex and each vertex in the vertex list, and determine whether each three-axis coordinate difference is less than the first preset tolerance value; In response to the fact that the differences in the three coordinate axes are all less than the first preset tolerance value, the current vertex is deduplicated; In response to the fact that the differences in the three-axis coordinates are not all less than the first preset tolerance value, the current vertex is added to the vertex list; The process continues until all vertices of the merged mesh have been traversed, resulting in a deduplicated list of vertices.
6. The method for exporting BIM model geometry and materials according to claim 5, characterized in that, In response to the fact that the differences in the three coordinate axes are all less than the first preset tolerance value, the method further includes: Determine whether the difference between the texture coordinates of the current vertex and the vertices in the vertex list is less than a second preset tolerance value; In response to the texture coordinate difference being less than the second preset tolerance value, the current vertex is deduplicated; In response to the texture coordinate difference being no less than the second preset tolerance value, the current vertex is added to the vertex list.
7. The method for exporting BIM model geometry and materials according to claim 1, characterized in that, The process of dividing the faces of each geometry based on the material identifier yields multiple merged meshes, including: Triangulate the faces of each geometry to obtain multiple meshes; All meshes with the same material identifier are merged to obtain the merged mesh.
8. The method for exporting BIM model geometry and materials according to claim 1, characterized in that, After obtaining the vertex list, it also includes: Based on configurable coordinate transformation parameters and the target coordinate system of the target platform, the coordinates of all the vertices are transformed to the target coordinate system to obtain the list of vertices after coordinate transformation, and the center point of the BIM model is automatically adjusted.
9. The method for exporting BIM model geometry and materials according to claim 1, characterized in that, The material information also includes texture mapping paths; The process of generating a dual-format material file and a model data file based on the material information, the vertex list, and the corresponding texture coordinates includes: Based on the texture mapping path, copy each texture file and rename it to obtain the renamed texture file; The material information is simultaneously converted into MTL and JSON formats to generate MTL material files and JSON files, respectively. The model data file is generated based on the vertex list and the corresponding texture coordinates.
10. A device for exporting BIM model geometry and materials, characterized in that, include: The model extraction module is used to extract the geometry, material identifiers, and material information of the BIM model. The material merging module is used to divide the face of each geometry based on the material identifier to obtain multiple merged meshes; The texture mapping module is used to generate corresponding texture coordinates for the vertices of each face of the geometry based on a dynamic texture mapping strategy. The vertex deduplication module is used to deduplicat vertices for each of the merged meshes to obtain a vertex list; The file generation module is used to generate a dual-format material file and a model data file based on the material information, the vertex list, and the corresponding texture coordinates.