سؤال

I am implementing a LookAt Controller plugin by deriving from the Control class.

Everything works fine, except that I don't understand how I can get a INode pointer to the node that the Control belongs to. How do I get this pointer? (I need to access the pointer from within the code of my LookAt class.)

هل كانت مفيدة؟

المحلول

Don't get the node pointer. Controls shouldn't know how their values are being used, just take your inputs, apply your algorithm to it, and return the value.

For example, to create a LookAt, I would define my Control to be of superclass type CTRL_ROTATION_CLASS_ID. When this control evaluates (GetValue is called with method = CTRL_RELATIVE), it will be passed a pointer to the transform you want to apply your value to. Assuming your rotation is part of a PRS, then the transform will be the parents transform, + the Position part of the (P)RS.

void YourClass::GetValue(TimeValue t, void* val, ...)
{
    Matrix3* pInTransform = reinterpret_cast<Matrix3*>(val);
    Point3& pMyPosition = pInTransform->GetTrans();

With the position, you can get the position of your target, then rotate/set that input matrix so your eye vector points at the target

I'd highly recommend the learning path section of the documentation for a general understanding of how the animation hierarchy in Max works.

http://docs.autodesk.com/3DSMAX/15/ENU/3ds-Max-SDK-Programmer-Guide/files/GUID-A39314EC-15B4-4919-BB1B-318FFDC05DD8.htm

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top