Loading Skin?
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
Attachment | Size |
---|---|
testscene2010.max | 272 KB |
Comments
I ended up figuring it out. I
I ended up figuring it out. I cleaned up the code and also found out thanks to bobo that you have to do a completeSceneRedraw in order for the weights to load onto the object.
John
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
Hi John
I can't test your scene in my Max 2009, but what i see in the code probably w'd help a bit --
1. In "if skinIDX >= 1 do" context you have
boneArr
, so if it not defined at least at one level above, w'd be invisible for the last function.2. Also in that function (fnLoadSkinning) I see you used "addModifier" which add new modifier on top (index = 1) and at the same time you used
skinIDX
(acquired from previous object stack.my recent MAXScripts RSS (archive here)