Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a Unity 3D-based floor dismantling method and a Unity 3D-based floor dismantling system.
The invention provides a floor disassembling method based on Unity3D, which comprises the following steps:
acquiring a floor three-dimensional space of a target building based on a Unity3D technology;
and moving and disassembling each floor in the three-dimensional floor space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
According to the floor dismantling method based on Unity3D provided by the invention, after the floor three-dimensional space of the target building is acquired based on Unity3D technology, the method further comprises the following steps:
and numbering each floor in the three-dimensional space of the floors according to the floor sequence, and acquiring the floor number of each floor.
According to the floor dismantling method based on Unity3D provided by the invention, the moving dismantling of each floor in the floor three-dimensional space according to the preset floor moving rule to obtain the floor dismantling result of the target building comprises the following steps:
calculating the corresponding moving distance of each floor in the three-dimensional space of the floor according to the floor number of each floor;
and moving each floor to the same horizontal plane in the three-dimensional space of the floors according to the moving distance to obtain a floor disassembling result of the target building.
According to the floor dismantling method based on Unity3D provided by the invention, the step of calculating the corresponding moving distance of each floor in the floor three-dimensional space according to the floor number of each floor comprises the following steps:
acquiring a space coordinate of each floor;
acquiring the displacement distance of the space coordinate of each floor according to the floor number of each floor and the preset floor parameters;
and obtaining the corresponding moving distance of each floor in the three-dimensional space of the floor according to the displacement distance.
According to the floor dismantling method based on the Unity3D, the method further comprises the following steps: and moving and disassembling each floor in the three-dimensional space of the floor through a DoTween script.
The invention also provides a Unity 3D-based floor dismantling system, which comprises:
the floor three-dimensional information acquisition module is used for acquiring a floor three-dimensional space of a target building based on the Unity3D technology;
and the floor disassembling module is used for moving and disassembling each floor in the floor three-dimensional space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
According to the floor dismantling system based on Unity3D provided by the invention, the system further comprises:
and the floor numbering module is used for numbering each floor in the floor three-dimensional space according to the floor sequence and acquiring the floor number of each floor.
According to the floor dismantling system based on the Unity3D provided by the invention, the floor dismantling module comprises:
the floor moving distance calculation unit is used for calculating the corresponding moving distance of each floor in the floor three-dimensional space according to the floor number of each floor;
and the floor moving unit is used for moving each floor to the same horizontal plane in the three-dimensional space of the floors according to the moving distance to obtain the floor disassembling result of the target building.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the steps of the Unity 3D-based floor dismantling method.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the Unity3D based floor dismantling method as described in any of the above.
According to the Unity 3D-based floor dismantling method and the Unity 3D-based floor dismantling system, the building model can be directly dismantled according to floors through the Unity3D technology and is tiled on a horizontal plane, the content of each floor can be visually seen from a top view outside the building, the dismantling process is very simple, and the internal structure of the building model can be more efficiently obtained.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Unity3D is a real-time 3D interactive content authoring and operation platform, including all creators of game development, art, architecture, automobile design and movie and television, which can be realized by the Unity3D technology. The Unity3D platform provides a complete and sophisticated software solution for authoring, operating and rendering any real-time interactive 2D and 3D content, and the supporting platforms include cell phones, tablets, PCs, game consoles, augmented reality and virtual reality devices. When the internal structure of a building model is obtained, the visual angle can be moved into the building model for observation only by moving a camera, and the observation mode can not grasp the internal structure of the building as a whole and can not visually see the distribution of objects on each floor of the building. Based on the problem, in Unity3D, the invention disassembles each floor of the 3D building model separately and lays out on the same plane.
Fig. 1 is a schematic flow chart of a Unity 3D-based floor dismantling method provided by the present invention, and as shown in fig. 1, the present invention provides a Unity 3D-based floor dismantling method, which includes:
and step 101, acquiring a floor three-dimensional space of the target building based on the Unity3D technology.
In the invention, firstly, through the Unity3D technology, model three-dimensional information of a target building is obtained, and a floor three-dimensional space of the target building is constructed according to the model three-dimensional information.
And 102, moving and disassembling each floor in the three-dimensional floor space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
In the invention, each floor in the three-dimensional space of the floors is numbered, for example, the floors are numbered from the top layer to the bottom layer in sequence; then, according to the number of each floor, calculating the moving distance of the floor corresponding to the current number in the three-dimensional space of the floor; and then, according to each calculated moving distance, moving the floor corresponding to the moving distance in the three-dimensional floor space, so that each floor moves to the same horizontal plane in the three-dimensional floor space, and thus, obtaining a floor disassembling result of the target building.
According to the Unity 3D-based floor dismantling method, the building model can be directly dismantled according to floors through the Unity3D technology and is tiled on a horizontal plane, the content of each floor can be visually seen from a top view outside the building, the dismantling process is very simple, and the internal structure of the building model can be obtained more efficiently.
On the basis of the above embodiment, after the Unity 3D-based technology is used to obtain the floor three-dimensional space of the target building, the method further includes:
and numbering each floor in the three-dimensional space of the floors according to the floor sequence, and acquiring the floor number of each floor.
On the basis of the above embodiment, the moving and dismantling each floor in the floor three-dimensional space according to a preset floor moving rule to obtain a floor dismantling result of the target building includes:
calculating the corresponding moving distance of each floor in the three-dimensional space of the floor according to the floor number of each floor;
and moving each floor to the same horizontal plane in the three-dimensional space of the floors according to the moving distance to obtain a floor disassembling result of the target building.
On the basis of the above embodiment, the calculating, according to the floor number of each floor, the corresponding movement distance of each floor in the floor three-dimensional space includes:
acquiring a space coordinate of each floor;
acquiring the displacement distance of the space coordinate of each floor according to the floor number of each floor and the preset floor parameters;
and obtaining the corresponding moving distance of each floor in the three-dimensional space of the floor according to the displacement distance.
In the invention, firstly, the three-dimensional information of the target building model is obtained through the Unity3D script, and the floor three-dimensional space is constructed, at the moment, the whole floor three-dimensional space is taken as a whole, and the disassembly of the subsequent steps is carried out. Further, through a Unity3D script, traversing all sub-objects in the three-dimensional space of the floor, and constructing a spatial rectangular coordinate system for the three-dimensional space of the floor, wherein the total length in the X-axis direction is defined as xlength, the total length in the Y-axis direction is defined as ylength, and the total length in the Z-axis direction is defined as zlength, so that the spatial coordinate of each floor is obtained according to the spatial rectangular coordinate system.
Next, each floor is numbered i (i is 0, 1, 2 … …) from the topmost floor to the bottom (the floor may be numbered from the bottommost floor to the top); then, according to a preset disassembly requirement, setting a corresponding preset floor parameter, so as to obtain a displacement distance of a space coordinate corresponding to each floor, wherein the selection of the parameter affects a final disassembly form, for example, the preset floor parameter is set to be 3 for explaining, and after the disassembly of the floors is completed, all floors in a target building are tiled on a horizontal plane where a topmost layer of a three-dimensional space of the floors is located according to a form of 3 rows and N columns.
Specifically, the number i of the floor is divided by 3 to obtain the remainder, wherein the remainder is 0, the moving distance of the floor in the X-axis direction is i/3 × xlength + i/3 × 0.3, the floor is moved to the Y coordinate of the highest floor in the Y-axis direction, and the Z coordinate is kept unchanged; the floor with the remainder of 1 moves in the X-axis direction by a distance of i/3 × xlength + i/3 × 0.3, moves to the Y coordinate of the highest floor in the Y-axis direction, and moves in the Z-axis direction by a distance of zlength + 0.3; the floor with the remainder of 2 moves by a distance i/3 × xlength + i/3 × 0.3 in the X-axis direction, moves to the Y-coordinate of the highest floor in the Y-axis direction, and moves by a distance zlength × 2+0.6 in the Z-axis direction. In the present invention, the i/3 quotient is discarded for the floors whose i/3 remainder is not 0. And finally, acquiring the integral moving distance of each floor in the three-dimensional space of the floor according to the displacement distance in the space coordinate of each floor, so as to disassemble each floor, and enabling all floors in the target building to be flatly paved on the horizontal plane where the topmost floor is located according to the form of 3 rows and N columns.
On the basis of the above embodiment, the method further includes: and moving and disassembling each floor in the three-dimensional space of the floor through a DoTween script.
In the invention, the moving processes of all floors are compiled by using a DoTween script, so that the floors are ensured to be in an animation form when moving in a three-dimensional space of the floors, and the moving distance and the moving time can be accurately controlled, thereby visually seeing the moving process of each floor and the positions of the floors after moving.
Fig. 2 is a schematic structural diagram of a Unity 3D-based floor dismantling system provided by the present invention, and as shown in fig. 2, the present invention provides a Unity 3D-based floor dismantling system, which includes a floor three-dimensional information obtaining module 201 and a floor dismantling module 202, where the floor three-dimensional information obtaining module 201 is configured to obtain a floor three-dimensional space of a target building based on a Unity3D technology; the floor disassembling module 202 is configured to move and disassemble each floor in the floor three-dimensional space according to a preset floor moving rule, so as to obtain a floor disassembling result of the target building.
According to the Unity 3D-based floor dismantling system, the building model can be directly dismantled according to floors through the Unity3D technology and is tiled on a horizontal plane, the content of each floor can be visually seen from a top view outside the building, the dismantling process is very simple, and the internal structure of the building model can be more efficiently obtained.
On the basis of the above embodiment, the system further includes:
and the floor numbering module is used for numbering each floor in the floor three-dimensional space according to the floor sequence and acquiring the floor number of each floor.
On the basis of the above embodiment, the floor dismantling module includes:
the floor moving distance calculation unit is used for calculating the corresponding moving distance of each floor in the floor three-dimensional space according to the floor number of each floor;
and the floor moving unit is used for moving each floor to the same horizontal plane in the three-dimensional space of the floors according to the moving distance to obtain the floor disassembling result of the target building.
The system provided by the embodiment of the present invention is used for executing the above method embodiments, and for details of the process and the details, reference is made to the above embodiments, which are not described herein again.
Fig. 3 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 3: a processor (processor)301, a communication interface (communication interface)302, a memory (memory)303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 complete communication with each other through the communication bus 304. The processor 301 may invoke logic instructions in the memory 303 to perform a Unity3D based floor dismantling method comprising: acquiring a floor three-dimensional space of a target building based on a Unity3D technology; and moving and disassembling each floor in the three-dimensional floor space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
In addition, the logic instructions in the memory 303 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the Unity3D based floor dismantling method provided by the above methods, the method comprising: acquiring a floor three-dimensional space of a target building based on a Unity3D technology; and moving and disassembling each floor in the three-dimensional floor space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
In yet another aspect, the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the Unity 3D-based floor dismantling method provided in the above embodiments, the method including: acquiring a floor three-dimensional space of a target building based on a Unity3D technology; and moving and disassembling each floor in the three-dimensional floor space according to a preset floor moving rule to obtain a floor disassembling result of the target building.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.