All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shadingModeImporter.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_IMPORTER_H
25 #define PXRUSDMAYA_SHADING_MODE_IMPORTER_H
26 
28 
29 #include "usdMaya/api.h"
31 
32 #include "pxr/pxr.h"
33 
34 #include "pxr/base/tf/staticTokens.h"
35 #include "pxr/base/tf/token.h"
36 
37 #include "pxr/usd/sdf/path.h"
38 #include "pxr/usd/usd/prim.h"
39 #include "pxr/usd/usdGeom/gprim.h"
40 #include "pxr/usd/usdShade/material.h"
41 
42 #include <maya/MObject.h>
43 
44 #include <functional>
45 
46 
47 PXR_NAMESPACE_OPEN_SCOPE
48 
49 
50 #define PXRUSDMAYA_SHADING_MODE_IMPORTER_TOKENS \
51  ((MayaMaterialNamespace, "USD_Materials"))
52 
53 TF_DECLARE_PUBLIC_TOKENS(UsdMayaShadingModeImporterTokens,
54  PXRUSDMAYA_API,
55  PXRUSDMAYA_SHADING_MODE_IMPORTER_TOKENS);
56 
57 
58 class UsdMayaShadingModeImportContext
59 {
60 public:
61 
62  const UsdShadeMaterial& GetShadeMaterial() const { return _shadeMaterial; }
63  const UsdGeomGprim& GetBoundPrim() const { return _boundPrim; }
64 
65  UsdMayaShadingModeImportContext(
66  const UsdShadeMaterial& shadeMaterial,
67  const UsdGeomGprim& boundPrim,
68  UsdMayaPrimReaderContext* context) :
69  _shadeMaterial(shadeMaterial),
70  _boundPrim(boundPrim),
71  _context(context),
72  _surfaceShaderPlugName("surfaceShader"),
73  _volumeShaderPlugName("volumeShader"),
74  _displacementShaderPlugName("displacementShader")
75  {
76  }
77 
86 
90  PXRUSDMAYA_API
91  bool GetCreatedObject(const UsdPrim& prim, MObject* obj) const;
92 
97  PXRUSDMAYA_API
98  MObject AddCreatedObject(const UsdPrim& prim, const MObject& obj);
99 
104  PXRUSDMAYA_API
105  MObject AddCreatedObject(const SdfPath& path, const MObject& obj);
107 
113  PXRUSDMAYA_API
114  MObject CreateShadingEngine() const;
115 
122  PXRUSDMAYA_API
123  TfToken GetShadingEngineName() const;
124 
125  PXRUSDMAYA_API
126  TfToken GetSurfaceShaderPlugName() const;
127  PXRUSDMAYA_API
128  TfToken GetVolumeShaderPlugName() const;
129  PXRUSDMAYA_API
130  TfToken GetDisplacementShaderPlugName() const;
131 
137  PXRUSDMAYA_API
138  void SetShadingEngineName(const TfToken& shadingEngineName);
139 
140  PXRUSDMAYA_API
141  void SetSurfaceShaderPlugName(const TfToken& surfaceShaderPlugName);
142  PXRUSDMAYA_API
143  void SetVolumeShaderPlugName(const TfToken& volumeShaderPlugName);
144  PXRUSDMAYA_API
145  void SetDisplacementShaderPlugName(const TfToken& displacementShaderPlugName);
146 
147 private:
148  const UsdShadeMaterial& _shadeMaterial;
149  const UsdGeomGprim& _boundPrim;
150  UsdMayaPrimReaderContext* _context;
151 
152  TfToken _shadingEngineName;
153 
154  TfToken _surfaceShaderPlugName;
155  TfToken _volumeShaderPlugName;
156  TfToken _displacementShaderPlugName;
157 };
158 typedef std::function< MObject (UsdMayaShadingModeImportContext*) > UsdMayaShadingModeImporter;
159 
160 
161 PXR_NAMESPACE_CLOSE_SCOPE
162 
163 
164 #endif
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
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
Base class for all geometric primitives.
Definition: gprim.h:66
A Material provides a container into which multiple &quot;render targets&quot; can add data that defines a &quot;sha...
Definition: material.h:111
This class provides an interface for reader plugins to communicate state back to the core usd maya lo...