Thank you eis_os for permission and thanks Yoshi for poking Merk I now have permission from all previous authors to release Version 0.6.0 of the plugin under a CC BY-NC-SA 2.0 License (https://creativecommons.org/licenses/by-nc-sa/2.0/)!
io_mesh_mdl_0.6.0.zip
I guess releasing this to the community makes it a beta version. I should point out that my own internal testing really only tested one workflow (import a stock TpF2 loco -> export it -> view in TpF2 Model Viewer or game, all with Blender 2.77a), so other workflows may well be very buggy. The intent was that the following workflows would remain functional:
- Import TF model -> edit -> export for TF
- Import TpF model -> edit -> export for TpF
...but I didn't explicitly test that these still work, so it is entirely possible that they don't. If you find that they don't, please reply with a bug report (suggested format below) and I will see whether I can fix the issue. Cross-game workflows (TF->Blender->TpF2) wasn't a design goal.
Some notes on configuration:
- You need to set two additional directories under "Blender/User Preferences/Import-Export: Train Fever ..." They are:
- Transport Fever 2 Directory (for many users this will be C:\Program Files (x86)\Steam\steamapps\common\Transport Fever 2\)
- Temporary File Directory. This is a kind of blunt workaround for the fact that res/models is zipped in TpF2; whenever an import relies on a file contained within the .zip file, it checks whether that file exists in this temporary file directory, and if it doesn't, it exports the file from the .zip to the temporary directory. The script never deletes anything from this directory, but you can manually (or you can leave it, so that subsequent imports will go faster). The reason for not getting python to read directly from the .zip is that it would require more extensive script changes and would (as far as I can tell) be significantly slower
- When importing, remember to indicate which game's files you are trying to import. It tweaks some settings
- When exporting, you now have to indicate which game's files you are trying to export. I also added a new option "prefix" to the exporter. If you enter a text string into this box when exporting, every file that gets exported will have that prefix prepended to it (the file references within the output files are also changed, so they still all reference one another). The reason for this features is I kept importing and exporting stock models for testing purposes, and I wanted a way to get the output into the game without replacing the stock models (which is how mods normally work) so that I could compare original and processed models in-game. You might find this handy if you want to re-mod an existing mod or model. I went with a prefix rather than a suffix so that the prefixed files would all be sorted together in my file browser and be easy to delete during testing.
I also changed some settings (like how spacing is inserted in exported files) so that the output files look more similar to the originals in TpF2.
Important Notes:
- I know a lot more about programming than I do about Blender - I'm open to bug reports, but you may have to explain your Blender workflow to me in really basic terms
- If you know as little about Blender as I do, you may be interested to know that those @#$ error messages that flash up when the script errors out are actually recorded somewhere. You can see the whole log of the python script if you enlarge any Info bar (e.g. drag down on the bottom of the menu bar in the default Blender configuration)
Bug Reports:
Please follow the following format:
Steps to reproduce:
- Open Blender 2.77a (default configuration).
- Load [stock model] with the following load settings...
- Click Menu/Menu Entry and then...
Expected Behavior: [describe]
Actual Behavior: [describe]
Vague bug reports will be ignored. Remember that I know more about programming than about Blender
Known Issues:
- Lane import/export (e.g. in station buildings) is not yet supported for TpF2.
- DDS normal map import does not work because the image doesn't have 4 channels (or something). Some models will be exported without
normal maps when the originals are DDS
- DDS textures need to be
flipped in Blender. I could not get the flip_image function within image_util.py to
work like I expected (it was extremely slow and didn't actually change
the way that the texture was applied to the model), so I instead flipped
the UV mapping ( v = 1 - v ) on import if the texture is DDS. This means exported models can't just reference the stock textures (unless you flip the v coordinate back manually).
- The import/export process changes textures a bit - I think that this may just be a result of Blender re-calculating normals (confirmed in TpF2 Model editor that import/export via this tool changes the normals)
- Not compatible with Blender 2.80 or later (making it work with these versions would be way more work - you can try it yourself if you want to prove me wrong!)
Feature Requests:
I am unlikely to entertain these unless they seem like core features which I've overlooked, but anyone is welcome to advance the project themselves under CC-BY-NC-SA 2.0.