All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
readUtil.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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 
26 
27 #ifndef PXRUSDMAYA_READUTIL_H
28 #define PXRUSDMAYA_READUTIL_H
29 
30 #include "usdMaya/api.h"
31 
32 #include "pxr/pxr.h"
33 #include "pxr/usd/sdf/attributeSpec.h"
34 #include "pxr/usd/usd/attribute.h"
35 
36 #include <maya/MDGModifier.h>
37 #include <maya/MFnDependencyNode.h>
38 #include <maya/MObject.h>
39 #include <maya/MPlug.h>
40 
41 #include <string>
42 
43 PXR_NAMESPACE_OPEN_SCOPE
44 
45 
48 {
51 
54  PXRUSDMAYA_API
55  static bool ReadFloat2AsUV();
56 
66  PXRUSDMAYA_API
67  static MObject FindOrCreateMayaAttr(
68  const SdfValueTypeName& typeName,
69  const SdfVariability variability,
70  MFnDependencyNode& depNode,
71  const std::string& attrName,
72  const std::string& attrNiceName = std::string());
73 
77  PXRUSDMAYA_API
78  static MObject FindOrCreateMayaAttr(
79  const SdfValueTypeName& typeName,
80  const SdfVariability variability,
81  MFnDependencyNode& depNode,
82  const std::string& attrName,
83  const std::string& attrNiceName,
84  MDGModifier& modifier);
85 
86  PXRUSDMAYA_API
87  static MObject FindOrCreateMayaAttr(
88  const TfType& type,
89  const TfToken& role,
90  const SdfVariability variability,
91  MFnDependencyNode& depNode,
92  const std::string& attrName,
93  const std::string& attrNiceName,
94  MDGModifier& modifier);
95 
100  PXRUSDMAYA_API
101  static bool SetMayaAttr(
102  MPlug& attrPlug,
103  const UsdAttribute& usdAttr);
104 
108  PXRUSDMAYA_API
109  static bool SetMayaAttr(
110  MPlug& attrPlug,
111  const VtValue& newValue);
112 
116  PXRUSDMAYA_API
117  static bool SetMayaAttr(
118  MPlug& attrPlug,
119  const VtValue& newValue,
120  MDGModifier& modifier);
121 
124  PXRUSDMAYA_API
125  static void SetMayaAttrKeyableState(
126  MPlug& attrPlug,
127  const SdfVariability variability);
128 
132  PXRUSDMAYA_API
133  static void SetMayaAttrKeyableState(
134  MPlug& attrPlug,
135  const SdfVariability variability,
136  MDGModifier& modifier);
137 
139 
142 
146  PXRUSDMAYA_API
147  static bool ReadMetadataFromPrim(
148  const TfToken::Set& includeMetadataKeys,
149  const UsdPrim& prim,
150  const MObject& mayaObject);
151 
157  PXRUSDMAYA_API
159  const TfToken::Set& includeAPINames,
160  const UsdPrim& prim,
161  const MObject& mayaObject);
162 
164 
167 
168  template <typename T>
169  static size_t ReadSchemaAttributesFromPrim(
170  const UsdPrim& prim,
171  const MObject& mayaObject,
172  const std::vector<TfToken>& attributeNames,
173  const UsdTimeCode& usdTime = UsdTimeCode::Default())
174  {
175  return ReadSchemaAttributesFromPrim(
176  prim,
177  mayaObject,
178  TfType::Find<T>(),
179  attributeNames,
180  usdTime);
181  }
182 
191  static size_t ReadSchemaAttributesFromPrim(
192  const UsdPrim& prim,
193  const MObject& mayaObject,
194  const TfType& schemaType,
195  const std::vector<TfToken>& attributeNames,
196  const UsdTimeCode& usdTime = UsdTimeCode::Default());
197 
199 };
200 
201 PXR_NAMESPACE_CLOSE_SCOPE
202 
203 #endif
static PXRUSDMAYA_API bool ReadMetadataFromPrim(const TfToken::Set &includeMetadataKeys, const UsdPrim &prim, const MObject &mayaObject)
Reads the metadata specified in includeMetadataKeys from prim, and uses adaptors to write them onto a...
static PXRUSDMAYA_API bool ReadAPISchemaAttributesFromPrim(const TfToken::Set &includeAPINames, const UsdPrim &prim, const MObject &mayaObject)
Reads the attributes from the non-excluded schemas applied to prim, and uses adaptors to write them o...
static PXRUSDMAYA_API MObject FindOrCreateMayaAttr(const SdfValueTypeName &typeName, const SdfVariability variability, MFnDependencyNode &depNode, const std::string &attrName, const std::string &attrNiceName=std::string())
Given the typeName and variability, try to create a Maya attribute on depNode with the name attrName...
Represents a value type name, i.e.
Definition: valueTypeName.h:83
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
std::set< TfToken, TfTokenFastArbitraryLessThan > Set
Predefined type for set of tokens, for when faster lookup is desired, without paying the memory or in...
Definition: token.h:185
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
static PXRUSDMAYA_API bool SetMayaAttr(MPlug &attrPlug, const UsdAttribute &usdAttr)
Sets a Maya plug using the value on a USD attribute at default time.
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:182
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
static PXRUSDMAYA_API bool ReadFloat2AsUV()
Returns whether the environment setting for reading Float2 types as UV sets is set to true...
static PXRUSDMAYA_API void SetMayaAttrKeyableState(MPlug &attrPlug, const SdfVariability variability)
Sets the plug&#39;s keyable state based on whether the variability is varying or uniform.
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for &#39;default&#39;.
Definition: timeCode.h:113
TfType represents a dynamic runtime type.
Definition: type.h:70
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
This struct contains helpers for reading USD (thus writing Maya data).
Definition: readUtil.h:47