AL_USDMaya  0.29.4
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RendererManager.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 "AL/maya/utils/NodeHelper.h"
21 #include "pxr/pxr.h"
22 #include "pxr/usd/usd/stage.h"
23 
24 #include "maya/MPxLocatorNode.h"
25 #include "maya/MNodeMessage.h"
26 #include "AL/maya/utils/MayaHelperMacros.h"
27 
28 #include <map>
29 
30 PXR_NAMESPACE_USING_DIRECTIVE
31 
32 namespace AL {
33 namespace usdmaya {
34 namespace nodes {
35 
36 class ProxyShape;
37 
38 
39 //----------------------------------------------------------------------------------------------------------------------
42 //----------------------------------------------------------------------------------------------------------------------
44  : public MPxNode,
45  public AL::maya::utils::NodeHelper
46 {
47 public:
48 
50  inline RendererManager()
51  : MPxNode(), NodeHelper() {}
52 
53  ~RendererManager();
54 
57  static MObject findNode();
58 
65  static MObject findOrCreateNode(MDGModifier* dgmod=nullptr, bool* wasCreated=nullptr);
66 
69  static RendererManager* findManager();
70 
77  static RendererManager* findOrCreateManager(MDGModifier* dgmod=nullptr, bool* wasCreated=nullptr);
78 
79  //--------------------------------------------------------------------------------------------------------------------
81  //--------------------------------------------------------------------------------------------------------------------
82 
84  void onRendererChanged();
85 
87  bool setRendererPlugin(const MString& pluginName);
88 
90  void changeRendererPlugin(ProxyShape* proxy, bool creation=false);
91 
93  int getRendererPluginIndex() const;
94 
96  static const MStringArray& getRendererPluginList() { return m_rendererPluginsNames; }
97 
98  //--------------------------------------------------------------------------------------------------------------------
100  //--------------------------------------------------------------------------------------------------------------------
102 
103  //--------------------------------------------------------------------------------------------------------------------
105  //--------------------------------------------------------------------------------------------------------------------
106 
108  AL_DECL_ATTRIBUTE(rendererPluginName);
110  AL_DECL_ATTRIBUTE(rendererPlugin);
111 
112 private:
113  static MObject _findNode();
114  static void onAttributeChanged(MNodeMessage::AttributeMessage, MPlug&, MPlug&, void*);
115 
117  void addAttributeChangedCallback();
118 
120  void removeAttributeChangedCallback();
121 
122  MCallbackId m_attributeChanged = 0;
123 
124  static TfTokenVector m_rendererPluginsTokens;
125  static MStringArray m_rendererPluginsNames;
126 
127  //--------------------------------------------------------------------------------------------------------------------
129  //--------------------------------------------------------------------------------------------------------------------
130 
131  void postConstructor() override;
132 
133  bool setInternalValueInContext(const MPlug& plug, const MDataHandle& dataHandle, MDGContext& ctx) override;
134 
135  bool getInternalValueInContext(const MPlug& plug, MDataHandle& dataHandle, MDGContext& ctx) override;
136 
137 };
138 
139 } // nodes
140 } // usdmaya
141 } // AL
142 //----------------------------------------------------------------------------------------------------------------------
143 
AL_MAYA_DECLARE_NODE()
Type Info & Registration.
void onRendererChanged()
Methods to handle renderer plugin.
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
static MObject findOrCreateNode(MDGModifier *dgmod=nullptr, bool *wasCreated=nullptr)
Either find the already-existing non-referenced RendererManager node in the scene, or make one.
int getRendererPluginIndex() const
Get current renderer plugin index.
The layer manager node handles serialization and deserialization of all layers used by all ProxyShape...
Definition: RendererManager.h:43
bool setRendererPlugin(const MString &pluginName)
Set current renderer plugin based on provided name.
AL_DECL_ATTRIBUTE(rendererPluginName)
Type Info & Registration.
static const MStringArray & getRendererPluginList()
Get list of available Hydra renderer plugin names.
Definition: RendererManager.h:96
static RendererManager * findOrCreateManager(MDGModifier *dgmod=nullptr, bool *wasCreated=nullptr)
Either find the already-existing non-referenced RendererManager in the scene, or make one...
static MObject findNode()
Find the already-existing non-referenced RendererManager node in the scene, or return a null MObject...
static RendererManager * findManager()
Find the already-existing non-referenced RendererManager node in the scene, or return a nullptr...
void changeRendererPlugin(ProxyShape *proxy, bool creation=false)
Change current renderer plugin for provided ProxyShape.
RendererManager()
ctor
Definition: RendererManager.h:50