Torchmodders
Mod Projects => Lord Nyriox's Playground => Topic started by: Lord Nyriox on May 29, 2018, 03:22:05 pm
-
Windows Scripts:
Automatic Mesh Rebuilding
As I mentioned during the discussion (https://torchmodders.com/forums/modding-questions/(tl2)-monster-class-general-questions/msg8694/#msg8694) on my "Emberdrake" class project, when @Anarch16sync suggested converting meshes to XML (to fix bugs in a previous project of mine), I ended up creating a small suite of recursive Windows command scripts to fully automate that process (using the official OGRE command-line tools).
They do require some initial set-up, but once that is finished, they should be more or less easy to run automatically.
Steps to Use:
- Extract the OGRE command-line tools for version 1.7.x into a directory. Make sure that OgreXMLConverter.exe, OgreMeshMagick.exe, and OgreMain.dll are all in that directory.
- Modify the paths in the Mesh-scripts to point to whatever directory you have the OGRE tools stored in.
- Copy the scripts into the directory of the model you want to edit.
- Run the scripts from within the model directory.
Included Scripts:
- MESH2ROTATE rebuilds all MESH and SKELETON files, then rotates all skeletons within its directory (and sub-directories) to 90 degrees counterclockwise. It was created to help fix bad rotations in animations exported via "PinkVertex".
- MESH2XML converts all Mesh and Skeleton files within its directory (and sub-directories) into Mesh.xml and Skeleton.xml files, then deletes the original Mesh and Skeleton files after conversion.
- XML2MESH converts all Mesh.xml and Skeleton.xml files within its directory (and sub-directories) back into Mesh and Skeleton files, then deletes all Mesh.xml and Skeleton.xml files in the directory after conversion.
- MESH2CLEAN uses the optimize function of OgreMeshMagick on all Mesh and Skeleton files within its directory (and sub-directories). See the MeshMagick page (https://wiki.ogre3d.org/MeshMagick) for more details.
- Simply combines 3 other scripts in this list (MESH2XML, XML2MESH, and MESH2CLEAN, respectively) to automatically decompile, recompile, then optimize all Mesh and Skeleton files within its directory. I developed this script as a more robust alternative to OgreMeshUpgrader. (By decompiling and then recompiling the models using tools whose OGRE version matches Torchlight's, I can ensure the meshes are not way out of date.)
- MESH2SCALE scales all meshes and skeletons within its directory (and sub-directories) to 2.0 times their original size. It was created as a proof-of-concept script demonstrating how one can use this scripting method to automate other MeshMagick commands.
- MESH2UPGRADE runs "OgreMeshUpgrader" on all Mesh and Skeleton files within its directory (and sub-directories). It throws an error at any Skeleton files, but does not seem to damage them.
- MESH2UPGRADE_V8 is a modified version of "MESH2UPGRADE", which uses the version-targeting feature from OGRE version 1.8+, for downgrading models from later OGRE versions (back to the version used by Torchlight 2).
Notes:
- All scripts make use of the "FOR /R" command to ensure all relevant files are recursively converted.
- XML2MESH, MESH2REBUILD, and MESH2UPGRADE use the "-e" (disable generation of Edge Lists) option when converting XML files to Mesh and Skeleton files, which reduces file-sizes dramatically (compared to OgreXMLConverter defaults). The in-game behavior of the resulting models does not seem to be impacted.
- The MESH2CLEAN and MESH2SCALE scripts can be easily adapted to perform other operations using MeshMagick. See the MeshMagick wiki page (https://wiki.ogre3d.org/MeshMagick) or the "Open Dungeons" OgreMeshMagick guide (https://github.com/OpenDungeons/OpenDungeons/wiki/Adding-a-model-in-the-game) for other examples on what you can do using it.
-
This is fantastic @Lord Nyriox ! Thanks for sharing your tools and work!
-
This is fantastic @Lord Nyriox ! Thanks for sharing your tools and work!
I figured that, given the almost complete lack of automation tools in Torchlight modding, anything to make mod-development easier can only improve the variety and quality of mods out there.
Speaking of which, do you think anyone would be interested in a "Mesh optimization" mod (in which all vanilla Model files are rebuilt with these)?
Given how much smoother gameplay gets with just the used player model optimized like this, what benefit could having every Model in the game optimized as well? ;>
-
@Lord Nyriox If any tool helps to cut down the time required to build mods and fix or avoid buggy writing then I am all in favor of it.
-
Updated the script package. Now includes a script for OgreMeshUpgrader as well.
I removed the Tangent-generation script, since it is currently useless for Torchlight modding.
You can find the latest version in the OP.
-
Can you include a readme in the zip explaining how these tools work in detail along with installation instructions?
-
Can you include a readme in the zip explaining how these tools work in detail along with installation instructions?
In retrospect, my description of each script's functionality does seem a bit dense.
These scripts are the product of extensive research on the OGRE model format, so a proper description of their behavior would probably wind up more technical than readable.
I will see about adding comments (and a "readme" file) to the script package.
-
Hi @Lord Nyriox . I made a readme for myself, from the info in the OP. Sharing it with you here (attached) in case you can use it ;)
-
Thanks for these scripts @Lord Nyriox. They saved me a ton of time right now. :)
-
Thanks for these scripts @Lord Nyriox. They saved me a ton of time right now.
That is great to hear, @Kva3imoda!
I may one day come back and clean my scripts up (i.e. add proper variables and better documentation). But I am glad that even in its incomplete state, my TL2 toolchain has proven useful for you.
P.S. For now, I will be locking all my forum topics while I am away.
Thank you so very much for all your support!