News: Go to the front page portal to create a Torchmodders account | Visit the wiki!
January 16, 2019, 10:08:56 PM
collapse

Author Topic: [SCRIPT] Automatic Mesh Rebuilding  (Read 1724 times)

Offline Lord Nyriox

  • Moderator
  • Rare
  • *
  • Posts: 153
  • Country: 00
    • status away
    • View Profile
    • Github Profile
  • Mood: mood lamp
[SCRIPT] Automatic Mesh Rebuilding
« on: May 29, 2018, 10:22:05 PM »
Windows Scripts:
Automatic Mesh Rebuilding

As I mentioned during the discussion 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: 
  • 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 for more details.
  • MESH2REBUILD simply combines the other 3 scripts in this list (in the order I have listed them) 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 within its directory (and sub-directories) to 8/10 of 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 now 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 models does not seem to be impacted. 
  • MESH2SCALE does not scale any Skeleton files (it only runs the "transform" command on the Mesh files).  Animation functionality does not appear to be impacted, when left alone like this.  (Attempting to scale Skeleton files directly, on the other hand, causes animations to look very distorted.) 
  • The MESH2CLEAN and MESH2SCALE scripts can be easily adapted to perform other operations using MeshMagick. 
    See the MeshMagick wiki page or the "Open Dungeons" OgreMeshMagick guide for other examples on what you can do using it. 
« Last Edit: December 26, 2018, 03:42:23 PM by Lord Nyriox »

Offline Phanjam

  • Operator
  • Legendary
  • *
  • Posts: 2580
  • Country: ph
    • status ready
    • View Profile
  • Mood: mood angel
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #1 on: May 30, 2018, 09:42:37 AM »
This is fantastic @Lord Nyriox ! Thanks for sharing your tools and work!



Offline Lord Nyriox

  • Moderator
  • Rare
  • *
  • Posts: 153
  • Country: 00
    • status away
    • View Profile
    • Github Profile
  • Mood: mood lamp
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #2 on: May 30, 2018, 10:21:42 PM »
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?  ;> 

Offline steffire3

  • Mod_Seeker, Balance_Researcher, Person_Listener.
  • Rare
  • *
  • Posts: 210
  • Country: us
  • I am more active on the Steam Workshop Discussions
    • status busy
    • View Profile
  • Mood: mood smiley
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #3 on: May 30, 2018, 10:37:48 PM »
@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.
At this point after playing Torchlight 2 for 4 years original and modded... ignorant of mods and now wise with compatibility... the one thing I value the most-

-is being able to have "support" from the author of any mod.

I think the only advice I can give is that you don't burn yourself out. ^_^

Offline Lord Nyriox

  • Moderator
  • Rare
  • *
  • Posts: 153
  • Country: 00
    • status away
    • View Profile
    • Github Profile
  • Mood: mood lamp
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #4 on: June 12, 2018, 06:08:25 PM »
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. 

Offline DragonDawn

  • Common
  • *
  • Posts: 16
  • Country: us
    • status mod
    • View Profile
  • Mood: mood smiley
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #5 on: December 17, 2018, 07:59:03 PM »
Can you include a readme in the zip explaining how these tools work in detail along with installation instructions?

Offline Lord Nyriox

  • Moderator
  • Rare
  • *
  • Posts: 153
  • Country: 00
    • status away
    • View Profile
    • Github Profile
  • Mood: mood lamp
Re: [SCRIPT] Automatic Mesh and Skeleton Rebuilding
« Reply #6 on: December 26, 2018, 03:41:03 PM »
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.

Tags:
 

* Quick Search


* Member Information

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Mod Boards Activity

* Who's Online

  • Dot Guests: 14
  • Dot Hidden: 0
  • Dot Users: 1
  • Dot Users Online:

* Calendar

January 2019
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 [16] 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

No calendar events were found.

* Recent Topics

Pet Variants Mod by Korzeam
[Today at 10:05:43 PM]


Deathknight class by Korzeam
[Today at 07:30:45 PM]


Lord Nyriox's Blog by Lord Nyriox
[Today at 07:18:27 AM]


[TL2] Ultimate Respec Lite by Phanjam
[January 09, 2019, 01:27:56 PM]


Playable Zealot by Lord Nyriox
[January 08, 2019, 06:55:49 PM]


Medea Pet to Class by DragonDawn
[January 08, 2019, 12:37:05 AM]


Fate Items by Lord Nyriox
[January 05, 2019, 10:55:30 AM]


Notepad++ Custom Language File (Syntax Highlight) by Lord Nyriox
[December 29, 2018, 09:05:41 PM]


[WIP] Lazarus Pack by Lord Nyriox
[December 29, 2018, 06:41:39 AM]


Floaty Torchlight Cube by Lord Nyriox
[December 29, 2018, 06:21:00 AM]


[SCRIPT] Automatic Mesh Rebuilding by Lord Nyriox
[December 26, 2018, 03:41:03 PM]


[CLASS] Emberdrake by Lord Nyriox
[December 22, 2018, 07:00:55 PM]


[CONCEPT] "Candied Ember" Mod by Lord Nyriox
[December 13, 2018, 05:26:38 PM]


TL1CP Bug Report by Sch123
[December 13, 2018, 04:35:48 AM]


Variant Classes Mod Information by Sch123
[December 12, 2018, 05:37:11 AM]

* Popular Topics