All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
translatorUtil.h
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_TRANSLATOR_UTIL_H
25 #define PXRUSDMAYA_TRANSLATOR_UTIL_H
26 
27 #include "pxr/pxr.h"
28 #include "usdMaya/api.h"
29 #include "usdMaya/primReaderArgs.h"
31 
32 #include "pxr/usd/usd/prim.h"
33 
34 #include <maya/MObject.h>
35 #include <maya/MString.h>
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 enum class UsdMayaShadingNodeType {
40  NonShading,
41  Light,
42  PostProcess,
43  Rendering,
44  Shader,
45  Texture,
46  Utility
47 };
48 
51 {
58  PXRUSDMAYA_API
59  static bool
61  const UsdPrim& usdPrim,
62  MObject& parentNode,
63  const UsdMayaPrimReaderArgs& args,
64  UsdMayaPrimReaderContext* context,
65  MStatus* status,
66  MObject* mayaNodeObj);
67 
75  PXRUSDMAYA_API
76  static bool
78  const UsdPrim& usdPrim,
79  MObject& parentNode,
80  bool importTypeName,
81  const UsdMayaPrimReaderArgs& args,
82  UsdMayaPrimReaderContext* context,
83  MStatus* status,
84  MObject* mayaNodeObj);
85 
89  PXRUSDMAYA_API
90  static bool
91  CreateNode(
92  const UsdPrim& usdPrim,
93  const MString& nodeTypeName,
94  MObject& parentNode,
95  UsdMayaPrimReaderContext* context,
96  MStatus* status,
97  MObject* mayaNodeObj);
98 
102  PXRUSDMAYA_API
103  static bool
104  CreateNode(
105  const SdfPath& usdPath,
106  const MString& nodeTypeName,
107  MObject& parentNode,
108  UsdMayaPrimReaderContext* context,
109  MStatus* status,
110  MObject* mayaNodeObj);
111 
116  PXRUSDMAYA_API
117  static bool
118  CreateNode(
119  const MString& nodeName,
120  const MString& nodeTypeName,
121  MObject& parentNode,
122  MStatus* status,
123  MObject* mayaNodeObj);
124 
137  PXRUSDMAYA_API
138  static bool
140  const MString& nodeName,
141  const MString& nodeTypeName,
142  const UsdMayaShadingNodeType shadingNodeType,
143  MStatus* status,
144  MObject* shaderObj,
145  const MObject parentNode=MObject::kNullObj);
146 
151  template <typename APISchemaType>
152  static APISchemaType GetAPISchemaForAuthoring(const UsdPrim& usdPrim)
153  {
154  if (!usdPrim.HasAPI<APISchemaType>()) {
155  return APISchemaType::Apply(usdPrim);
156  }
157 
158  return APISchemaType(usdPrim);
159  }
160 
161 };
162 
163 
164 
165 PXR_NAMESPACE_CLOSE_SCOPE
166 
167 #endif
Provides helper functions for other readers to use.
static PXRUSDMAYA_API bool CreateDummyTransformNode(const UsdPrim &usdPrim, MObject &parentNode, bool importTypeName, const UsdMayaPrimReaderArgs &args, UsdMayaPrimReaderContext *context, MStatus *status, MObject *mayaNodeObj)
Creates a &quot;dummy&quot; transform node for the given prim, where the dummy transform has all transform prop...
static PXRUSDMAYA_API bool CreateNode(const UsdPrim &usdPrim, const MString &nodeTypeName, MObject &parentNode, UsdMayaPrimReaderContext *context, MStatus *status, MObject *mayaNodeObj)
Helper to create a node for usdPrim of type nodeTypeName under parentNode.
This class holds read-only arguments that are passed into reader plugins for the usdMaya library...
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
static PXRUSDMAYA_API bool CreateTransformNode(const UsdPrim &usdPrim, MObject &parentNode, const UsdMayaPrimReaderArgs &args, UsdMayaPrimReaderContext *context, MStatus *status, MObject *mayaNodeObj)
Often when creating a prim, we want to first create a Transform node.
static APISchemaType GetAPISchemaForAuthoring(const UsdPrim &usdPrim)
Gets an API schema of the requested type for the given usdPrim.
This class provides an interface for reader plugins to communicate state back to the core usd maya lo...
static PXRUSDMAYA_API bool CreateShaderNode(const MString &nodeName, const MString &nodeTypeName, const UsdMayaShadingNodeType shadingNodeType, MStatus *status, MObject *shaderObj, const MObject parentNode=MObject::kNullObj)
Helper to create shadingNodes.
bool HasAPI(const TfToken &instanceName=TfToken()) const
Return true if the UsdPrim has had an API schema represented by the C++ class type T applied to it th...
Definition: prim.h:506