20 #include "AL/usdmaya/TransformOperation.h"
22 #include "maya/MPxTransformationMatrix.h"
23 #include "maya/MPxTransform.h"
26 #include "pxr/usd/usdGeom/xform.h"
27 #include "pxr/usd/usdGeom/xformCommonAPI.h"
29 PXR_NAMESPACE_USING_DIRECTIVE
42 :
public MPxTransformationMatrix
47 std::vector<UsdGeomXformOp> m_xformops;
48 std::vector<TransformOperation> m_orderedOps;
49 MObject m_transformNode;
53 MEulerRotation m_rotationTweak;
54 MVector m_translationTweak;
56 MPoint m_scalePivotTweak;
57 MVector m_scalePivotTranslationTweak;
58 MPoint m_rotatePivotTweak;
59 MVector m_rotatePivotTranslationTweak;
60 MQuaternion m_rotateOrientationTweak;
63 MVector m_scaleFromUsd;
64 MEulerRotation m_rotationFromUsd;
65 MVector m_translationFromUsd;
66 MVector m_shearFromUsd;
67 MPoint m_scalePivotFromUsd;
68 MVector m_scalePivotTranslationFromUsd;
69 MPoint m_rotatePivotFromUsd;
70 MVector m_rotatePivotTranslationFromUsd;
71 MQuaternion m_rotateOrientationFromUsd;
74 MVector m_localTranslateOffset;
77 void insertTranslateOp();
80 void insertScalePivotOp();
81 void insertScalePivotTranslationOp();
82 void insertRotateOp();
83 void insertRotatePivotOp();
84 void insertRotatePivotTranslationOp();
85 void insertRotateAxesOp();
90 kAnimatedScale = 1 << 0,
91 kAnimatedRotation = 1 << 1,
92 kAnimatedTranslation = 1 << 2,
93 kAnimatedMatrix = 1 << 3,
94 kAnimatedShear = 1 << 4,
98 kFromMayaSchema = 1 << 9,
101 kPrimHasScale = 1 << 16,
102 kPrimHasRotation = 1 << 17,
103 kPrimHasTranslation = 1 << 18,
104 kPrimHasShear = 1 << 19,
105 kPrimHasScalePivot = 1 << 20,
106 kPrimHasScalePivotTranslate = 1 << 21,
107 kPrimHasRotatePivot = 1 << 22,
108 kPrimHasRotatePivotTranslate = 1 << 23,
109 kPrimHasRotateAxes = 1 << 24,
110 kPrimHasPivot = 1 << 25,
111 kPrimHasTransform = 1 << 26,
113 kPushToPrimEnabled = 1 << 28,
114 kInheritsTransform = 1 << 29,
116 kPushPrimToMatrix = 1 << 30,
117 kReadAnimatedValues = 1 << 31,
119 kAnimationMask = kAnimatedShear | kAnimatedScale | kAnimatedRotation | kAnimatedTranslation | kAnimatedMatrix,
124 kPreservationMask = kPushToPrimEnabled | kReadAnimatedValues
126 uint32_t m_flags = 0;
128 bool internal_readVector(MVector& result,
const UsdGeomXformOp& op) {
return readVector(result, op,
getTimeCode()); }
129 bool internal_readShear(MVector& result,
const UsdGeomXformOp& op) {
return readShear(result, op,
getTimeCode()); }
130 bool internal_readPoint(MPoint& result,
const UsdGeomXformOp& op) {
return readPoint(result, op,
getTimeCode()); }
131 bool internal_readRotation(MEulerRotation& result,
const UsdGeomXformOp& op) {
return readRotation(result, op,
getTimeCode()); }
133 bool internal_readMatrix(MMatrix& result,
const UsdGeomXformOp& op) {
return readMatrix(result, op,
getTimeCode()); }
135 bool internal_pushVector(
const MVector& result, UsdGeomXformOp& op) {
return pushVector(result, op,
getTimeCode()); }
136 bool internal_pushPoint(
const MPoint& result, UsdGeomXformOp& op) {
return pushPoint(result, op,
getTimeCode()); }
137 bool internal_pushRotation(
const MEulerRotation& result, UsdGeomXformOp& op) {
return pushRotation(result, op,
getTimeCode()); }
138 void internal_pushDouble(
const double result, UsdGeomXformOp& op) {
pushDouble(result, op,
getTimeCode()); }
139 bool internal_pushShear(
const MVector& result, UsdGeomXformOp& op) {
return pushShear(result, op,
getTimeCode()); }
140 bool internal_pushMatrix(
const MMatrix& result, UsdGeomXformOp& op) {
return pushMatrix(result, op,
getTimeCode()); }
147 { m_transformNode = object; }
153 MPlug plug(m_transformNode, MPxTransform::translate);
154 return plug.isLocked() ||
155 plug.child(0).isLocked() ||
156 plug.child(1).isLocked() ||
157 plug.child(2).isLocked();
164 MPlug plug(m_transformNode, MPxTransform::rotate);
165 return plug.isLocked() ||
166 plug.child(0).isLocked() ||
167 plug.child(1).isLocked() ||
168 plug.child(2).isLocked();
175 MPlug plug(m_transformNode, MPxTransform::scale);
176 return plug.isLocked() ||
177 plug.child(0).isLocked() ||
178 plug.child(1).isLocked() ||
179 plug.child(2).isLocked();
187 static bool readVector(MVector& result,
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
194 static bool readShear(MVector& result,
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
201 static bool readPoint(MPoint& result,
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
208 static bool readRotation(MEulerRotation& result,
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
214 static double readDouble(
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
221 static bool readMatrix(MMatrix& result,
const UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::EarliestTime());
228 static bool pushVector(
const MVector& input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
235 static bool pushPoint(
const MPoint& input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
242 static bool pushRotation(
const MEulerRotation& input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
249 static void pushDouble(
const double input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
256 static bool pushShear(
const MVector& input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
263 static bool pushMatrix(
const MMatrix& input, UsdGeomXformOp& op, UsdTimeCode timeCode = UsdTimeCode::Default());
272 static MPxTransformationMatrix*
creator();
308 { m_localTranslateOffset = localTranslateOffset; }
312 inline const UsdPrim&
prim()
const
321 {
return (kAnimationMask & m_flags) != 0; }
325 {
return (kAnimatedScale & m_flags) != 0; }
329 {
return (kAnimatedShear & m_flags) != 0; }
333 {
return (kAnimatedTranslation & m_flags) != 0; }
337 {
return (kAnimatedRotation & m_flags) != 0; }
341 {
return (kAnimatedMatrix & m_flags) != 0; }
345 {
return (kPrimHasScale & m_flags) != 0; }
349 {
return (kPrimHasRotation & m_flags) != 0; }
353 {
return (kPrimHasTranslation & m_flags) != 0; }
357 {
return (kPrimHasShear & m_flags) != 0; }
361 {
return (kPrimHasScalePivot & m_flags) != 0; }
365 {
return (kPrimHasScalePivotTranslate & m_flags) != 0; }
369 {
return (kPrimHasRotatePivot & m_flags) != 0; }
373 {
return (kPrimHasRotatePivotTranslate & m_flags) != 0; }
377 {
return (kPrimHasRotateAxes & m_flags) != 0; }
381 {
return (kPrimHasPivot & m_flags) != 0; }
385 {
return (kPrimHasTransform & m_flags) != 0; }
389 {
return (kReadAnimatedValues & m_flags) != 0; }
393 {
return (kPushToPrimEnabled & m_flags) != 0; }
397 {
return (kPushPrimToMatrix & m_flags) != 0; }
425 MStatus translateTo(
const MVector &vector, MSpace::Space = MSpace::kTransform)
override;
428 MStatus scaleTo(
const MVector &, MSpace::Space = MSpace::kTransform)
override;
431 MStatus shearTo(
const MVector& shear, MSpace::Space = MSpace::kTransform)
override;
434 MStatus setScalePivot(
const MPoint &, MSpace::Space = MSpace::kTransform,
bool balance =
true)
override;
435 MStatus setScalePivotTranslation(
const MVector &vector, MSpace::Space = MSpace::kTransform)
override;
438 MStatus setRotatePivot(
const MPoint &, MSpace::Space = MSpace::kTransform,
bool balance =
true)
override;
439 MStatus setRotatePivotTranslation(
const MVector &vector, MSpace::Space = MSpace::kTransform)
override;
442 MStatus setRotationOrder(MTransformationMatrix::RotationOrder,
bool preserve =
true)
override;
445 MStatus rotateTo(
const MQuaternion &q, MSpace::Space = MSpace::kTransform)
override;
446 MStatus rotateTo(
const MEulerRotation &e, MSpace::Space = MSpace::kTransform)
override;
447 MStatus setRotateOrientation(
const MQuaternion &q, MSpace::Space = MSpace::kTransform,
bool balance =
true)
override;
448 MStatus setRotateOrientation(
const MEulerRotation &euler, MSpace::Space = MSpace::kTransform,
bool balance =
true)
override;
451 MMatrix asMatrix()
const override;
452 MMatrix asMatrix(
double percent)
const override;