AL_USDMaya  0.29.4
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ProxyDrawOverride.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 
18 #include "../Api.h"
19 
20 #include "maya/MPxDrawOverride.h"
21 #include "AL/usdmaya/ForwardDeclares.h"
22 
23 #include "pxr/pxr.h"
24 #include "pxr/usdImaging/usdImaging/version.h"
25 
26 #include "AL/usd/utils/ForwardDeclares.h"
27 #if (USD_IMAGING_API_VERSION >= 7)
28 # include "pxr/usdImaging/usdImagingGL/hdEngine.h"
29 #else
30 # include "pxr/usdImaging/usdImaging/hdEngine.h"
31 #endif
32 
33 PXR_NAMESPACE_USING_DIRECTIVE
34 
35 
36 namespace AL {
37 namespace usdmaya {
38 namespace nodes {
39 
40 //----------------------------------------------------------------------------------------------------------------------
43 //----------------------------------------------------------------------------------------------------------------------
45  : public MHWRender::MPxDrawOverride
46 {
47 public:
48 
51  ProxyDrawOverride(const MObject& obj);
52 
55 
59  AL_USDMAYA_PUBLIC
60  static MHWRender::MPxDrawOverride* creator(const MObject& obj);
61 
66  bool isBounded(
67  const MDagPath& objPath,
68  const MDagPath& cameraPath) const override;
69 
74  MBoundingBox boundingBox(
75  const MDagPath& objPath,
76  const MDagPath& cameraPath) const override;
77 
84  MUserData* prepareForDraw(
85  const MDagPath& objPath,
86  const MDagPath& cameraPath,
87  const MHWRender::MFrameContext& frameContext,
88  MUserData* oldData) override;
89 
91  AL_USDMAYA_PUBLIC
92  static MString kDrawDbClassification;
93 
95  AL_USDMAYA_PUBLIC
96  static MString kDrawRegistrantId;
97 
101  AL_USDMAYA_PUBLIC
102  static void draw(const MHWRender::MDrawContext& context, const MUserData* data);
103 
107  AL_USDMAYA_PUBLIC
108  static ProxyShape* getShape(const MDagPath& objPath);
109 
112  MHWRender::DrawAPI supportedDrawAPIs() const override
113  { return MHWRender::kOpenGL | MHWRender::kOpenGLCoreProfile; }
114 
115 #if MAYA_API_VERSION >= 201700
116  bool excludedFromPostEffects() const override
119  { return false; }
120 #endif
121 
122 private:
123  static MUint64 s_lastRefreshFrameStamp;
124 
125 #if MAYA_API_VERSION >= 20190000
126  bool wantUserSelection() const override {return true;}
127 
128  bool userSelect(
129  const MHWRender::MSelectionInfo& selectInfo,
130  const MHWRender::MDrawContext& context,
131  const MDagPath& objPath,
132  const MUserData* data,
133  MSelectionList& selectionList,
134  MPointArray& worldSpaceHitPts) override;
135 #endif
136 
137 };
138 
139 //----------------------------------------------------------------------------------------------------------------------
140 } // nodes
141 } // usdmaya
142 } // AL
143 //----------------------------------------------------------------------------------------------------------------------
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:244
MBoundingBox boundingBox(const MDagPath &objPath, const MDagPath &cameraPath) const override
Called by Maya whenever the bounding box of the drawable object is needed.
static AL_USDMAYA_PUBLIC MString kDrawRegistrantId
draw registration id for this override
Definition: ProxyDrawOverride.h:96
static AL_USDMAYA_PUBLIC MString kDrawDbClassification
draw classification string for this override
Definition: ProxyDrawOverride.h:92
static AL_USDMAYA_PUBLIC MHWRender::MPxDrawOverride * creator(const MObject &obj)
static creator method
MUserData * prepareForDraw(const MDagPath &objPath, const MDagPath &cameraPath, const MHWRender::MFrameContext &frameContext, MUserData *oldData) override
Called by Maya whenever the object is dirty and needs to update for draw.
This class provides the draw override for the USD proxy shape node.
Definition: ProxyDrawOverride.h:44
MHWRender::DrawAPI supportedDrawAPIs() const override
We support the legacy and VP2 core profile rendering.
Definition: ProxyDrawOverride.h:112
bool isBounded(const MDagPath &objPath, const MDagPath &cameraPath) const override
Called by Maya to determine if the drawable object is bounded or not.
static AL_USDMAYA_PUBLIC void draw(const MHWRender::MDrawContext &context, const MUserData *data)
The draw callback, performs the actual rendering for the draw override.
static AL_USDMAYA_PUBLIC ProxyShape * getShape(const MDagPath &objPath)
utility function to get a pointer to the proxy shape node given the specified path ...
ProxyDrawOverride(const MObject &obj)
ctor