ResetMesh script for 3ds Max - No more re-importing! UPDATED
Feb 18, 2020 0:43:38 GMT 10
EvilLord, JTeghius Kittius, and 8 more like this
Post by alphaz on Feb 18, 2020 0:43:38 GMT 10
Download Here (v0.4)
Old (v0.3)
Old (v0.2)
Old (v0.1)
*Only for 3ds Max 2013-2016 thanks to Autodesk deprecating and removing the gPoly class. I will look into alternative ways to do this.
ResetMesh is a small, time-saving script that prepares an edited mesh for proper export back into Resident Evil 2 without the need to first export and re-import the mesh as .3DS, .FBX or .OBJ inside Max.
You may have noticed that after you delete verts, weld verts together, or convert your mesh to and from an Editable Poly, your mesh will either fail to export or will export to the game like this:
This is caused by having UV maps that are mismatched to your geometry. Most of the time, you can only fix this problem by re-importing the mesh using one of the above file formats, but this script will clean and reset the mesh to work for RE2 all at the press of a button inside 3ds Max. It also has options to automatically perform the cleaning actions only on a clone of your selected mesh, and to automatically weld all duplicate / overlapping vertices.
Here is an example of it cleaning a mesh that has had clusters of vertices along the UV seams either deleted or welded together:
And here is an example of ResetMesh permanently cleaning a copy of a mesh that had previously been splintered / had its verts separated, which is caused by getting re-imported as a .3DS file:
The scrambling / shrinking problem is caused by having Dead Verts and / or a mismatched amount of Num Verts when looking down the line in Tools -> Channel Info. ResetMesh automatically welds together overlapping UV verts to a very fine threshold, while simultaneously increasing the number of geometric verts to match up to the number of UV verts whenever the amount of UV verts cannot be decreased further. With "Weld Overlapping Vertices" checked, it welds together all overlapping geometric verts, then welds together UV verts, then increases the amount of geometric verts to match the UV verts, and it does this for two cycles to correct any misplaced overlapping verts that may appear in the middle of your mesh (like when you re-import a mesh once as Noesis FBX).
UV channel 2 is handled just like UV channel 1 and will remain intact and matched-up to your mesh even if it is different from UV channel 1.
*Tested on 3ds Max 2014 only. It uses the now-deprecated "Deformable gPoly" form, so there may be issues with newer versions of Max.
Update v0.2:
I continued working on this a bit after I uploaded it and added a couple new features. Now the script has the ability to automatically transfer the skin / rigging of the original mesh to the cloned + reset mesh if the original mesh has a skin. If you want to use this option and you are making edits to the geometry of the original mesh, I would suggest going into the original mesh's Skin modifier first and clicking Edit Envelopes -> Select by Vertices -> Ctrl + A to select all -> Uncheck "Normalize", to prevent your deleted or welded vertices from changing the skin. I tested this by deleting 1/2 my mesh's body split vertically down the middle and I got no rigging issues on the side that remained, after using ResetMesh to duplicate + skin-wrap to it.
Also, there is a new checkbox for automatically averaging normals on the reset mesh, as well as a checkbox for removing materials / textures from it.
Update v0.3:
An undetected problem with MaxScript's non-handling of all Unwrap UVW actions on UV Channel 2 made v0.2 ineffective at both fixing overlapping vertices and at preserving UV channel 2, but these functionalities are both fixed as of v0.3. Two new options are included: one for specifying whether or not you want to preserve UV Channel 2 or just quickly overwrite it with a copy of UV channel 1 (for if both your UV channels are the same anyway), and another for manually specifying the number of times that overlapping vertices are welded (Max Welding Iterations). With this option, you can specify the maximum number of times the cycle of welding together all the overlapping verts -> welding together all the extra UV verts that were attached to those overlapping verts -> turning into a gPoly object -> converting back to mesh is repeated. The first cycle / iteration of welding cleans up 99.9% of problems, and then the second one cleans up the remaining 0.1%. The script automatically stops welding if it detects no decrease in the number of UV verts for two cycles in a row, so it usually will not weld and reset more than 3 times in a row anyway.
Tip: If you set the Max Welding Iterations to a negative number, ResetMesh will skip the step to convert the mesh to a Deformable gPoly (which is the part that duplicates verts in your geometry to match up to your UV verts). Use this if you still want to use the welding and UV welding features of the script, but don't want to convert to gPoly (either because your Max doesn't have it or because it's not fixing your jagged UVs).
Old (v0.3)
Old (v0.2)
Old (v0.1)
*Only for 3ds Max 2013-2016 thanks to Autodesk deprecating and removing the gPoly class. I will look into alternative ways to do this.
ResetMesh is a small, time-saving script that prepares an edited mesh for proper export back into Resident Evil 2 without the need to first export and re-import the mesh as .3DS, .FBX or .OBJ inside Max.
You may have noticed that after you delete verts, weld verts together, or convert your mesh to and from an Editable Poly, your mesh will either fail to export or will export to the game like this:
{(More Examples)}
This is caused by having UV maps that are mismatched to your geometry. Most of the time, you can only fix this problem by re-importing the mesh using one of the above file formats, but this script will clean and reset the mesh to work for RE2 all at the press of a button inside 3ds Max. It also has options to automatically perform the cleaning actions only on a clone of your selected mesh, and to automatically weld all duplicate / overlapping vertices.
Here is an example of it cleaning a mesh that has had clusters of vertices along the UV seams either deleted or welded together:
And here is an example of ResetMesh permanently cleaning a copy of a mesh that had previously been splintered / had its verts separated, which is caused by getting re-imported as a .3DS file:
The scrambling / shrinking problem is caused by having Dead Verts and / or a mismatched amount of Num Verts when looking down the line in Tools -> Channel Info. ResetMesh automatically welds together overlapping UV verts to a very fine threshold, while simultaneously increasing the number of geometric verts to match up to the number of UV verts whenever the amount of UV verts cannot be decreased further. With "Weld Overlapping Vertices" checked, it welds together all overlapping geometric verts, then welds together UV verts, then increases the amount of geometric verts to match the UV verts, and it does this for two cycles to correct any misplaced overlapping verts that may appear in the middle of your mesh (like when you re-import a mesh once as Noesis FBX).
UV channel 2 is handled just like UV channel 1 and will remain intact and matched-up to your mesh even if it is different from UV channel 1.
*Tested on 3ds Max 2014 only. It uses the now-deprecated "Deformable gPoly" form, so there may be issues with newer versions of Max.
Update v0.2:
I continued working on this a bit after I uploaded it and added a couple new features. Now the script has the ability to automatically transfer the skin / rigging of the original mesh to the cloned + reset mesh if the original mesh has a skin. If you want to use this option and you are making edits to the geometry of the original mesh, I would suggest going into the original mesh's Skin modifier first and clicking Edit Envelopes -> Select by Vertices -> Ctrl + A to select all -> Uncheck "Normalize", to prevent your deleted or welded vertices from changing the skin. I tested this by deleting 1/2 my mesh's body split vertically down the middle and I got no rigging issues on the side that remained, after using ResetMesh to duplicate + skin-wrap to it.
Also, there is a new checkbox for automatically averaging normals on the reset mesh, as well as a checkbox for removing materials / textures from it.
Update v0.3:
An undetected problem with MaxScript's non-handling of all Unwrap UVW actions on UV Channel 2 made v0.2 ineffective at both fixing overlapping vertices and at preserving UV channel 2, but these functionalities are both fixed as of v0.3. Two new options are included: one for specifying whether or not you want to preserve UV Channel 2 or just quickly overwrite it with a copy of UV channel 1 (for if both your UV channels are the same anyway), and another for manually specifying the number of times that overlapping vertices are welded (Max Welding Iterations). With this option, you can specify the maximum number of times the cycle of welding together all the overlapping verts -> welding together all the extra UV verts that were attached to those overlapping verts -> turning into a gPoly object -> converting back to mesh is repeated. The first cycle / iteration of welding cleans up 99.9% of problems, and then the second one cleans up the remaining 0.1%. The script automatically stops welding if it detects no decrease in the number of UV verts for two cycles in a row, so it usually will not weld and reset more than 3 times in a row anyway.
Tip: If you set the Max Welding Iterations to a negative number, ResetMesh will skip the step to convert the mesh to a Deformable gPoly (which is the part that duplicates verts in your geometry to match up to your UV verts). Use this if you still want to use the welding and UV welding features of the script, but don't want to convert to gPoly (either because your Max doesn't have it or because it's not fixing your jagged UVs).