Creating 3D model assets

Following steps describe how to create a 3D model template that is very beneficial in creation of 3D models of buildings.

  1. Define a layout entity in your mod with desired layout specified using ASCII (see ExampleMachineData.cs).
  2. Set prefab path to "TODO" since we don't have a prefab yet.
  3. Compile and deploy the mod.
  4. Launch game with the newly created machine and run console command generate_layout_entity_mesh_template followed by your entity ID. This will generate an OBJ file in %APPDATA%/Captain of Industry/Misc/GeneratedMeshTemplates which represents a 3D bounding box of layout of your new entity with exact port locations.
  5. If you don't have a 3D model, load the newly created template model to a 3D editor of your choice and create 3D model that fits it. If you already have a 3D model, you can compare it to the generated template and edit the ASCII layout accordingly.
  6. When 3D model is complete, export FBX or OBJ and follow the next steps.

Following steps describe how to package a 3D model.

  1. We recommend organizing assets in directories. Under the Assets directory create <mod name>/<model name> directory, in our case that is ExampleMod/ExampleModel.
  2. Import 3D model files (OBJ, FBX, etc.) and textures (PNG, JPG, etc.) to the model directory. You can simply use drag & drop. Creating a separate folder for each asset is recommended.
  3. Drag the 3D model from Project pane to the Unity scene. Reset its position and rotation to all zeros using Inspector (you can use the three dots menu next to transform) and make it look as you want (add materials, etc.). Note: it is important that your asset has zero position and rotation. If you need to reposition it, change the 3D model or make a child object that can be moved.
  4. Create a prefab by dragging the root object and dropping it to the project pane. This will make a new .prefab file. In our example we created the prefab in the <mod name> directory.
  5. Assign the newly created prefab to any asset bundle from the drop-down menu on the bottom of the Inspector tab. You can create a new temporary bundle called asdf or pick any existing one.
  6. To use prefabs in your mod, simply right-click any prefab and select Copy Path. That path can be used to load your prefab in the game.
  7. Follow steps under the Packaging asset bundles to package the created assets.