Notifications
Clear all
[Closed] Calling C++ function inside C#
Page 3 / 3
Prev
Jan 22, 2022 3:44 pm
This is the right method to get the biped interface to call SetBipedTM:
public IIBipMaster12 GetIBipMasterInterface12(IINode node)
{
var ptr = ((INativeObject)node.TMController.GetInterface((InterfaceID)0x9167)).NativePointer;
return (IIBipMaster12)Autodesk.Max.Wrappers.CustomMarshalerIBipMaster12.GetInstance(string.Empty).MarshalNativeToManaged(ptr);
}
and we can check to see if the object is biped:
public static bool IsBipedNode(IINode node)
{
IControl c = node.TMController;
if (c == null) return false;
if (c.ClassID.PartA == 0x9154) return true;
if (c.ClassID.PartA == 0x9156) return true;
if (c.ClassID.PartA == 0x3011) return true;
return false;
}
Then we can set transform like this:
private void Part_Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (canChange == true)
{
int time = coreInterface.Time;
float val = Convert.ToSingle(e.NewValue / 100d);
globalInterface.DisableRefMsgs();
for (int i = 0; i < sourceNodes.Count; i++)
{
IMatrix3 blendTM = BlendMatrix(sourceTMs[i], targetTMs[i], val);
if (IsBipedNode(sourceNodes[i]))
{
IIBipMaster12 iBipMaster12 = GetIBipMasterInterface12(sourceNodes[i]);
int id = 0;
int link = 0;
iBipMaster12.GetIdLink(sourceNodes[i], ref id, ref link);
iBipMaster12.StartSettingBipedKeys();
iBipMaster12.SetBipedTM(time, blendTM, id, link);
iBipMaster12.StopSettingBipedKeys();
}
else
{
sourceNodes[i].SetNodeTM(time, BlendMatrix(sourceTMs[i], targetTMs[i], val));
}
}
globalInterface.EnableRefMsgs();
for (int i = 0; i < sourceNodes.Count; i++)
{
sourceNodes[i].InvalidateTM();
}
coreInterface.RedrawViews(time, RedrawFlags.Normal, null);
}
}
Jan 22, 2022 3:44 pm
Because we start from the root node in the scene, it works on the hierarchy. (if we use the SetBipedTM for biped parts).
Jan 22, 2022 3:44 pm
oops, it was my mistake, StartSettingBipedKeys and StopSettingBipedKeys should be outside the loop. Now it’s work on the latest scene as well.
Page 3 / 3
Prev