Notifications
Clear all
[Closed] [.net max SDK] animateVertex equivalent
Jan 18, 2015 1:29 am
Hello,
Im 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();
Ive tried multiple things to replace it, but none of them work. Id like to know what it does in the background, but I couldnt 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 doesnt work, it moves the whole mesh and doesnt even create any keyframes. I also dont 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