News: Go to the front page portal to create a Torchmodders account | Visit the wiki!
June 20, 2019, 03:08:22 PM
collapse

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

Offline Lord Nyriox

  • Moderator
  • Rare
  • *
  • Posts: 161
  • Country: 00
    • status bored
    • View Profile
    • Github Profile
  • Mood: mood evil
[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: 2666
  • 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: 161
  • Country: 00
    • status bored
    • View Profile
    • Github Profile
  • Mood: mood evil
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: 227
  • 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 5 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: 161
  • Country: 00
    • status bored
    • View Profile
    • Github Profile
  • Mood: mood evil
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: 161
  • Country: 00
    • status bored
    • View Profile
    • Github Profile
  • Mood: mood evil
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: 2
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Calendar

June 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

No calendar events were found.

* Recent Topics

[Stats], [Effects] & [Charges] by Rhythmier
[Today at 06:01:03 AM]


Lightbringer Mod (Paladin) by Rhythmier
[Today at 05:04:55 AM]


Need Help: a problem in GUTS by Sch123
[June 19, 2019, 11:41:00 PM]


A new beginning by Phanjam
[June 19, 2019, 02:04:50 PM]


New props & ideas for "The Dark Palace" by Phanjam
[June 18, 2019, 02:22:33 AM]


Hosting for 2019 by Wolven
[June 17, 2019, 08:50:11 PM]


Darkened TL2 UI (Re-texture Mod) by Rhythmier
[June 12, 2019, 08:27:13 AM]


FEP+ by Sch123
[June 11, 2019, 10:42:57 PM]


Variant Classes Bug Reports by Viz
[June 11, 2019, 01:18:21 PM]


Charge Domination % by Phanjam
[June 08, 2019, 02:30:49 PM]


Triggerable Weapons by Phanjam
[June 04, 2019, 12:25:05 PM]


FEP+ April 2019 Update by steffire3
[June 02, 2019, 07:40:37 AM]


Destroyer Rebalance by Phanjam
[May 25, 2019, 02:28:58 AM]


Skills Expansion: Bugs Report & Ideas by Sch123
[May 16, 2019, 10:54:27 AM]


[Help Request] Putting Custom Dungeons Into Vanilla Zones by Phanjam
[May 09, 2019, 02:19:19 AM]

* Popular Topics