Hello guys, i have been working on a tool for our animation team. they asked me to help them automate some task that have to be preformed for each character in our game.
The mesh Skin has multiple Ref.Frames, and the goal is to merge all the data to Ref.Frame 0. this is to properly export to our game engine.
here is the manual way of doing it which works 100%.
0. Set time line to frame 0
- select mesh
- select skin modifier
- open weigh-table
- copy all vertex values and paste them back into the same places (this is as i was explained forces the Manual Vertex Weighting, in case something was done using Envelopes, the Column M gets “X” marked for all.
- Right-click -Copy Skin Modifier,
- Collapse Skin Modifier
- Paste Previously copied Skin
- Skin-Advanced parameters - Set Ref.Frame to 0
- Toggle Always Deform on/off (to update the view port)
- DONE.- ready for export.
Don’t ask why these are the steps, i had been trying to find out but it was a little challenging, considering lots of people were involved in the process, and i have just joined the team.
What i wrote:
clearlistener()
sliderTime = 0f
theModel = $
vertArray = #()
vertWeightArray = #()
boneIdArray = #()
------------------------------------------------------------
--Create TMP model and append to TMP Layer
tmpModel = copy theModel
tmpModel.name = "tmp_" + theModel.name
tmpLayer = LayerManager.newLayer()
tmpLayer.setname "tmp_Layer"
tmpLayer.addnode tmpModel
----------------------------------------------------------
for vert = 1 to (skinOps.GetNumberVertices tmpModel.modifiers[#skin]) do
(
--format ("Vertex %
")vert
append vertArray vert
for bon = 1 to (skinOps.GetVertexWeightCount tmpModel.modifiers[#skin] vert) do
(
boneID = (skinOps.GetVertexWeightBoneID tmpModel.modifiers[#skin] vert bon)
append boneIdArray boneID
boneName = (skinOps.GetBoneName tmpModel.modifiers[#skin] boneID 0)
VertWeight = (skinOps.GetVertexWeight tmpModel.modifiers[#skin] vert bon)
append vertWeightArray VertWeight
--skinOps.SetVertexWeights theModel.modifiers[#skin] vert boneID VertWeight
format ("Vertex: % | boneID: % | Name: % | Weight: %
")vert boneID boneName VertWeight
)
format("
")
)
maxOps.CollapseNodeTo theModel theModel.modifiers.count on
addModifier theModel tmpModel.modifiers[#skin]
modPanel.setCurrentObject theModel.modifiers[#Skin]
subobjectlevel = 1
for vert=1 to vertArray.count do (
for bon = 1 to boneIdArray.count do (
skinOps.SetVertexWeights theModel.modifiers[#skin] vert boneIdArray[bon] vertWeightArray[bon]
)
)
theModel.modifiers[#skin].ref_frame = 0
theModel.modifiers[#skin].always_deform = False
theModel.modifiers[#skin].always_deform = True
subobjectlevel = 0
As the result - my new skin after application, doesn’t match to what the manual way is doing, however the steps are all the same, and i can’t seem to figure out what is the problem, if anyone has a tip, i would really appreciate this, thanks!