I've attached the test scene. The code runs perfectly fine and does everything it needs to do. But the skin doesn't match. If i run the load skin weights through button operations doing the same thing as the code the skinning matches perfectly? Any help?
Thanks
tObj = $Box001
sObj = $Box002
fn fnFindSkinMod obj = (
if validModifier obj Skin do (
for m = 1 to obj.modifiers.count do (
if classof obj.modifiers[m] == skin then ( --// if the object has a valid skin modifier return the modifier number in the stack
return m
)
)
)
)
skinIDX = if fnFindSkinMod tObj != ok then (fnFindSkinMod tObj) else 0 --//Skin modifier index
if skinIDX >= 1 do (
boneArr = #()
numBones = skinOps.GetNumberBones tObj.modifiers[skinIDX] --//Number of bones in skin modifier
max modify mode
modPanel.setCurrentObject tObj.modifiers[skinIDX]
try (deleteFile (maxfilepath + "skinning.env"))catch()
skinOps.saveEnvelope tObj.modifiers[skinIDX] (maxfilepath + "skinning.env")
for b = 1 to numBones do (--//Add to an array the name of all the bones in the skin modifier
boneObject = skinOps.GetBoneName tObj.modifiers[skinIDX] b 1 --//0 = transform | 1 = object name
append boneArr boneObject
)
max create mode
)
fn fnLoadSkinning obj = (
addModifier obj (Skin ())
select obj
max modify mode
modPanel.setCurrentObject tObj.modifiers[skinIDX]
for b in boneArr do (
theBone = getNodeByName (b + "_002")
skinOps.addbone obj.modifiers[1] theBone 1
)
obj.modifiers[1].filter_vertices = on
skinOps.loadEnvelope obj.modifiers[#skin] (maxfilepath + "skinning.env")
)
fnLoadSkinning sObj
By JokerMartini · 2011-10-11
Anubis · 2011-10-11