0
\$\begingroup\$

I'm working in Maya and I have a light object. When I rotate my light object on the origin my manipulator rotates with object. However, as soon as I translate the light object (no longer at origin), my manipulator goes in some other direction. If I move the light object back to the origin, the manipulator will return to back to the correct spot.

The code does two things:

  1. It will get the translation of the light object's transform and set the manipulator's translation to that. I've debugged and checked the values and it does set it to the correct values
    MFnDagNode dagFn(fNodePath);
    MDagPath path;
    dagFn.getPath(path);
    path.pop();  
    MFnTransform transformFn(path);
    return transformFn.getTranslation(MSpace::kWorld); // a vector
  1. It gets the transform's rotation quaternion and sets the manipulator's rotation to that
    MFnDagNode dagFn(fNodePath);
    MDagPath path;
    dagFn.getPath(path);
    path.pop();
    MFnTransform transformFn(path);
    MQuaternion q;
    transformFn.getRotation(q, MSpace::kTransform);
    manipFn.setRotation(q);

Light object rotated on origin, in blue circle is the manipulator

Light object translated, the manipulator is not on the light object as expected

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.