AL_USDMaya  0.29.4
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Transform.h
1 //
2 // Copyright 2017 Animal Logic
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.//
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #pragma once
17 #include <AL/usdmaya/ForwardDeclares.h>
18 
19 #include "AL/maya/utils/NodeHelper.h"
20 #include "AL/usdmaya/utils/ForwardDeclares.h"
21 #include "AL/maya/utils/MayaHelperMacros.h"
22 #include "maya/MObjectHandle.h"
23 #include "maya/MPxTransform.h"
24 
25 
26 namespace AL {
27 namespace usdmaya {
28 namespace nodes {
29 
30 //----------------------------------------------------------------------------------------------------------------------
32 // transform type directly from inside Maya. It works by providing a custom MPxTransform node which uses a
82 //----------------------------------------------------------------------------------------------------------------------
83 class Transform
84  : public MPxTransform,
85  public AL::maya::utils::NodeHelper
86 {
87 public:
88 
89  Transform();
90  ~Transform();
91 
92  //--------------------------------------------------------------------------------------------------------------------
93  // Type Info & Registration
94  //--------------------------------------------------------------------------------------------------------------------
95  AL_MAYA_DECLARE_NODE();
96 
97  //--------------------------------------------------------------------------------------------------------------------
98  // Input Attributes
99  //--------------------------------------------------------------------------------------------------------------------
100  AL_DECL_ATTRIBUTE(primPath);
101  AL_DECL_ATTRIBUTE(inStageData);
102  AL_DECL_ATTRIBUTE(time);
103  AL_DECL_ATTRIBUTE(timeOffset);
104  AL_DECL_ATTRIBUTE(timeScalar);
105  AL_DECL_ATTRIBUTE(localTranslateOffset);
106  AL_DECL_ATTRIBUTE(pushToPrim);
107  AL_DECL_ATTRIBUTE(readAnimatedValues);
108 
109  //--------------------------------------------------------------------------------------------------------------------
110  // Output Attributes
111  //--------------------------------------------------------------------------------------------------------------------
112  AL_DECL_ATTRIBUTE(outTime);
113 
114  //--------------------------------------------------------------------------------------------------------------------
116  //--------------------------------------------------------------------------------------------------------------------
117 
121  { return reinterpret_cast<TransformationMatrix*>(transformationMatrixPtr()); }
122 
125  MPxNode::SchedulingType schedulingType() const override
126  { return kParallel; }
127 
128  inline const MObject getProxyShape() const
129  { return proxyShapeHandle.object(); }
130 
131 private:
132 
133  //--------------------------------------------------------------------------------------------------------------------
135  //--------------------------------------------------------------------------------------------------------------------
136 
137  MStatus validateAndSetValue(const MPlug& plug, const MDataHandle& handle, const MDGContext& context) override;
138  MPxTransformationMatrix* createTransformationMatrix() override;
139  MStatus compute(const MPlug &plug, MDataBlock &datablock) override;
140  void postConstructor() override;
141  MBoundingBox boundingBox() const override;
142  MStatus connectionMade(const MPlug& plug, const MPlug& otherPlug, bool asSrc) override;
143  MStatus connectionBroken(const MPlug& plug, const MPlug& otherPlug, bool asSrc) override;
144  bool isBounded() const override
145  { return true; }
146  bool treatAsTransform() const override
147  { return false; }
148 
149  //--------------------------------------------------------------------------------------------------------------------
151  //--------------------------------------------------------------------------------------------------------------------
152 
153  void updateTransform(MDataBlock& dataBlock);
154 
155  //--------------------------------------------------------------------------------------------------------------------
157  //--------------------------------------------------------------------------------------------------------------------
158  bool updateTransformInProgress = false;
159 
160  //--------------------------------------------------------------------------------------------------------------------
162  //--------------------------------------------------------------------------------------------------------------------
163 
197 
222 
223  //--------------------------------------------------------------------------------------------------------------------
225  //--------------------------------------------------------------------------------------------------------------------
226 
234 
235  MObjectHandle proxyShapeHandle;
236 };
237 
238 //----------------------------------------------------------------------------------------------------------------------
239 } // nodes
240 } // usdmaya
241 } // AL
242 //----------------------------------------------------------------------------------------------------------------------
MPxNode::SchedulingType schedulingType() const override
Enable parallel evaluation.
Definition: Transform.h:125
TransformationMatrix * transform() const
returns the transformation matrix for this transform node
Definition: Transform.h:120
This class provides a transformation matrix that allows you to apply tweaks over some read only trans...
Definition: TransformationMatrix.h:41
The AL::usdmaya::nodes::Transform node is a custom transform node that allows you to manipulate a USD...
Definition: Transform.h:83