<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get morph target in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7877778#M11926</link>
    <description>&lt;P&gt;No &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Mar 2018 08:22:57 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-03-23T08:22:57Z</dc:date>
    <item>
      <title>How to get morph target weights in c# ?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7425625#M11922</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to retreive the weight of each morph target listed inside the 'morpher' modifier &lt;STRONG&gt;when no animation is defined&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently i'm only able to get the animation values of such attribute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A screenshot of what i want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MaxMorphTargetWeight.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/407837i9EA41F1B4B4661E4/image-size/large?v=v2&amp;amp;px=999" role="button" title="MaxMorphTargetWeight.jpg" alt="MaxMorphTargetWeight.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code i have &lt;SPAN&gt;using 3ds Max 2017&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IIGameNode meshNode = ... // initialized previously&lt;BR /&gt;&lt;BR /&gt;// Retreive modifiers with morpher flag
List&amp;lt;IIGameModifier&amp;gt; modifiers = new List&amp;lt;IIGameModifier&amp;gt;();
for (int i = 0; i &amp;lt; meshNode.IGameObject.NumModifiers; i++)
{
    IIGameModifier modifier = meshNode.IGameObject.GetIGameModifier(i);
    if (modifier.ModifierType == Autodesk.Max.IGameModifier.ModType.Morpher)
    {
        modifiers.Add(modifier);
    }
}

// Cast modifiers to morphers
List&amp;lt;IIGameMorpher&amp;gt; morphers = new List&amp;lt;IIGameMorpher&amp;gt;();
modifiers.ForEach(modifier =&amp;gt;
{
    Assembly wrappersAssembly = Assembly.Load("Autodesk.Max.Wrappers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
    Type type = wrappersAssembly.GetType("Autodesk.Max.Wrappers.IGameMorpher");
    ConstructorInfo constructor = type.GetConstructors()[0];
    unsafe
    {
        void* voidPtr = modifier.GetNativeHandle().ToPointer();
        IIGameMorpher morpher = (IIGameMorpher)constructor.Invoke(new object[] { modifier.GetNativeHandle(), false });
        morphers.Add(morpher);
    }
});

// Retreive morph target weights
morphers.ForEach(morpher =&amp;gt;
{
    for (int i = 0; i &amp;lt; morpher.NumberOfMorphTargets; i++)
    {
        IIGameControl morphWeight = morpher.GetMorphWeight(i);

        // Retreive weight animation values
        ITab&amp;lt;IIGameKey&amp;gt; gameKeyTab = GlobalInterface.Instance.Tab.Create&amp;lt;IIGameKey&amp;gt;();
        morphWeight.GetQuickSampledKeys(gameKeyTab, IGameControlType.Float);
        for (int indexKey = 0; indexKey &amp;lt; gameKeyTab.Count; indexKey++)
        {
            IIGameKey gameKey = gameKeyTab[indexKey];

            // Animation value
            int time = gameKey.T;
            float weight = gameKey.SampleKey.Fval / 100.0f;
        }

        // TODO - HOW TO GET MORPH TARGET WEIGHT?
    }
});&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was expecting&amp;nbsp;IIGameMorpher.GetMorphWeight to return a float and have another method like&amp;nbsp;&lt;SPAN&gt;IIGameMorpher.&lt;/SPAN&gt;GetMorphWeightControl to get the animation control...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Noalak&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 15:01:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7425625#M11922</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-02T15:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to get morph target weights in c# ?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7435330#M11923</link>
      <description>&lt;P&gt;Hi Noalak,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I review that GetMorhWeight API in the Autodesk.Max.dll assembly (I am using ilspy to have a quick look). I can see that the API is returning another object of type IIGameControl. The signature is like this: IIGameControl &lt;SPAN style="color: #191970; font-weight: bold;"&gt;GetMorphWeight&lt;/SPAN&gt;(&lt;SPAN style="color: #ff0000; font-weight: bold;"&gt;int&lt;/SPAN&gt; index); This type holds a lot of data, and includes IsAnimated. I also checked the C++ SDK header, where there is some documentation. Here it says that the returned IGameControl object is used to get: "The actual value of the keys provides the weight value - this value can not be consider normalised." Going back to your code, I think you are using it correctly, but I agree it is not clear how to obtain the weight with no animation. I see in the IGameControl class there is also a GetConstraintWeight that returns float, would that be something?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that does not help, and if no one else has a strong knowledge of these APIs, it would be great if you provided a small scene with the setup, and a small sample C# program to make it easier for us to investigate deeper. (note the C# version is a simple wrapper of the C++ version, so behavior should be&lt;/P&gt;
&lt;P&gt;identical).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps,&lt;/P&gt;
&lt;P&gt;kevin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:02:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7435330#M11923</guid>
      <dc:creator>kevinvandecar</dc:creator>
      <dc:date>2017-10-05T14:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get morph target weights in c# ?</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7451829#M11924</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answer. Was busy lately couldn't reply sooner.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About your suggestion with&amp;nbsp;&lt;SPAN&gt;GetConstraintWeight,&amp;nbsp;&lt;/SPAN&gt;for me this method is not inside IGameControl class but&amp;nbsp;inside IIGameConstraint.&lt;/P&gt;&lt;P&gt;Such a object can be retreive through IGameControl.GetConstraint method.&lt;/P&gt;&lt;P&gt;However it requires a&amp;nbsp;IGameControlType as parameter and none of the available choice returns a non null value...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Retreive morph target weights
morphers.ForEach(morpher =&amp;gt;
{
    for (int i = 0; i &amp;lt; morpher.NumberOfMorphTargets; i++)
    {
        IIGameControl morphWeight = morpher.GetMorphWeight(i);

        // For each control type (float, vec3...)
        var controlTypes = Enum.GetValues(typeof(IGameControlType)).Cast&amp;lt;IGameControlType&amp;gt;();
        foreach (var controlType in controlTypes)
        {
            IIGameConstraint constraint = morphWeight.GetConstraint(controlType);
            if (constraint != null)
            {
                // Never reach here
                
                // float weight = constraint.GetConstraintWeight(0);
            }
        }
    }
});&lt;/PRE&gt;&lt;P&gt;Dunno what to do...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2017 15:44:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7451829#M11924</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-11T15:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get morph target</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7877576#M11925</link>
      <description>&lt;P&gt;I have exactly the same problem.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;morphWeight.GetConstraint (controlType)&amp;nbsp;always null&amp;nbsp;&lt;SPAN&gt;even with my try&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did you ever get it out?&lt;BR /&gt;Please write a short msg !&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Peter&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 07:08:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7877576#M11925</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-23T07:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get morph target</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7877778#M11926</link>
      <description>&lt;P&gt;No &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 08:22:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/how-to-get-morph-target-weights-in-c/m-p/7877778#M11926</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-23T08:22:57Z</dc:date>
    </item>
  </channel>
</rss>

