Disclosure of Invention
The invention aims to provide a BIM rendering method and a BIM rendering system, so as to solve the technical problem that the derived BIM has an unsatisfactory rendering effect on a webpage side.
In order to solve the problems, the invention adopts the following technical scheme: a BIM model rendering method comprises the following steps:
step S1, building a rendering platform by using a ThreeJS framework based on WebGL;
step S2, importing a glTF file of the original BIM after lightweight processing, and rendering according to a preset rendering strategy;
and step S3, after the rendering processing is finished, displaying the rendered BIM model on the browser end in real time.
The principle and the advantages of the scheme are as follows: during actual application, a rendering platform is built by using a WebGL-based ThreeJS framework, a lightweight BIM model is rendered, the processing mode of Mesh data is adjusted according to the number Count of vertexes of Mesh nodes in a glTF file derived from the BIM model and the number N of times of quoting, the data is classified and then differentially rendered and displayed, efficient rendering of the BIM model is achieved, and the rendering effect of the BIM model is effectively improved. Compared with the prior art, the method has the advantages that the vertex number Count of the Mesh nodes in the glTF file and the reasonable analysis and utilization of the quoted times N are achieved, the calculation capacity of the GPU and the CPU are fully considered, the best rendering display effect is provided on the premise that the data volume is relatively small, the rendering effect of the BIM is greatly improved, meanwhile, the utilization rate of the memory and the video memory can be effectively reduced, and therefore the rendering efficiency of the BIM is effectively improved.
Preferably, as an improvement, the preset rendering strategy includes the following contents:
retrieving the vertex number Count and the number N of quoted times of each Mesh node in the glTF file;
performing rendering frame rate processing on the Mesh node by utilizing the size relation between the product of the number of times N to be quoted and the number of vertexes Count and the threshold value epsilon and combining the merge technology and the instance technology;
and after finishing the rendering frame rate processing of each Mesh node in the glTF file, outputting a processed rendering BIM.
By the rendering strategy, the rendering effect of the glTF file can be effectively improved, the simplification of data is realized on the basis of ensuring the rendering effect, the degree of frame rate rendering is improved, and the problem that a large amount of memory is occupied by the data is solved.
Preferably, as an improvement, the rendering frame rate of the Mesh node is processed in such a way that if the product of the number of times N that is quoted and the number of vertices Count is greater than the threshold epsilon, the Mesh node performs frame rate rendering by using instance technology, and otherwise, performs frame rate rendering by using merge technology.
The merge technology and the instance technology are adjusted and used by setting a threshold value, the rendering effect and the rendering efficiency of the glTF file can be improved, and the final BIM model can meet the display requirement and can effectively save the memory size occupied by the BIM model.
Preferably, as an improvement, the threshold value epsilon is also dynamically adjusted according to different Mesh nodes in the rendering process.
By dynamically adjusting the threshold value, the rendering mode of the Mesh node is changed, the matching use mode of the merge technology and the instance technology is more variable, the rendering strategy can be adjusted according to different glTF files, and the optimal rendering effect can be achieved on the basis of ensuring the rendering efficiency.
Preferably, as an improvement, the frame rate rendering is performed by using an instance technology, that is, an instance is first performed on a Mesh node at the bottom layer of the glTF, a plurality of Mesh nodes with the same geometry are combined into an instance Mesh, and each instance Mesh node is independently sent to the GPU for processing.
If the data volume is large, the Mesh node data in the glTF file is processed for multiple times, the data volume processed each time is reduced, rendering blockage caused by overlarge data volume is avoided, the processing speed of the system is reduced, and therefore data processing efficiency and rendering efficiency are guaranteed.
Preferably, as an improvement, the merge technology is used for performing frame rate rendering, that is, all Mesh node data in the glTF file are merged and then simultaneously sent to the GPU for processing.
If the number of the references of the Mesh objects processed at this time is small and the vertex data amount is small, the data are merged and then processed in the process of reuse, the utilization rate of the GPU can be effectively improved, the rendering frame rate is greatly improved, and the rendering effect of the glTF file is guaranteed.
The invention also provides a BIM rendering system, which comprises a processor module, and a data transmission module, a cloud server module and a display module which are respectively connected with the processor module;
the data transmission module is used for acquiring the glTF file of the BIM after the lightweight processing to form a first data set and sending the first data set to the processor module;
the processor module comprises a data storage unit and a data processing unit, wherein the data storage unit is used for storing a first data set; the data processing unit is used for rendering the first data set according to a preset rendering strategy, obtaining a processed BIM model and then sending the BIM model to the cloud server module and the display module;
the cloud server module is used for storing the processed BIM model in a cloud mode;
and the display module is used for displaying the rendered BIM model in real time.
According to the BIM rendering method, the data transmission module is used for acquiring the glTF file of the BIM after lightweight processing, the glTF file is sent to the processing module for rendering, the data processing unit of the processor module is used by matching of merge technology and instance technology, and the transmission mode of Mesh data is dynamically adjusted, so that the GPU utilization rate and the rendering frame rate are effectively improved, meanwhile, the utilization rates of memory and video memory are reduced, the whole rendering effect is better, the rendering process is more efficient, and finally the rendered BIM is uploaded to the cloud server for storage and displayed through the display module.
Preferably, as an improvement, when obtaining the glTF file after the weight reduction process of the BIM model, only one copy of the same geometric data is kept in the glTF file.
By means of specific setting in a data obtaining mode, the existence of the same geometric data is automatically detected in the process of obtaining the glTF file, if the same geometric data exists, repeated parts are automatically removed, only one part of the same data is reserved, the data can be effectively simplified, accordingly, the occupied space of a memory of a GPU is reduced, and the operation speed is improved.
Preferably, as an improvement, after the data transmission module acquires the glTF file, the data transmission module firstly transmits the glTF file data to the cloud server module for storage, and the data transmission module transmits the data to the processor module for subsequent rendering.
The cloud server module is used for storing and transferring data, the work of the GPU and the CPU can be liberated to a great extent, reliable condition guarantee is provided for subsequent rendering work, the rendering effect of the BIM model is guaranteed, and therefore the BIM model can be displayed on a browser end more clearly and smoothly.
Detailed Description
The following is further detailed by way of specific embodiments:
the reference numbers in the drawings of the specification include: the system comprises a processor module 1, a data transmission module 2, a cloud server module 3, a display module 4, a data storage unit 5 and a data processing unit 6.
The first embodiment is as follows:
this embodiment is substantially as shown in figure 1: a BIM model rendering method comprises the following steps:
step S1, building a rendering platform by using a ThreeJS (namely 3 DJavaSocript library) framework based on WebGL (a 3D drawing protocol);
step S2, importing a glTF file (the glTF is an asset format in the WebGL operation and is a format free of royalties) of an original BIM (building information model) after lightweight processing, and performing rendering processing according to a preset rendering strategy, wherein the glTF is used for efficiently transmitting and loading a three-dimensional scene and a model through an application program;
retrieving vertex types contained in each Mesh node in the glTF file, the number of vertexes contained in each class and the number N of times of being referred;
the vertex types comprise four types of common vertexes, textured vertexes, normal vector vertexes and textured and normal vector vertexes, a vertex factor Ti (1 is not less than i and not more than 4) is respectively set for representing the four types of vertexes, wherein the common vertex factor value is 1, the textured vertex factor value is 1.7, the normal vector vertex factor value is 2, the texture and normal vector vertex factor value is 2.7, Di (1 is not less than i and not more than 4) is respectively set for representing the number of the four types of vertexes, the total quantity of vertexes contained in the Mesh object is sigma Ti Di, the rendering frame rate processing of the Mesh node is carried out by utilizing the magnitude relation of the product of the number of quoted times N and the number of vertexes and a preset threshold value in combination with the merge use of merge technology and the instance technology, if the product of the number of quoted times N and the number of vertexes is more than the threshold value, the Mesh node carries out frame rate rendering by utilizing the instance technology, and merges the Mesh of the bottom layer of the glTF firstly, merging a plurality of mesh with the same geometry into an instance mesh, and independently sending each instance mesh to a GPU for processing; otherwise, performing frame rate rendering by using merge technology, and simultaneously sending all Mesh data in the glTF file to a GPU for processing after merging;
after each Mesh node in the glTF file completes rendering frame rate processing, outputting a processed rendering BIM model;
and step S3, after the rendering processing is finished, displaying the rendered BIM model on the browser end in real time.
As shown in fig. 2, the present disclosure further provides a BIM model rendering system, which applies the BIM model rendering method described above, and includes a processor module 1, and a data transmission module 2, a cloud server module 3, and a display module 4 respectively connected to the processor module 1;
the data transmission module 2 is used for acquiring the glTF file of the BIM after the lightweight processing to form a first data set and sending the first data set to the processor module 1;
the processor module 1 comprises a data storage unit 5 and a data processing unit 6, wherein the data storage unit 5 is used for storing a first data set; the data processing unit 6 is configured to perform rendering processing on the first data set according to a preset rendering strategy, obtain a processed BIM model, and send the BIM model to the cloud server module 3 and the display module 4;
the cloud server module 3 is used for storing the processed BIM model in a cloud mode;
and the display module 4 is used for displaying the rendered BIM model in real time.
The specific implementation process of this embodiment is as follows:
firstly, a rendering platform is built by using a WebGL-based ThreeJS framework, then a data transmission module 2 is used for acquiring a glTF file of a BIM model after lightweight processing, if the acquired glTF file has the same geometric data, only one part of the data is reserved, and then the glTF file is sent to a processor module 1.
And secondly, the data storage unit 5 of the processor module 1 receives and stores the glTF file, then the data processing unit 6 performs rendering processing on the glTF file according to a preset rendering strategy, firstly, the vertex number Count and the referred number N of each Mesh node in the glTF file are retrieved, and then the rendering frame rate processing of the Mesh nodes is performed by using the size relationship between the product of the referred number N and the vertex number Count and the threshold epsilon in combination with the collocation use of merge technology and instance technology.
Thirdly, if the product of the number of times N of reference and the number of vertexes Count is larger than a threshold value epsilon, the Mesh node uses an instance technology to perform frame rate rendering, and Mesh data in the glTF file are sent to a GPU for processing for multiple times; and otherwise, performing frame rate rendering by using merge technology, and simultaneously sending all Mesh data in the glTF file to the GPU for processing after merging.
And fourthly, after finishing the rendering frame rate processing of each Mesh node in the glTF file, outputting a processed rendering BIM, displaying the BIM in real time by using a browser end through a display module 4, and uploading the BIM to a cloud server module 3 for storage.
Many works in many industries involve the design of models, and conventional design software such as Sketchup software can only be displayed in Sketchup software, but cannot be directly displayed in other places, for example, cannot be directly browsed in a browser, because the 3D rendering engine WebGL at the browser end does not support the reading of Sketchup files, great inconvenience is brought to the display and application of the design results, and the application of the design results of the Sketchup software in the internet field is limited.
The traditional Sketchup model derivation scheme comprises an official Sketchup-STL tool, a plug-in-based glTF derivation tool and an intermediate format conversion tool, wherein the official Sketchup-STL tool only can describe the geometric shape of a model, has no attributes such as color, material texture and the like, and is low in applicability.
In the scheme, a rendering platform is built by utilizing a ThreeJS framework based on WebGL, then, the BIM model after the lightweight processing is collected for rendering processing, the vertex number Count of each Mesh node in the glTF file after the BIM model is exported is retrieved, and the number of times N of being quoted, the processing mode of the Mesh data is adjusted by utilizing the magnitude relation between the product of the number of times N of being quoted and the number of vertexes Count and the threshold epsilon and combining the merge technology and the instance technology, the data are classified and then are differentially rendered and displayed, the high frame rate rendering of the BIM model is realized, the computing power of a GPU and a CPU is fully considered, the utilization rate of a memory and a video memory is effectively reduced, the rendering efficiency and the display smoothness are ensured, and the dynamic data transmission mode is realized for rendering according to the difference of data quantity, therefore, the rendering effect of the BIM model is ensured, and the BIM model can be better displayed at a browser end.
Example two:
this embodiment is basically the same as the first embodiment, except that: after the data transmission module 2 acquires the glTF file, the data of the glTF file is sent to the cloud server module 3 for storage, and the data of the glTF file is sent to the processor module 1 by the cloud server module 3 for subsequent rendering.
The specific implementation process of this embodiment is the same as that of the first embodiment, except that:
firstly, a rendering platform is built by using a WebGL-based ThreeJS framework, then a data transmission module 2 is used for acquiring a glTF file of a BIM model after lightweight processing, if the acquired glTF file has the same geometric data, only one part of the data is reserved, then the glTF file data is firstly sent to a cloud server module 3 for storage, and the glTF file data is sent to a processor module 1 by the cloud server module 3 for subsequent rendering work.
In order to reduce the storage and calculation loads of the GPU and the CPU on data, the cloud server module 3 is used for storing and transferring the glTF file data, so that the working intensity of the GPU and the CPU can be greatly reduced, reliable condition guarantee is provided for subsequent rendering work, the rendering effect of the BIM model is guaranteed, and the BIM model can be displayed on a browser end more clearly and smoothly.
Example three:
this embodiment is basically the same as the first embodiment, except that: after a page is loaded with a glTF file, a rendering frame rate can be specified, the rendering frame rate is preset to be lambda, the default value is 30, the threshold value epsilon is divided into M gears, the first gear is e, the second gear is 2e, the third gear is 3e, and the M gear is Me.
As shown in fig. 3, if the current user operation is in an idle state, it is first determined whether the current frame rate is less than 0.8 λ, if the current frame rate is greater than 0.8 λ, the automatic upshift operation is directly ended, if the current frame rate is less than 0.8 λ, β ═ epsilon + e is set, a Mesh object satisfying ∈ N × Count ≦ β in the instance is checked, then it is calculated whether the memory occupied by the Mesh object satisfying the condition is less than the current available memory, if the memory occupied by the Mesh object is greater than the current available memory, the automatic upshift operation is directly ended, if the memory occupied by the Mesh object is less than the current available memory, the Mesh object data is merged into a merge queue, then the current threshold value ∈ β is set, and finally the above operation steps are repeated.
As shown in fig. 4, if the current user operation is in an idle state, it is first determined whether the frame rate is greater than 1.5 λ or the frame rate is greater than 60, if neither is satisfied, the process is directly ended, if the frame rate is greater than 1.5 λ or greater than 60, α ═ e is set, and meanwhile, a Mesh object satisfying α ≦ N × Count ≦ e in instance is checked, then the last added data in the merge queue is cleared, and after the current value of ≦ α is set, the operation is returned to the operation of determining the frame rate size to continue repeating the above operation until the frame rate is less than 1.5 λ or less than 60. Through the default value 30 of the frame rate, the frame rate which is less than 1.5 times of the default value or less than 60 frames is set, so that the rendering effect of the glTF file can be guaranteed, the frame rate can be limited through the set specific value, the unnecessary processing process of the system is reduced, the rendering efficiency is improved, the overall rendering effect is finally guaranteed, and the display effect of the BIM model at the browser end is improved.
The specific implementation process of this embodiment is the same as that of the first embodiment, except that:
thirdly, a preset threshold epsilon totally has M gears, a preset rendering frame rate is lambda, a default value is 30, when a glTF file is initially loaded on a page, epsilon is e, an instance queue and a merge queue process a Mesh node object in the glTF file according to the epsilon, when user operation is in an idle state, the epsilon value is dynamically adjusted by adopting two types of operations of automatic upshifting and automatic downshifting according to the page frame rate, in the upshifting operation, part of Mesh node data larger than the threshold epsilon is added to the tail of the merge queue, the Mesh node data are merged and simultaneously sent to a GPU for processing, and the utilization rate of the GPU is improved; and in the downshift operation, releasing part of Mesh node data of which the tail of the merge queue is smaller than a threshold epsilon, and reducing the utilization rate of the memory and the video memory.
According to the set value of the user, resources such as a memory and a video memory can be flexibly and automatically allocated, and the value of the threshold value epsilon is dynamically adjusted according to the page frame rate, so that the rendering process of the glTF file is more delicate, the threshold value can be accurately adjusted according to the requirement, the technology adopted by the rendering is dynamically adjusted, the rendering requirement of the user is met, and the rendering effect of the BIM model is ensured.
Example four:
this embodiment is basically the same as the first embodiment, except that: the frame rate range is preset to be 30-60 frames, when a glTF file is initially loaded on a page, all the Mesh objects are stored in an instance queue, total Mesh node objects are set, and the product fi of the number of vertexes of each Mesh node object and the number of reference times is Ni Ci (i is more than or equal to 0 and less than total), wherein Ni represents the number of reference times of the Mesh node object, and Ci represents the number of vertexes of the Mesh node object. And F is stored in an array F and sorted from small to large. And setting epsilon to represent the position of the currently pointed F array, wherein epsilon is-1 initially, and when the page is in an idle state, dynamically adjusting the epsilon value according to the page frame rate, wherein the adjustment is divided into two types of operation, namely automatic upshift and automatic downshift.
As shown in fig. 5, if the current page operation is in the idle state, it is determined whether the current frame rate is less than 30, if the current frame rate is less than 30, the process is ended directly, if the current frame rate is greater than 30, β ═ e +1 is set, and if β is greater than 30, β ═ e +1 is set>total, which indicates that all Mesh node objects use merge technology, and the execution is finished if beta<total, then calculate FβIf the occupied internal memory quantity is less than the current available internal memory quantity, directly ending the operation if the occupied internal memory quantity is greater than the current available internal memory quantity, otherwise, FβAnd merging the pointed Mesh object data into the merge queue, setting the current epsilon as beta, returning to judge the frame rate, and repeating the operation.
Automatic downshift operation as shown in fig. 6, if the current page is operatedIf the current frame rate is greater than 60, if the current frame rate is less than 60, the operation is ended directly, if the current frame rate is greater than 60, alpha is equal to epsilon-1, and if alpha is greater than 60, the operation is ended directly<0, indicating that all the Mesh objects use the instance technology, ending the execution, otherwise clearing F in the merge queueαAnd pointing to Mesh node object data, setting the current epsilon as alpha, returning to judge the frame rate size, and repeating the operation. The frame rate is fixedly set within the range of 30-60 frames, and the files beyond the range are subjected to gear lifting operation, so that the final frame rate requirement is met, the rendering effect within the range can be ensured, the file processing speed within the range is effectively increased, the rendering effect of the system is improved, the workload of a processor is reduced, and the rendering effect is ensured while the working efficiency is ensured.
The specific implementation process of this embodiment is the same as that of the first embodiment, except that:
thirdly, presetting the frame rate range to 30-60, when the glTF file is initially loaded on the page, storing all the Mesh objects into an instance queue, and designing total Mesh node objects, wherein the product fi of the number of vertexes of each Mesh node object and the number of times of reference is Ni Ci (i is more than or equal to 0)<total), where Ni represents the number of references of the Mesh node object and Ci represents the number of vertices of the Mesh node object. And F is stored in an array F and sorted from small to large. Setting epsilon to represent the position of the F array pointed at currently, initially setting epsilon to-1, dynamically adjusting the epsilon value by adopting two types of operations of automatic upshift and automatic downshift according to the page frame rate when the page is in an idle state, and during the upshift operation, setting F to be the position of the F array pointed at currentlyα+1Adding corresponding Mesh node data to the tail of the merge queue, merging the Mesh node data and sending the merged Mesh node data to the GPU for processing, and improving the utilization rate of the GPU; in the downshift operation, F in merge queue is releasedαAnd the corresponding Mesh node data reduces the utilization rate of the memory and the video memory. And by controlling the addition and deletion of a single Mesh object in the merge queue each time, the finer-grained resource management is realized.
Frame rate and epsilon value all need not user manual setting, reduce user operation step, make the system can allocate resources such as memory, video memory more fine-grained simultaneously through this kind of mode, improve the efficiency of rendering up to preset frame rate scope can satisfy the demand of user to the effect of rendering up, only through the operation process who increases automatic adjustment, realize the high efficiency of BIM model and render up, improve the effect of rendering up of BIM model, guarantee the bandwagon effect of BIM model at the browser end.
The foregoing is merely an example of the present invention and common general knowledge in the art of designing and/or characterizing particular aspects and/or features is not described in any greater detail herein. It should be noted that, for those skilled in the art, without departing from the technical solution of the present invention, several variations and modifications can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicability of the patent. The scope of the claims of the present application shall be determined by the contents of the claims, and the description of the embodiments and the like in the specification shall be used to explain the contents of the claims.