General mechanical disassembly simulation is used for training demonstrations, such as large-scale machinery disassembly is very time-consuming, need a software to simulate the steps of disassembly, to the unskilled workers to demonstrate the precautions and so on. The application is very extensive. Therefore, a general framework is designed to adapt well to changing needs.
Using unity makes it easy to develop virtual reality software, and the program part requires only ordinary programmers to complete the project.
Mechanical disassembly simulation is the most common project in the last two years, a large number of orders and simulations that need to be made. Loang also received a list of these when he was a sophomore. is to a large-scale mechanical equipment disassembly, maintenance demonstration.
Let's start with the general plan for this project (which I did at the outset) by using Unity's animation system to animate every part, such as displacement, rotation, etc. After the completion of production, through the program to invoke the animation of the part, to achieve the disassembly of the demonstration.
The disadvantage of this program is very obvious, one is that, a lot of parts, animation itself is a time-consuming work, the overall production length. Second, the animation system is imperfect and smooth transition of the adjustment, will haunt the developers, so that the production of animation is not stable, inefficient. Third, after the animation, animation changes, such as the speed of movement, position, angle and other adjustments, is a huge task, and the code can not help, the maintenance of the project is very deadly. Four, the scalability is very poor, if there are new parts to fill in, or the new action will test the adaptability of the system, and animation system architecture is difficult to adapt to this change.
In short, unless you do a few analog parts, and everything is fixed, you can use the above scheme. Otherwise, if your project succeeds, it also takes a lot of time and effort, which is money.
General mechanical simulation, the parts will be absolutely no less, a wide range of movements, there are successively order. The moving scheme is also uncertain, such as the position of the part, the angle of placement, and so on. The movement speed of a part is sometimes also required. For example small parts move fast, large parts move slowly.
Based on the above requirements and characteristics, the mechanical simulation, should use transform to achieve. The bottom write the parts of the movement, rotation, speed and other interfaces. At the same time the rotation is not determined axially, and sometimes the rotating axis is not on the body (irregular parts), so the underlying interface should take these into account. If you do not want to write, you can use Itween, and encapsulate the relevant functions.
This article does not provide the source code, only provides the development plan and the idea, if wants the source code, may contact me, certainly that is not free. (In fact, the solution is the most expensive)
Then, the bottom of the implementation of the move is the first step, followed by the second step of the design, the first step of the ordinary programmer is fully capable.
Because there are a lot of parts, you can't write a moving method for each part. So we need to define some common rules, such as moving, rotating, etc., and generating the corresponding fields. Perhaps you have guessed, the second step is to do a data persistence layer, about the design of this database, I will not talk about, look at personal needs. Define the movement, rotation, position, speed and other parameters of the part, then save it and read it when running the program. The advantage is that you can dynamically modify the action of the part. Even if you do not program, you can change the "animation" of the mechanical simulation by modifying the data directly without knowing unity. This part of the design is relatively simple, depending on the specific needs. For databases, the general local database is sufficient. Ready-made databases have SQLite, but cross-platform is bad. XML, simple and convenient, cross-platform. See my previous blog for details.
The third step is the encapsulation of the algorithm structure. This level is mainly responsible for the design of parts operation, to provide various methods of operation of the parts, such as add action, modify the action, etc., no outside of some position, angle, speed of access and so on. This kind of general programmer can do well, the key is to see the specific needs of you.
Fourth step, make a UI, a visual "animation" editor. This motion editor is not a unity animation editor. It can be understood as a call to the method of the first three steps. If you directly modify the parameters in the database, there is no intuitive feeling, tuning parameters is also very troublesome, each time the re-open program to see the effect, so you need to make a part of the action editor to complete.
Specifically, in one scene, load all the parts and then click through the mouse to get the parts. It's easy to do this, with all the parts adding a meshcollder and then colliding with the rays. Because of the number of parts, we can dynamically add Collder components, the process is relatively slow, very easy to lag, we recommend the use of the association process. Once the part is selected, you can edit the action of the part. The specific UI is designed to look at the needs of everyone, but the function of no outside, moving (select axial), rotation (select axial), speed parameters and so on. For ease of viewing, you can also add a preview function, which allows you to see the moving track of a part after editing is complete. The function is also very good to complete, use a table, store the starting position, and then read the move parameters on the line.
Of course, shortcut keys can also be added to the UI design, the purpose is to facilitate the design of parts movement. In the end, you can also simulate the unity engine operation of the object, mouse drag parts, through similar anchor points, storage key points, set speed and so on, a simple and convenient "animation" editor is perfect.
The motion editor can be used as an advanced feature, allowing users to customize the action of the part, simulate the disassembly of the animation, and can also be modified in real time. In this case, the software has better flexibility. At the same time, it is convenient to add new parts. Not only that, in the face of a new simulation project, there is no need to modify the code, directly to the art of the model placed in the specified folder is OK. It depends on your resources to load the design.
This article connection: http://www.cnblogs.com/jqg-aliang/p/4825460.html, reprint please declare the source, thank you!
Virtual reality mechanical Disassembly Project architecture