Hello everyone,
I'm trying to create a little Maxscript for splitting a character into parts for a game but have some trouble with the resulting normal borders and hope anyone here can help me. I've already searched the forum but couldn't find what I'm looking for.
What I'm doing right now:
- I create 3 copys of my character and delete all unwanted faces by material id. This way I get 3 new Objects (in the end this will be more but I'm just testing on a smaller object) This works and I'm doing it this way because I want to keep the skinning of the original object
- To fix the normal borders I'm trying to copy the normal of my original object onto the normal of my new one at the same position. This doesn't work because they always seem to be the same in code although they are different in max
Here's my script so far:
-- variables and declarations --------------------------------------------------
temp = copy $
counter = 1
partsToCreate = #("top", "middle", "bottom")
-- delete all modifiers of temp ------------------------------------------------
for i = 1 to temp.modifiers.count do deleteModifier temp 1
-- create parts ----------------------------------------------------------------
for partName in partsToCreate do (
--create
part = copy $ name:partName
--crop by Material ID
facesToDelete = #()
for i = 1 to part.numfaces do (
if polyop.getFaceMatID temp i != counter do append facesToDelete i
)
counter += 1
polyop.deleteFaces part facesToDelete
--adjust normals
-- -- preparation whole
addmodifier $ (Edit_Normals())
whole_NormMod = $.modifiers[#Edit_Normals].EditNormalsMod
whole_VertIDtoPos = #()
for i = 1 to whole_NormMod.GetNumVertices() do (
whole_VertIDtoPos[i] = (whole_NormMod.GetVertex i) * $.objecttransform
)
-- -- preparation part
addmodifier part (Edit_Normals())
part_NormMod = $.modifiers[#Edit_Normals].EditNormalsMod
part_VertIDtoPos = #()
for i = 1 to part_NormMod.GetNumVertices() do (
part_VertIDtoPos[i] = (part_NormMod.GetVertex i) * part.objecttransform
)
-- -- compare and get normal
for i=1 to part_NormMod.GetNumVertices() do (
for j=1 to whole_NormMod.GetNumVertices() do (
if length (whole_VertIDtoPos[j] - part_VertIDtoPos[i]) == 0.0 do (
whole_Normal = whole_NormMod.getNormal j
part_Normal = part_NormMod.getNormal i
format " Body normal: % \n Part normal: % \n" whole_Normal part_Normal
part_NormMod.Setnormal i whole_Normal
format " Body normal: % \n Part normal: % \n\n" whole_Normal part_Normal
)
)
)
-- -- cleanup
deletemodifier $ 1
)
-- cleanup ----------------------------------------------------------------------
delete temp
By Jantaria · 2013-09-08
Budi G · 2013-10-05
draging · 2013-09-10
barigazy · 2013-09-08