Notifications
Clear all

[Closed] Calling C++ function inside C#

 MZ1

I will check it out @Serejah, Thanks!

 MZ1

I saw your code, Yes, it will remove unnecessary set transform. thanks!
Another point is the DisableRefMsgs also impressively will increase the performance.
But the loading issue is still exist with the biped. Please find attached .fig file and load on your biped to see what problem I’m talking about.(rotate the clavicle bone)TestFigure.fig (14.7 KB)

Yes, bones didn’t change their positions when I move the slider. Maybe you need to use .SetBipedTM from IBipMaster, just guessing.

 MZ1

Maybe you didn’t exit the figure mode?
For me the problem is when I rotate the clavicle for example, then entire arm will move back and forth randomly during blending,

3 Replies
(@serejah)
Joined: 10 months ago

Posts: 0

Oh, that… yes, I didn’t exit the mode.

Maybe that’s because you set tms in arbitrary order? I don’t know if there’s any difference if we set TMs starting with childs and go up in hierarchy to parents. It is a question for somebody more knowledgeable about animation

SetBipedTM is in IIBipDriver9 interface

 MZ1
(@mz1)
Joined: 10 months ago

Posts: 0

How we can access to that interface? I guess it would solve the problem.

(@denist)
Joined: 10 months ago

Posts: 0

biped needs a specific order to set bone transforms… and it’s not a simple hierarchical order.

 MZ1

I couldn’t find it neither in IBipMaster or IIBipMaster:

public static Autodesk.Max.IBipMaster GetIBipMasterInterface(IINode node)
{
    var ptr = ((INativeObject)node.TMController.GetInterface((InterfaceID)0x9167)).NativePointer;
    return (Autodesk.Max.IBipMaster)Autodesk.Max.Wrappers.CustomMarshalerBipMaster.GetInstance(string.Empty).MarshalNativeToManaged(ptr);
}

public static IIBipMaster GetIIBipMasterInterface(IINode node)
{
    return globalInterface.IBipMaster12.GetBipMaster12Interface(node.TMController);
}

It should present in IBipMaster9+ ( AD renamed classes and interfaces cause of this master/slave bullshit ) and in newer versions it became IBipDriver9.

But is it really a good idea to store poses as world coords in the first place? .SetBipedTM expects world tm
If you move whole rig just a tiny bit then all your TMs must update since all of them now differ from what is strored in xml, but the pose remained absolutely the same

2 Replies
 MZ1
(@mz1)
Joined: 10 months ago

Posts: 0

It is not ideal, but the only method that comes to my mind for now. to make the entire biped or rig, we should move the root object, but Any other mechanism are welcome.

 MZ1
(@mz1)
Joined: 10 months ago

Posts: 0

I ended up to save and load transforms locally. First I tried to set the transform controller, but I waste my time:

So the best method is to make all transforms locally:

private IMatrix3 GetNodeLocalTM(IINode node)
{
    int time = coreInterface.Time;
    IMatrix3 nodeTM = node.GetNodeTM(time, null);
    if (IsBipedNode(node))
    {
        IIBipMaster9 iBipMaster9 = GetIBipMasterInterface9(node);
        IINode footstepNode = iBipMaster9.GetNode(15, 0);
        nodeTM.MultiplyBy(globalInterface.Inverse(footstepNode.GetNodeTM(time,null)));
    }
    else
    {
        nodeTM.MultiplyBy(globalInterface.Inverse(node.GetParentTM(time)));
    }
    return nodeTM;
}

private void SetNodeLocalTM(IINode node, IMatrix3 matrix)
{
    int time = coreInterface.Time;
    if (IsBipedNode(node))
    {
        IIBipMaster9 iBipMaster9 = GetIBipMasterInterface9(node);
        int id = 0;
        int link = 0;
        iBipMaster9.GetIdLink(node, ref id, ref link);
        IINode footstepNode = iBipMaster9.GetNode(15, 0);
        matrix.MultiplyBy(footstepNode.GetNodeTM(time,null));
        iBipMaster9.SetBipedTM(time, matrix, id, link);
    }
    else
    {            
        matrix.MultiplyBy(node.GetParentTM(time));
        node.SetNodeTM(time, matrix);
    }
}

could you save the file in 2016 version please? maybe my old projects will be helpful…

Denis, there’s no .max file inside only the source codes

ouch

 MZ1

Sadly, There is a dotnet dll that may not work on other versions, mostly because of Autodesk renaming system

Page 2 / 3