Notifications
Clear all
[Closed] SDK-C# Set transform controller value
Page 4 / 4
Prev
Feb 02, 2022 6:53 am
Is this working for you?! which Max version do you use? not working for me. I have 2020
Feb 02, 2022 6:53 am
I tested on Max 2018 – 2022 and none of them is working. I can build and max will not crash, but nothing is changing in the scene.
Feb 02, 2022 6:53 am
It’s 2016. And no, nothing is changing in the scene. But the same with your code.
It was just to try something without ‘ExecuteMaxScript’.
Sorry.
Feb 02, 2022 6:53 am
have you tried setting the sub controllers (position rotation scale) from a decomp_affine of the transform matrix ?
virtual Control * GetPositionController ()
virtual Control * GetRotationController ()
virtual Control * GetScaleController ()
CoreExport void decomp_affine ( Matrix3 A, AffineParts * parts )
where
struct AffineParts: public MaxHeapOperators {
/*! The translation components. */
Point3 t; /* Translation components */
/*! The essential rotation. */
Quat q; /* Essential rotation */
/*! The stretch rotation. This is the axis system of the scaling application. */
Quat u; /* Stretch rotation */
/*! The stretch factors. These are the scale factors for x, y and z. */
Point3 k; /* Stretch factors */
/*! Sign of the determinant. */
float f; /* Sign of determinant */
};
from my first post
Control *c;
c = node->GetTMController()->GetPositionController();
Feb 02, 2022 6:53 am
Something like this?
private IMatrix3 GetTMControllerValue(IINode node)
{
int time = coreInterface.Time;
IInterval interval = globalInterface.Interval.Create();
IControl tMController = node.TMController;
object rotation = globalInterface.Quat.Create();
tMController.RotationController.GetValue(time, ref rotation, interval, GetSetMethod.Absolute);
object position = globalInterface.Point3.Create();
tMController.PositionController.GetValue(time, ref position, interval, GetSetMethod.Absolute);
object scale = globalInterface.Point3.Create();
tMController.ScaleController.GetValue(time, ref scale, interval, GetSetMethod.Absolute);
IMatrix3 matrix = globalInterface.Matrix3.Create();
matrix.IdentityMatrix();
((IQuat)rotation).MakeMatrix(matrix, false);
matrix.PreScale((IPoint3)scale);
matrix.Translate((IPoint3) position);
return matrix;
}
private void SetTMControllerValue(IINode node,IMatrix3 matrix)
{
int time = coreInterface.Time;
IControl tMController = node.TMController;
IAffineParts apmatrix = globalInterface.AffineParts.Create();
globalInterface.DecompAffine(matrix, apmatrix);
tMController.PositionController.SetValue(time, apmatrix.T, true, GetSetMethod.Absolute);
tMController.RotationController.SetValue(time, apmatrix.Q, true, GetSetMethod.Absolute);
tMController.ScaleController.SetValue(time, apmatrix.K, true, GetSetMethod.Absolute);
}
it works in some cases, but it will crash on this line:
object scale = globalInterface.Point3.Create();
tMController.ScaleController.GetValue(time, ref scale, interval, GetSetMethod.Absolute);
Page 4 / 4
Prev