Notifications
Clear all

[Closed] [.net max SDK] animateVertex equivalent

Hello,

I’m trying to animate vertices using the Max SDK (.net version). I have it working with 1 line of MaxScript (“animateVertex $ #all”) in between and I would like to know if it would be possible to remove it. This is what I have right now:

var iface = m_Global.COREInterface;
IInterval interval = m_Global.Interval.Create();
interval.SetInfinite();
IINode node = iface.GetSelNode(0);
IObject baseObjectRef = node.ObjectRef.FindBaseObject();
ITriObject triObject = baseObjectRef as ITriObject;
IMasterPointControl masterPointController = GetmasterPointController(triObject);
if (masterPointController == null)
    return;

MaxScriptExecute("animateVertex $ #all");  //This is the one!

subControlList = EnumControl(masterPointController);

int begin = 0 * m_Global.TicksPerFrame; //0 :)
int end = 1 * m_Global.TicksPerFrame;

m_Global.SuspendAnimate();
m_Global.AnimateOn();

foreach (var control in subControlList)
{
    IPoint3 val = m_Global.Point3.Create(0, 0, 0);
    object valObj = val;
    control.GetValue(begin, ref valObj, interval, GetSetMethod.Absolute);

    var testVal = valObj as IPoint3;
    testVal.X += 30;    testVal.Y += 30;    testVal.Z += 30;
    object testValObj = testVal; 

    control.SetValue(end, testValObj, true, GetSetMethod.Absolute);
}

m_Global.ResumeAnimate();

I’ve tried multiple things to replace it, but none of them work. I’d like to know what it does in the background, but I couldn’t find any samples.

masterPointController.SetNumSubControllers(8, true);
for (int i = 0; i < masterPointController.NumSubControllers; i++)
{
    //I want a ctrlPoint3
    //var controller = m_Global.Point3Controller.ToController; //crash!
    IControl positionController = m_Global.NewDefaultPositionController; //I dont think this one is correct either, but doesn't crash at least

    masterPointController.SetSubController(i, positionController);  //set the controller at the current index              
    IPoint3 val = trimesh.Mesh.GetVert(i);  //get the position of the vertex
    object valObj = val; 

    positionController.SetValue(begin, valObj, true, GetSetMethod.Absolute);   //set a key at 0

    val.X += 30;    val.Y += 30;    val.Z += 30;
    object testValObj = val; 

    positionController.SetValue(end, testValObj, true, GetSetMethod.Absolute);  //set another key at 1
}

This doesn’t work, it moves the whole mesh and doesn’t even create any keyframes. I also don’t see any subControllers under Master Point Controller in the Track View. Could it be because I set an incorrect controller type? (ctrlPoint3 vs ctrlPosition)

Thanks in advance,
Vin