Performing translation after rotation on object

by green123   Last Updated July 10, 2019 19:13 PM - source

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



Related Questions



3D Player x positon problem

Updated November 11, 2017 17:13 PM

Translating an object in the rotation direction

Updated April 15, 2015 20:05 PM