Home Technical Talk

Maxscript: working with skinning

Mrfred
polycounter lvl 4
Offline / Send Message
Mrfred polycounter lvl 4
Hey, i'm trying to write a custom .env file using xml that could be able to store more information than the .env file
so far everything works, I managed to save the skin into an xml and load it back

However i'm not really happy with the loading part pipeline. In order to get the weights loaded correctly I have to:

(pipeline for a single vertex)
Get all the bone ID currently used
Turn off normalize
Sets all weights to zero on all the bone id previously gathered
load the weight data from the xml
turn on normalize

if I only load the weight data using setweights or replaceWeights i get skinning error ( the weights doesn't get applied correctly)

is there a way to force the skin modifiers to take new weights without having to flush everything out of every vertex ?

Replies

  • monster
    Offline / Send Message
    monster polycounter
    SkinOps.ReplaceVertexWeights should do what you want. No need to collect current influence, normalize, or set to zero.

    https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&ved=0CDwQFjAB&url=http%3A%2F%2Fdocs.autodesk.com%2F3DSMAX%2F15%2FENU%2FMAXScript-Help%2Ffiles%2FGUID-0820AA26-920F-434D-A6BC-E8B6B57F54AC.htm&ei=pYXgUZuOLonxygHtvYG4Ag&usg=AFQjCNEDSPMAVuqsig3eSjazYxF5xw5_7w&sig2=XCMD-qjXatahTOzCck6K8g
    Sets the influence of the specified bone(s) to the specified vertex.
    Any influence weights for the bone(s) that are not specified are erased.

    Is there an script crash? Can you post a code snippet?
  • Mrfred
    Offline / Send Message
    Mrfred polycounter lvl 4
    is the part that load and assign the vertex weithging
    (

    local VertexId = execute (enum.current.Attributes.Item[0].Value)
    local BoneID = enum.current.Attributes.Item[1].Value
    local Vertex_Weights =execute (enum.current.Attributes.Item[2].Value)
    -- format " VertexID:% BoneID:% VertexWeight: %\n" VertexId BoneID Vertex_Weights
    local boneArray = execute BoneID
    /* set the vertex weights to 0 with NOrmalize unchecked ( kinda resets the vertices weights array) */
    skinOps.unNormalizeVertex skinOjb VertexId true
    for o = 1 to skinOps.getVertexWeightCount skinOjb VertexId do (
    local singleboneID = (skinOps.GetVertexWeightBoneID skinOjb vertexID o)
    skinOps.SetVertexWeights skinOjb VertexId singleboneID 0
    )
    skinOps.SetVertexWeights skinOjb VertexId BoneArray Vertex_Weights
    skinOps.unNormalizeVertex skinOjb VertexId false
    )

    I already tried skinops.ReplaceVertexWeights on a specific vertex and didnt work, I had to set the current influence to zero and mess with normalize.

    What I tried to do I assigned some legs verts to the head bone to max influence ( was using a character for testing) but with setVertexWeights or replaceVertexWeight I would still get something like 0.5 influence on the head

    There's no crash, no error I get an OK but the weight isnt right
    At first I thought it was an error from the xml, but doing it manually from the data saved from the xml gave me the right results.

    I'm using max2013
  • monster
    Offline / Send Message
    monster polycounter
    I don't know man. ReplaceVertexWeights works for me. In the screenshot below everything was assigned to boneID 1, and after I run the script they are assigned to 2 and 3. I don't even have to normalize, because the results are normalized when they are applied.

    skinResults.png
  • Mrfred
    Offline / Send Message
    Mrfred polycounter lvl 4
    Weird, ill redo some test
  • Mrfred
    Offline / Send Message
    Mrfred polycounter lvl 4
    wooaahh ok, I commented all the "unecessary stuff" meaning I only had the setvertexweight line and as I predicted it didnt work correctly however the replacevertexweight worked fine. I'm damn sure I tested this command tho yesterday without any probing results.

    strange, I guess I was either too tired or I fucked up somewhere anyhow it's working perfectly many thanks ;)

    btw I simply want to confirm what I saw about an other issue. THere's no real vertex with the 0 ID in the skinning array which means that the number we get from the weight table aren't exact you have to do the weightTable given vertex ID + 1 to compensate for ID#0
    Thanks autodesk for making things so intuitive.
Sign In or Register to comment.