All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shadingModeExporterContext.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXRUSDMAYA_SHADING_MODE_EXPORTER_CONTEXT_H
25 #define PXRUSDMAYA_SHADING_MODE_EXPORTER_CONTEXT_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "usdMaya/api.h"
31 #include "usdMaya/jobArgs.h"
32 #include "usdMaya/util.h"
34 
35 #include "pxr/base/tf/token.h"
36 #include "pxr/base/vt/types.h"
37 #include "pxr/usd/sdf/path.h"
38 #include "pxr/usd/usd/prim.h"
39 #include "pxr/usd/usd/stage.h"
40 
41 #include <maya/MObject.h>
42 #include <maya/MPlug.h>
43 
44 #include <string>
45 #include <utility>
46 #include <vector>
47 
48 
49 PXR_NAMESPACE_OPEN_SCOPE
50 
51 
52 class UsdMayaShadingModeExportContext
53 {
54 public:
55  void SetShadingEngine(const MObject& shadingEngine) {
56  _shadingEngine = shadingEngine;
57  }
58  MObject GetShadingEngine() const { return _shadingEngine; }
59 
60  const UsdStageRefPtr& GetUsdStage() const { return _stage; }
61 
62  UsdMayaWriteJobContext& GetWriteJobContext() const {
63  return _writeJobContext;
64  }
65 
66  const UsdMayaJobExportArgs& GetExportArgs() const {
67  return _writeJobContext.GetArgs();
68  }
69 
70  bool GetMergeTransformAndShape() const {
71  return GetExportArgs().mergeTransformAndShape;
72  }
73  const SdfPath& GetOverrideRootPath() const {
74  return GetExportArgs().usdModelRootOverridePath;
75  }
76  const SdfPathSet& GetBindableRoots() const {
77  return _bindableRoots;
78  }
79 
80  PXRUSDMAYA_API
81  void SetSurfaceShaderPlugName(const TfToken& surfaceShaderPlugName);
82  PXRUSDMAYA_API
83  void SetVolumeShaderPlugName(const TfToken& volumeShaderPlugName);
84  PXRUSDMAYA_API
85  void SetDisplacementShaderPlugName(const TfToken& displacementShaderPlugName);
86 
87  const UsdMayaUtil::MDagPathMap<SdfPath>& GetDagPathToUsdMap() const {
88  return _dagPathToUsdMap;
89  }
90 
91  PXRUSDMAYA_API
92  MPlug GetSurfaceShaderPlug() const;
93  PXRUSDMAYA_API
94  MObject GetSurfaceShader() const;
95  PXRUSDMAYA_API
96  MPlug GetVolumeShaderPlug() const;
97  PXRUSDMAYA_API
98  MObject GetVolumeShader() const;
99  PXRUSDMAYA_API
100  MPlug GetDisplacementShaderPlug() const;
101  PXRUSDMAYA_API
102  MObject GetDisplacementShader() const;
103 
109  typedef std::pair<SdfPath, VtIntArray> Assignment;
110 
112  typedef std::vector<Assignment> AssignmentVector;
113 
116  PXRUSDMAYA_API
117  AssignmentVector GetAssignments() const;
118 
126  PXRUSDMAYA_API
127  UsdPrim MakeStandardMaterialPrim(
128  const AssignmentVector& assignmentsToBind,
129  const std::string& name=std::string(),
130  SdfPathSet* const boundPrimPaths=nullptr) const;
131 
141  PXRUSDMAYA_API
142  std::string GetStandardAttrName(
143  const MPlug& attrPlug,
144  const bool allowMultiElementArrays) const;
145 
146  PXRUSDMAYA_API
147  UsdMayaShadingModeExportContext(
148  const MObject& shadingEngine,
149  UsdMayaWriteJobContext& writeJobContext,
150  const UsdMayaUtil::MDagPathMap<SdfPath>& dagPathToUsdMap);
151 
152 private:
153  MObject _shadingEngine;
154  const UsdStageRefPtr& _stage;
155  const UsdMayaUtil::MDagPathMap<SdfPath>& _dagPathToUsdMap;
156  UsdMayaWriteJobContext& _writeJobContext;
157  TfToken _surfaceShaderPlugName;
158  TfToken _volumeShaderPlugName;
159  TfToken _displacementShaderPlugName;
160 
163  SdfPathSet _bindableRoots;
164 };
165 
166 
167 PXR_NAMESPACE_CLOSE_SCOPE
168 
169 
170 #endif
Provides basic functionality and access to shared data for UsdMayaPrimWriters.
std::map< MDagPath, V, _CmpDag > MDagPathMap
Mapping of DAG paths to an arbitrary type.
Definition: util.h:97
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287