forked from sideeffects/HoudiniEngineForMaya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssetNode.h
210 lines (173 loc) · 7.36 KB
/
AssetNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#ifndef __AssetNode_h__
#define __AssetNode_h__
#include <maya/MPxTransform.h>
#include <maya/MTypeId.h>
class MPlugArray;
#include <vector>
class Asset;
// -------------------------------------------------------------------------------
//Overall structure:
//
// The AssetNode is a Maya node that wraps the functionality of a Houdini asset.
// It has input attributes (dynamically created) that mirror the input parms of the asset.
// The input attributes are created dynamically at compute time, by the function
// Asset::getParmAttributes()
// At compute time, the input attributes are read and pushed into HAPI, then it
// calls on the Asset class (a helper, contained as a member) to compute itself.
// The Asset class knows how to compute itself - it will first deal with inputs
// to the asset, whether from another asset (inter-asset workflow) or from the
// Maya scene (geometry marshalling). It will then call HAPI_CookAsset() and
// then extract the results from Houidni to update all the Maya output attributes.
// It does this by first calling computeInstancerObjects() then
// computeGeometryObjects(). Each of these will fill out the information in
// the output attribute. For computeInstancerObjects() it will end up doing the
// work by calling the compute() function of the OutputInstancerObject class, and
// for computeGeometryObjects() it will call the computeParts() function of the
// OutputGeometryObject class.
class AssetNode: public MPxTransform
{
public:
AssetNode();
virtual ~AssetNode();
virtual void postConstructor();
virtual MStatus compute(const MPlug& plug, MDataBlock& data);
virtual bool getInternalValueInContext(
const MPlug &plug,
MDataHandle &dataHandle,
MDGContext &ctx);
virtual bool setInternalValueInContext(
const MPlug &plug,
const MDataHandle &dataHandle,
MDGContext &ctx
);
virtual int internalArrayCount(const MPlug &plug, const MDGContext &ctx) const;
virtual void copyInternalData(MPxNode* node);
virtual MStatus setDependentsDirty(const MPlug& plugBeingDirtied,
MPlugArray& affectedPlugs);
Asset* getAsset() const;
static void* creator();
static MStatus initialize();
void rebuildAsset();
public:
static MString typeName;
static MTypeId typeId;
private:
Asset* myAsset;
bool isAssetValid() const;
void createAsset();
void destroyAsset();
MString myOTLFilePath;
MString myAssetName;
bool myIsLoadedFromFile;
bool myResultsClean;
bool myNeedToMarshalInput;
typedef std::vector<MObject> MObjectVector;
MObjectVector myDirtyParmAttributes;
public:
static MObject inTime;
static MObject otlFilePath;
static MObject assetName;
static MObject autoSyncOutputs;
static MObject splitGeosByGroup;
static MObject outputHiddenObjects;
static MObject outputTemplatedGeometries;
static MObject input;
static MObject output;
static MObject outputObjects;
static MObject outputObjectName;
static MObject outputObjectTransform;
static MObject outputObjectTranslate;
static MObject outputObjectTranslateX;
static MObject outputObjectTranslateY;
static MObject outputObjectTranslateZ;
static MObject outputObjectRotate;
static MObject outputObjectRotateX;
static MObject outputObjectRotateY;
static MObject outputObjectRotateZ;
static MObject outputObjectScale;
static MObject outputObjectScaleX;
static MObject outputObjectScaleY;
static MObject outputObjectScaleZ;
#if MAYA_API_VERSION >= 201400
static MObject outputObjectFluidFromAsset;
#endif
static MObject outputObjectMetaData;
static MObject outputGeos;
static MObject outputGeoType;
static MObject outputGeoName;
static MObject outputGeoIsTemplated;
static MObject outputGeoIsDisplayGeo;
static MObject outputGeoCurveType;
static MObject outputGeoCurveOrder;
static MObject outputGeoCurveCVX;
static MObject outputGeoCurveCVY;
static MObject outputGeoCurveCVZ;
static MObject outputGeoCurveCVs;
static MObject outputParts;
static MObject outputPartName;
static MObject outputPartHasMesh;
static MObject outputPartMesh;
static MObject outputPartHasParticles;
static MObject outputPartMaterial;
static MObject outputPartMaterialExists;
static MObject outputPartMaterialName;
static MObject outputPartTexturePath;
static MObject outputPartAmbientColor;
static MObject outputPartDiffuseColor;
static MObject outputPartSpecularColor;
static MObject outputPartAlphaColor;
static MObject outputPartParticle;
static MObject outputPartParticleCurrentTime;
static MObject outputPartParticlePositions;
static MObject outputPartParticleArrayData;
static MObject outputPartCurves;
static MObject outputPartCurvesIsBezier;
#if MAYA_API_VERSION >= 201400
static MObject outputPartVolume;
static MObject outputPartVolumeName;
static MObject outputPartVolumeGrid;
static MObject outputPartVolumeRes;
static MObject outputPartVolumeTransform;
static MObject outputPartVolumeTranslate;
static MObject outputPartVolumeTranslateX;
static MObject outputPartVolumeTranslateY;
static MObject outputPartVolumeTranslateZ;
static MObject outputPartVolumeRotate;
static MObject outputPartVolumeRotateX;
static MObject outputPartVolumeRotateY;
static MObject outputPartVolumeRotateZ;
static MObject outputPartVolumeScale;
static MObject outputPartVolumeScaleX;
static MObject outputPartVolumeScaleY;
static MObject outputPartVolumeScaleZ;
#endif
static MObject outputPartExtraAttributes;
static MObject outputPartExtraAttributeName;
static MObject outputPartExtraAttributeOwner;
static MObject outputPartExtraAttributeDataType;
static MObject outputPartExtraAttributeTuple;
static MObject outputPartExtraAttributeData;
static MObject outputVisibility;
static MObject outputIsInstanced;
//static MObject numObjects;
static MObject outputInstancers;
static MObject outputInstancerData;
static MObject outputInstancedObjectNames;
static MObject outputHoudiniInstanceAttribute;
static MObject outputHoudiniNameAttribute;
static MObject outputInstanceTransform;
static MObject outputInstanceTranslate;
static MObject outputInstanceTranslateX;
static MObject outputInstanceTranslateY;
static MObject outputInstanceTranslateZ;
static MObject outputInstanceRotate;
static MObject outputInstanceRotateX;
static MObject outputInstanceRotateY;
static MObject outputInstanceRotateZ;
static MObject outputInstanceScale;
static MObject outputInstanceScaleX;
static MObject outputInstanceScaleY;
static MObject outputInstanceScaleZ;
static MObject useInstancerNode;
};
#endif