Surface Utilities.js

Surface Utilities.js

Here's a new tool script based on my old Global Iterator, but vastly improved thanks to this thread:

http://www.cheetah3d.com/forum/showthread.php?p=57839#post57839

The iterator framework now provides simple support for iterating through hierarchies and the entire scene, but defaults to acting on the selected object (there's no scripting support for multiple selection yet) and its children.

I've added new normal utilities for:
a) flipping all normals
b) "unifying" normals (which should make all normals in a continuous mesh consistent).
c) quickly "correcting" normals to face outwards from the object's origin (which should work nicely for simple, convex objects.
 

Attachments

  • Screen shot 2011-03-22 at 10.35.35 PM.png
    Screen shot 2011-03-22 at 10.35.35 PM.png
    26.9 KB · Views: 1,310
  • Surface Utilities.js.zip
    2.8 KB · Views: 718
Last edited:
I should note that the unify normals command can be quite slow, so don't panic if it seems to lock up (there's no way for a script to show a progress bar in c3d).

It will be faster at dealing with a bunch of small meshes than one big mesh because it will execute in O( M x N^2 ) where M is the number of meshes and N is the number of polygons in them.

The way I'd test it was to create a default Torus which has a pretty high polycount, and then use the different options on it (face outwards messes up a torus). Unify would run quite slowly.

There's an obvious way to speed up unify by a factor of 2 assuming the surface is "well formed" (in this case, if you assume that once you've found a polygon that shares an edge you can stop looking, and hence look at roughly half as many edges), but I left it out because some surfaces may not be well-formed.
 
Updated the script to fix bugs and attempt to improve performance of the Unify operation. Added a randomize function to facilitate testing.

Made a further fix that would cause errors in mesh strips.
 
Last edited:
Back
Top