Unable to access Morpher keyframes via script?

Unable to access Morpher keyframes via script?

nickmaxxQS68F
Explorer Explorer
1,455 Views
2 Replies
Message 1 of 3

Unable to access Morpher keyframes via script?

nickmaxxQS68F
Explorer
Explorer

I have a scene where I am animating a mesh via morph target weights:
MorpherKeyframeSdk1.png

Currently I am unable to retrieve my animation keyframes via MaxScript:
MorpherKeyframeSdk2.png

Would anyone be able to help me figure out how to properly use Maxscript and the Max C# SDK to properly do this?

Attached is the scene file that I'm working off of:

0 Likes
Accepted solutions (2)
1,456 Views
2 Replies
Replies (2)
Message 2 of 3

Swordslayer
Advisor
Advisor
Accepted solution
Message 3 of 3

nickmaxxQS68F
Explorer
Explorer
Accepted solution

Thanks @Swordslayer for your response, but I currently struggle with how to conceptualize the Morpher implementation, and its associated channels and where these keyframes are actually stored.

If you have any experience with the 3dsMax C# (or C++) API, what would the equivalent to your code snippet:

$.morpher[1][1].keys



if $ represents our currently selected IIGameNode mesh and $.morpher is the IIGameMorpher applied to the mesh. Why do we need to index twice, and what do these indices correspond to?

Currently I do something along the lines of (I wish i had a template to to minimize my MaxAPI project for quick execution):

// Retreive modifiers with morpher flag
List<IIGameModifier> modifiers = new List<IIGameModifier>();
for (int i = 0; i < meshNode.IGameObject.NumModifiers; i++)
{
    var modifier = meshNode.IGameObject.GetIGameModifier(i);
    if (modifier.ModifierType == Autodesk.Max.IGameModifier.ModType.Morpher)
    {
        modifiers.Add(modifier);
    }
}

// Cast modifiers to morphers
List<IIGameMorpher> morphers = modifiers.ConvertAll(new Converter<IIGameModifier, IIGameMorpher>(modifier => modifier.AsGameMorpher()));

var hasMorphTarget = false;
morphers.ForEach(morpher =>
{
    if (morpher.NumberOfMorphTargets > 0)
    {
        hasMorphTarget = true;
    }
});

if (hasMorphTarget)
{
    morphers.ForEach(morpher =>
    {
        for (int i = 0; i < morpher.NumberOfMorphTargets; i++)
        {
            // Morph target
            var maxMorphTarget = morpher.GetMorphTarget(i);

            // Ensure target still exists (green color legend)
            if (maxMorphTarget != null)
            {
    
                var morphWeight = morpher.GetMorphWeight(i);
                ITab<IIGameKey> gameKeyTab = GlobalInterface.Instance.Tab.Create<IIGameKey>();
                // Here we don't get any keys from the API. :'(
                morphWeight.GetQuickSampledKeys(gameKeyTab, IGameControlType.Float);
// This also returns 0 when ran against my original scene
morphWeight.GetNumOfListSubControls(IGameControlType.Float); } } }); }

 

I assume that the first index of the MaxScript snippet is similar to morpher.GetMorphWeight(i), but I, I don't quite understand how to retrieve the sub controller that I assume corresponds to your second index, and what actual class structure applies to the hierarchy seen in the dopesheet in my first post. Yikes.

This seems like alot, but got any idea what I should be doing here?

 

0 Likes