at the moment we have a character system where customisable parts are part of the same mesh but are separate elements. so the arms detach from the torso for example.
to hide the seem where this is happening I’ve been using the edit normals modifier to make the verts on the join point in the saamedirection (average selected).
What I’m about to script is a tool that will loop through the verts in a mesh and average the ones at the join.
I’ve seen some similar scripts but none of them seem to do this functionality.
So I thought I’d ask:
A) if people think this would be possible (it does look like you could do it from the max script help.)
B) Does any one have any advice or experience they’d like to share in how you’d go about doing this. (especially methods and functions as I’m new to max script)
Sounds like this should be very much doable, but with some headaches. Getting proper object space vertex normals from MaxScript is surprisingly non-trivial (without querying them via the Edit Normals modifier which slows things down a lot).
Have fun matching the “which vertices are the same” without things getting really slow on higher density meshes. Cache the vertex positions and don’t do a getVert for each vertex in every iteration. Optimize by only testing the elements where their bounding boxes overlap or with some more complex methods. Expect to have more than two vertices being the same at some locations. Smoothing groups (thus a vertex having more than one normal) will give you headache.
Sounds like a fairly complex thing if you’re new to MaxScript, but a wonderful learning experience (as if finding out why some things are hard to do in MaxScript…
That being said, this sounds like a fun weekend thing to write.
Hi!
you could reduce the problem using this kind of passes (don’t know if appliable to your models):
-check for the border (detached edge loop in editPoly) for every submesh and store them as vertex indices
-find the right corrispondence between coupled borders in object sub-meshes
-for every coupled borders, find a common vertex
-find the average normal from the two vertices
in this way the real problems become:
1)find the coupling between the vertex borders
2)for every border couple find the coupled vertices
the 1) problem could be resolved (with some luck ) checking the average position of all the border vertices and test the distances
the 2) problem could be easly resolved checking the distances between a vertex of a border with all the other vertices in the second border (when you find a couple, delete them from the arrays)
this is what I think in a 1 minute if I find a better approach I’ll let you know.
Looking into the edit normals modifier it has a threasold hold setting which I think might save me some time.
all I need to do from what I can see is grab all the vertex normals in an array some how then apply the average with the lowest threshold possible this would work for what we want.
I’ve only just started looking into the syntax for all this but its not immediately obvious how to index all the normals so I can use the average command on the entire Array.
I’m not sure about your solution…try to create a box, convert to editPoly, add the EditNormal modifiers, select all the normal and do the average…I think it would not work for your needs…or maybe I’ve not understood you
the 1…24 in the brackets about only get put in there like that when you manually select the normals, I need to find the command to select them with max script instead.
Doing that way does seem to work for what I want so that should cover it for now, I will as I get better at max script update this to work as I originally intended by detecting the the open edges as you and Sami have both suggested.