全面战争:幕府将军2

全面战争:幕府将军2

评价数不足
Introduction to creating custom naval units
由 :penguin1: 制作
An introductory guide designed to help you get started using the scripts and documentation provided by taw/ChaosRobie to create your own custom naval units for Total War: Shogun 2.
   
奖励
收藏
已收藏
取消收藏
Notes on this guide
This guide is intended as a supplement to the fairly extensive documentation provided inside of the Blender scripts file by taw/ChaosRobie. If you want to know something or have any questions i would recommend first consulting the documentation contained within the Blender scripts file, it most likely contains what you are looking for.

Here are some of the things you can do with the scripts; create completely custom multiple decked naval vessels with custom damage models, meshes and textures, custom flags with particle system physics and much more

All credit goes to taw/ChaosRobie for his amazing scripts and documentation without which making new naval units would be impossible.
Prerequisites
This guide is intended for Windows users and i will be walking through the steps in Blender which is available for free on Steam.

You will need the .blend file containing the scripts which you can get here: https://www.twcenter.net/threads/s2tw-ship-builder.816204/

and you will need the models_naval portion of the file you can download here(if you are new to github, click the drop-down menu where it says "Code" in green and download as a zip file): https://github.com/taw/etwng/tree/master

You will need at least Java JDK 21(maybe JDK 24 is required) or newer to run the jruby scripts. If your computer previously had installed a lower version of Java like JRE 8/9 you will likely have to set a new JAVA HOME path on your computer. You can do this by searching for environment variables in the search bar then select edit system environment variables, and then under the variable name field setting it to JAVA_HOME and under the variable value field pointing it to the directory with your JDK 24 installation.

You will need RustedPackFile Manager to access the packfiles the game uses.

You will need jruby (different to ruby) to run the models_naval scripts. You will also need Python to run the blender scripts.

You will need a 3D texturing program (I use substance painter) that lets you export diffuse, normal, ambient occlusion and gloss_maps.

The Assembly Kit for Shogun 2 is also useful if you want to do things like make custom uniforms for your naval crews.

Lastly you can either use an image editing software like GIMP or Photoshop, or use various browser based services to convert your textures from .png/whatever to .dds format to be compatible with Shogun 2.
Best Practices
Make backups often, its a good idea to keep at least 2 or more backups of your project.

If something breaks or you get an error message when trying to import/export using any of the scripts, double check your notation ( C:\programfiles\etc\... = bad notation, C:/programfiles/etc/... = good notation)

Apply transforms, modifiers and triangulate your mesh if you think you have any ngons (the scripts can handle quads) before making LODs and damage models.

You can also check my mod or taw's mod on the Steam Workshop to see the pack file structure and reverse engineer how to set up your mod.
Importing/Exporting rigidmodels and models_naval db table
The first thing you need to do is open up the data.pack and models.pack packfiles found inside of your ./shogun2/data installation folder. Inside of the data.pack packfile you will need to navigate to db->models_naval and extract the models_naval db table to the folder with your jruby script installation.

The jruby scripts are run from the cmd prompt. First you will have to point the cmd to the correct directory, you do this by typing in cd and copy pasting the directory path that contains your models_naval_script installation and hitting enter. Then you simply copy paste the jruby script into cmd and then hit enter.

Use the script directly below when unpacking the models_naval db table extracted from your data.pack db table. You will probably have to rename the models_naval file to models_naval_dbtable to make the script run correctly. If you did everything correctly you should now have a db_table.xml file and all the other ship's xml files in your models_naval_dir folder. These xml files are what you will be pointing the directory path of the 4 Models_Naval Import blender script towards to import the mesh data into blender.

jruby models_naval_unpack models_naval_dbtable models_naval_dir

use the script directly below when you have exported the xml file containing the mesh data with the 2 Models naval export blender script and packaged it into the models_naval_dir folder alongside a db_table.xml file that you have edited with visual studio or a similar text editing program to only contain your ship.

jruby models_naval_pack models_naval_dir models_naval_dbtable

To import rigid_model_v2 files into blender you simply need to extract the rigid_model_v2 files contained within rigidmodels/naval and extract them to a folder, then point the .blend script to the directory where you extracted them to and then run the script.

When you want to export the rigidmodels, it will similarly create rigid_model_v2 files with the prefix "output" in front of the filename. You can simply edit the name to remove the "output" prefix and then import the new rigid_model_v2 files into your pack file using RPFM.
Texturing
The ships in Shogun 2 uses 4 texture maps; diffuse, normal_map, ambient_occlusion and gloss_map.

From what i understand the gloss_map's red and green channels contain information about the metallic and roughness of the mesh, while the blue channel is used for applying a Clan's color to parts of the mesh.

You can open the gloss_map.dds file in GIMP/Photoshop etc and simply remove the blue channel's influence for any part of your texture you don't want to apply your clan's color to, then go back and paint with a blue color over any part of the mesh you DO want it applied to.

From what I was able to gather, the way you are supposed to do that is just have a blank white diffuse texture with a normal map, gloss map etc containing the details you want it to have to make the color apply correctly.
logic.xml.rigging and placement.placement editing
EDIT: You can also just use the script contained within the .blend file, its much easier and faster. It also lets you create custom flags with any shape you want and still works with the particle physics system.

logic.xml.rigging contains placement of Clan Mon Flags (confusingly called sails within logic.xml.rigging) and Lanterns that spawn during night time, but also contains information for sails (actual sails, not flags) and ropes for rigging which i won't be covering in this guide.

placement.placement contains information for spawning animated oars on both sides of your ship. Both can be opened with Notepad or similar text editing programs.

Weirdly, logic.xml.rigging lantern placement uses XZY coordinates, while placement.placement and the flags inside logic.xml.rigging seem to use conventional XYZ coordinates.

The easiest way to place your oars, lanterns, flags etc is to open your .blend file containing your ship's RMV2 meshes and lining up single vertices to the exact location where you want them to spawn, then copying the coordinate values into the notepad file.

This Google Sheets spreadsheet contains the XYZ offset(X coordinate for every particle is always the same as the X coordinate in particle 1) for correct Clan Mon Flag simulation based on the dimensions of the Heavy Bune's basic flag(sail_sail_01).

Particle 8 is the "parent" particle for the rest of the flag's particles. Therefore you need to calculate the value for each particle based on the offset of a vanilla flag's values, in relation to the new XYZ particle values you now have for your particle 8 (the vertex values you copied over from blender.

You HAVE to calculate the offset for each flag (sail) separately as the offsets are based on the flag's position in relation to the ship. The top of the small flag (sail) is fairly precisely 1.22 meters above particle 8 position, so i would recommend calculating your blender vertices' positions 1.22 meters below where you want to place the top left corner of your flag.


https://docs.google.com/spreadsheets/d/1tYS-9BawtvTflhCdkI1G5k1dw1ERc7-cIkdGft0x-6I/edit?usp=sharing