This post will detail the process needed to get from a solidworks model of a park to a basic ksp .mu file
- SolidWorks (Tested with 2014, later versions might not apply)
- SolidWorks OBJ Conversion Macro
- Unity 5.3.5f1
- Kerbal Space Program (At least 1.1.3)
- Kerbal Part Tools (It states this is part tools for 1.1.2, it is still valid for 1.1.3)
This process can be broken up into two steps. Getting from Soldworks to Unity, and then getting from Unity to KSP. The first step is simply a matter of exporting to a file format readable by unity, namely a .obj file. The second step involves some more detailed work setting up the part model, textures, and placing relevant coordinate frames.
Setting up Unity
This section needs to be verified, steps may have changed
- Open Unity, create a new project
- Copy the entire Part Tools folder into the unity project’s assets folder
- A “Tool” menu should now be available in the unity toolbar. Click Tools»KSP Part Tools and point to the GameData folder of a vanilla version of KSP (no mods).
- Go into the Part Tools folder in Assets and double click PartTools_AssetBundles, click import.
- Should now be set up?
Getting from SolidWorks to Unity
- Make a solidworks part.
- Run the SW OBJ exporter macro
- Open a unity project that is already set up for KSP
- Drag the entire obj folder created via the macro into the assets pane (both .obj and .mtl)
Getting from Unity to KSP
- Navigate to the material file in Assets and change the shader to a ksp shader
- Add a texture. As an example: Drag a background texture from Squad/Kspedia/backgrounds to the texture panel of the material file
- Create an empty game room under Hierarchy
- Under inspector (with the game room selected) click Add Component»KSP»PartTools
- Add model name and file path to write (example: GitHub/ksp-rocket-model/VADL/Parts/XXX/name)
- Drag obj model into the game room
- Select the game object. In the toolbar, go to Component»Physics»Mesh Collider.Point the mesh collider’s mesh to the model mesh, make sure convec mesh is checked.
- Click write in Part Tool component to make the .mu file
Adding coordinate “Transforms”
Some modules require coordinate frames to know where to apply a force or otherwise act. For example, a motor part needs to specify where thrust is applied.
Adding a thrust transform
- In unity, add a game object under the model’s game object (as a child)
- Set the z direction (blue arrow) pointing in the direction of thrust
- name the object “thrustTransform” and reference in in the .cfg file’s ModuleEngineFX module
Adding RCS transform
- make a transform (unity game obj, see above section) for each thrust vector of the rcs system.
- Thrust is in the positive y direction.
- Name all transforms the same name so that onlyh one RCS module is needed in the .cfg file.
Center of Mass
Set the coordinates of the model object in unity so that the model’s Center of Mass is at the origin