2 #include "AL/usdmaya/Common.h"
3 #include "AL/maya/NodeHelper.h"
4 #include "AL/usdmaya/fileio/translators/TranslatorBase.h"
5 #include "AL/usdmaya/fileio/translators/TranslatorContext.h"
6 #include "AL/usdmaya/fileio/translators/TransformTranslator.h"
7 #include "AL/usdmaya/nodes/VariantDB.h"
9 #include "maya/MPxSurfaceShape.h"
10 #include "maya/MEventMessage.h"
11 #include "maya/MNodeMessage.h"
12 #include "maya/MPxDrawOverride.h"
13 #include "pxr/usd/usd/prim.h"
14 #include "pxr/usd/usd/timeCode.h"
15 #include "pxr/usd/sdf/path.h"
16 #include "pxr/base/tf/weakBase.h"
17 #include "pxr/usd/usd/notice.h"
18 #include "pxr/usd/sdf/notice.h"
21 class UsdImagingGLHdEngine;
34 :
public MPxSurfaceShape,
49 AL_MAYA_DECLARE_NODE();
176 bool getRenderAttris(
void* attribs,
const MHWRender::MFrameContext& frameContext,
const MDagPath& dagPath);
202 {
return m_requiredPaths.find(path) != m_requiredPaths.end(); }
209 const auto it = m_requiredPaths.find(path);
210 if(it != m_requiredPaths.end())
212 return it->second.m_node;
214 return MObject::kNullObj;
223 const MDagPath& proxyTransformPath,
236 const UsdPrim& usdPrim,
237 MDagModifier& modifier,
239 MDGModifier* modifier2 = 0,
240 uint32_t* createCount = 0);
249 const UsdPrim& usdPrim,
250 MDagModifier& modifier,
252 MDGModifier* modifier2 = 0);
260 const UsdPrim& usdPrim,
261 MDagModifier& modifier,
270 const UsdPrim& usdPrim,
271 MDagModifier& modifier,
286 { m_requiredPaths.clear(); }
296 {
return m_schemaNodeDB; }
309 inline UsdImagingGLHdEngine*
engine()
const
315 {
return m_selectedPaths; }
329 if(!m_path.IsEmpty())
331 UsdPrim prim = m_stage->GetPrimAtPath(m_path);
335 return m_stage->GetPseudoRoot();
342 void constructExcludedPrims();
343 bool getInternalValueInContext(
const MPlug& plug, MDataHandle& dataHandle, MDGContext& ctx)
override;
344 bool setInternalValueInContext(
const MPlug& plug,
const MDataHandle& dataHandle, MDGContext& ctx)
override;
348 const MPlug& outStage,
349 const MPlug& outTime,
350 const MObject& parentXForm,
351 MDagModifier& modifier,
353 MDGModifier* modifier2,
354 uint32_t* createCount);
356 void makeUsdTransformsInternal(
357 const UsdPrim& usdPrim,
358 const MObject& parentXForm,
359 MDagModifier& modifier,
361 MDGModifier* modifier2);
363 void removeUsdTransformsInternal(
364 const UsdPrim& usdPrim,
365 MDagModifier& modifier,
368 struct TransformReference
377 uint32_t m_required:1;
378 uint32_t m_selected:1;
379 uint32_t m_refCount:30;
390 typedef std::map<SdfPath, TransformReference> TransformReferenceMap;
391 TransformReferenceMap m_requiredPaths;
394 void makeTransformReference(
const SdfPath& path,
const MObject& node,
TransformReason reason);
400 void postConstructor()
override;
401 MStatus compute(
const MPlug& plug, MDataBlock& dataBlock)
override;
402 MStatus setDependentsDirty(
const MPlug& plugBeingDirtied, MPlugArray& plugs)
override;
403 bool isBounded()
const override;
410 MStatus computeInStageDataCached(
const MPlug& plug, MDataBlock& dataBlock);
411 MStatus computeOutStageData(
const MPlug& plug, MDataBlock& dataBlock);
412 MStatus computeOutputTime(
const MPlug& plug, MDataBlock& dataBlock);
418 UsdPrim getUsdPrim(MDataBlock& dataBlock)
const;
419 SdfPathVector getExcludePrimPaths()
const;
420 bool isStageValid()
const;
421 bool primHasExcludedParent(UsdPrim prim);
422 bool initPrim(
const uint32_t index, MDGContext& ctx);
424 void reloadStage(MPlug& plug);
425 void onObjectsChanged(UsdNotice::ObjectsChanged
const&, UsdStageWeakPtr
const& sender);
426 void variantSelectionListener(SdfNotice::LayersDidChange
const& notice, UsdStageWeakPtr
const& sender);
427 void onEditTargetChanged(UsdNotice::StageEditTargetChanged
const& notice, UsdStageWeakPtr
const& sender);
428 static void onSelectionChanged(
void* ptr);
429 static void onAttributeChanged(MNodeMessage::AttributeMessage, MPlug&, MPlug&,
void*);
430 void validateTransforms();
433 SdfPathVector m_selectedPaths;
434 std::vector<SdfPath> m_paths;
435 std::vector<UsdPrim> m_prims;
436 TfNotice::Key m_objectsChangedNoticeKey;
437 TfNotice::Key m_variantChangedNoticeKey;
438 TfNotice::Key m_editTargetChanged;
439 mutable std::map<UsdTimeCode, MBoundingBox> m_boundingBoxCache;
440 MCallbackId m_onSelectChanged;
441 MCallbackId m_beforeSaveSceneId;
442 MCallbackId m_attributeChanged;
443 SdfPathVector m_excludedGeometry;
444 SdfPathVector m_excludedTaggedGeometry;
445 UsdStageRefPtr m_stage;
447 SchemaNodeRefDB m_schemaNodeDB;
448 SdfPath m_variantChangePath;
449 SdfPathVector m_variantSwitchedPrims;
450 UsdImagingGLHdEngine* m_engine = 0;
451 uint32_t m_engineRefCount = 0;
452 bool m_variantHasChanged =
false;
the node exists for selection
Definition: ProxyShape.h:193
the node has been requested by a user
Definition: ProxyShape.h:194
void createSelectionChangedCallback()
create a callback to destroy unused transform nodes when the selection changes.
void unloadMayaReferences()
unloads all maya references
A custom proxy shape node that attaches itself to a USD file, and then renders it. The stage is held internally as a member variable, and it will be composed based on a change to the "filePath" attribute.
Definition: ProxyShape.h:33
void destroySelectionChangedCallback()
destroys the selection callback
void findExcludedGeometry()
searches for the excluded geometry
UsdStageRefPtr getUsdStage() const
provides access to the UsdStage that this proxy shape is currently representing
UsdPrim getRootPrim()
if a root prim has been specified by the user in the proxy shape AE, then this method will return the...
Definition: ProxyShape.h:325
void makeUsdTransforms(const UsdPrim &usdPrim, MDagModifier &modifier, TransformReason reason, MDGModifier *modifier2=0)
Will construct AL_usdmaya_Transform nodes for all of the prims from the specified usdPrim and down...
void printRefCounts() const
Debugging util - prints out the reference counts for each AL_usdmaya_Transform that currently exists ...
void deserialiseTranslatorContext()
deserialises the translator context
nodes::SchemaNodeRefDB & schemaDB()
return a reference to the DB of schema prims imported via custom translators (used for variant switch...
Definition: ProxyShape.h:295
AL_DECL_ATTRIBUTE(filePath)
the input USD file path for this proxy
bool isRequiredPath(const SdfPath &path) const
returns true if the path is required for an imported schema prim
Definition: ProxyShape.h:201
Layer * getLayer()
return the node that represents the root layer
The proxy shape node needs to store a mapping of all the schema nodes it has brought into the Maya sc...
Definition: VariantDB.h:53
void destroyTransformReferences()
destroys all internal transform references
Definition: ProxyShape.h:285
Layer * findLayer(SdfLayerHandle handle)
Locate the maya node associated with the specified layer.
MObject findRequiredPath(const SdfPath &path) const
returns the MObject of the maya transform for requested path (or MObject::kNullObj) ...
Definition: ProxyShape.h:207
UsdImagingGLHdEngine * engine() const
returns the usd imaging engine for this proxy shape
Definition: ProxyShape.h:309
std::vector< UsdPrim > huntForNativeNodesUnderPrim(const MDagPath &proxyTransformPath, SdfPath startPath)
traverses the UsdStage looking for the prims that are going to be handled by custom transformer plug-...
MObject makeUsdTransformChain(const UsdPrim &usdPrim, MDagModifier &modifier, TransformReason reason, MDGModifier *modifier2=0, uint32_t *createCount=0)
constructs a single chain of transform nodes from the usdPrim to the root of this proxy shape...
void constructGLImagingEngine()
constructs the USD imaging engine for this shape
SdfPathVector & selectedPaths()
returns the paths of the selected items within the proxy shape
Definition: ProxyShape.h:314
TransformReason
an enum describing the reason that a transform exists in the scene
Definition: ProxyShape.h:191
void removeUsdTransformChain(const UsdPrim &usdPrim, MDagModifier &modifier, TransformReason reason)
will destroy all of the AL_usdmaya_Transform nodes from the prim specified, up to the root (unless an...
the node is required for an imported schema prim
Definition: ProxyShape.h:195
The layer node stores a reference to an SdfLayer.
Definition: Layer.h:20
bool getRenderAttris(void *attribs, const MHWRender::MFrameContext &frameContext, const MDagPath &dagPath)
gets hold of the attributes on this node that control the rendering in some way
MString findLayerMayaName(SdfLayerHandle handle)
Locate the name of the maya node associated with the specified layer.
MBoundingBox boundingBox() const override
compute bounds
void serialiseTranslatorContext()
serialises the translator context
void removeUsdTransforms(const UsdPrim &usdPrim, MDagModifier &modifier, TransformReason reason)
Will destroy all AL_usdmaya_Transform nodes found underneath the prim (unless those nodes are require...
This is a little helper object designed to reduce the amount of boilerplate GUI code you need to jump...
Definition: NodeHelper.h:175