HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XUSD_AttributeUtils.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright 2019 Side Effects Software Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef __XUSD_AttributeUtils_h__
20 #define __XUSD_AttributeUtils_h__
21 
22 #include "HUSD_API.h"
23 #include <SYS/SYS_Deprecated.h>
24 #include <SYS/SYS_Types.h>
25 #include <pxr/pxr.h>
27 
28 class VOP_Node;
29 class VOP_TypeInfo;
31 class PRM_Parm;
32 class HUSD_TimeCode;
33 
35 class UsdObject;
36 class UsdAttribute;
37 class UsdRelationship;
38 class UsdTimeCode;
39 class UsdShadeInput;
40 class UsdShadeOutput;
42 
43 /// Returns the SdfValueTypeName string best corresponding to the UT type.
44 template<typename UT_VALUE_TYPE>
45 HUSD_API const char *
47 
48 /// Sets the given @p attribute to the given @p value.
49 template<typename UT_VALUE_TYPE>
50 HUSD_API bool
52  const UT_VALUE_TYPE &value,
53  const UsdTimeCode &timecode,
54  bool clear_existing = true);
55 
56 /// Sets the given @p attribute to the value of a given @p parm.
57 /// @note HUSD_TimeCode allows evaluating a parameter at a given frame
58 /// while authoring an attribute value at the default time code.
59 HUSD_API bool
61  const PRM_Parm &parm,
62  const HUSD_TimeCode &timecode);
63 
64 HUSD_API bool
66  const UsdAttribute &attribute,
67  const UsdTimeCode &timecode,
68  bool save_for_undo = false);
69 
70 HUSD_API bool
72  const UsdRelationship &relationship,
73  bool save_for_undo = false);
74 
75 /// Gets the @p value of the given @p attribute at specified @p timecode.
76 template<typename UT_VALUE_TYPE>
77 HUSD_API bool
78 HUSDgetAttribute(const UsdAttribute &attribute, UT_VALUE_TYPE &value,
79  const UsdTimeCode &timecode);
80 
81 /// Sets the parameter to specify the given source for a connection.
82 HUSD_API bool
84  const UsdShadeConnectionSourceInfo &src_info,
85  bool save_for_undo = false);
86 
87 /// Obtains the source the given destination attribute is connected to.
88 HUSD_API bool
90  UsdShadeConnectionSourceInfo &src_info_value );
91 HUSD_API bool
92 HUSDgetFirstConnectedSrc( const UsdShadeInput &shade_input,
93  UsdShadeConnectionSourceInfo &src_info_value );
94 HUSD_API bool
95 HUSDgetFirstConnectedSrc( const UsdShadeOutput &shade_output,
96  UsdShadeConnectionSourceInfo &src_info_value );
97 
98 
99 template<typename UT_VALUE_TYPE>
100 HUSD_API bool
102  UT_VALUE_TYPE &value);
103 
104 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
105 template<typename UT_VALUE_TYPE>
106 HUSD_API bool
107 HUSDsetMetadata(const UsdObject &object, const TfToken &name,
108  const UT_VALUE_TYPE &value);
109 
110 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
111 template<typename UT_VALUE_TYPE>
112 HUSD_API bool
113 HUSDgetMetadata(const UsdObject &object, const TfToken &name,
114  UT_VALUE_TYPE &value);
115 
116 HUSD_API bool
117 HUSDclearMetadata(const UsdObject &object, const TfToken &name);
118 
119 /// Metadata utilities
120 HUSD_API bool HUSDhasMetadata(const UsdObject &object, const TfToken &name);
121 HUSD_API bool HUSDisArrayMetadata(const UsdObject &object, const TfToken &name);
123  const TfToken &name);
124 
125 /// Fetch custom data.
126 template<typename UT_VALUE_TYPE>
127 HUSD_API bool HUSDgetCustomData(const UsdObject &object, const TfToken &name,
128  UT_VALUE_TYPE &value);
129 
130 /// Fetch asset info.
131 template<typename UT_VALUE_TYPE>
132 HUSD_API bool HUSDgetAssetInfo(const UsdObject &object, const TfToken &name,
133  UT_VALUE_TYPE &value);
134 
135 /// Conversion function between VtValue and UT_* value objects.
136 template<typename UT_VALUE_TYPE>
137 HUSD_API bool
138 HUSDgetValue( const VtValue &vt_value, UT_VALUE_TYPE &ut_value );
139 
140 /// Conversion function between from UT_* value objects and a VtValue with
141 /// a matching GfValue inside.
142 template<typename UT_VALUE_TYPE>
144 HUSDgetVtValue( const UT_VALUE_TYPE &ut_value );
145 
146 
147 /// Returns the best suited Usd attribute type given the Houdini parameter.
149  const PI_EditScriptedParm &parm );
150 
151 /// Returns the value of the best suited Usd type given the Houdini parameter.
153 HUSDgetShaderParmValue( const PRM_Parm &parm, const HUSD_TimeCode &timecode);
156 
157 /// Returns the type of a shader input attribute given the VOP node input.
159  const PRM_Parm &parm );
161  const VOP_Node &vop, int input_idx,
162  const PRM_Parm *parm_hint = nullptr );
164  const VOP_Node &vop, int output_idx,
165  const PRM_Parm *parm_hint = nullptr );
167 
168 
170 
171 #endif
HUSD_API bool HUSDgetValue(const VtValue &vt_value, UT_VALUE_TYPE &ut_value)
Conversion function between VtValue and UT_* value objects.
HUSD_API bool HUSDsetNodeParm(PRM_Parm &parm, const UsdAttribute &attribute, const UsdTimeCode &timecode, bool save_for_undo=false)
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_API bool HUSDgetAssetInfo(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Fetch asset info.
HUSD_API bool HUSDhasMetadata(const UsdObject &object, const TfToken &name)
Metadata utilities.
HUSD_API SdfValueTypeName HUSDgetShaderAttribSdfTypeName(const PRM_Parm &parm)
Returns the type of a shader input attribute given the VOP node input.
HUSD_API VtValue HUSDgetShaderParmValue(const PRM_Parm &parm, const HUSD_TimeCode &timecode)
Returns the value of the best suited Usd type given the Houdini parameter.
HUSD_API VOP_TypeInfo HUSDgetVopTypeInfo(SdfValueTypeName sdf_type_name)
Definition: token.h:87
HUSD_API bool HUSDisArrayMetadata(const UsdObject &object, const TfToken &name)
HUSD_API bool HUSDclearMetadata(const UsdObject &object, const TfToken &name)
HUSD_API bool HUSDsetConnectionNodeParm(PRM_Parm &parm, const UsdShadeConnectionSourceInfo &src_info, bool save_for_undo=false)
Sets the parameter to specify the given source for a connection.
HUSD_API VtValue HUSDgetVtValue(const UT_VALUE_TYPE &ut_value)
GLuint const GLchar * name
Definition: glcorearb.h:786
HUSD_API exint HUSDgetMetadataLength(const UsdObject &object, const TfToken &name)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HUSD_API VtValue HUSDgetShaderParmDefaultValue(const PRM_Parm &parm)
HUSD_API bool HUSDgetAttribute(const UsdAttribute &attribute, UT_VALUE_TYPE &value, const UsdTimeCode &timecode)
Gets the value of the given attribute at specified timecode.
HUSD_API bool HUSDsetMetadata(const UsdObject &object, const TfToken &name, const UT_VALUE_TYPE &value)
Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HUSD_API SdfValueTypeName HUSDgetShaderInputSdfTypeName(const VOP_Node &vop, int input_idx, const PRM_Parm *parm_hint=nullptr)
HUSD_API SdfValueTypeName HUSDgetAttribSdfTypeName(const PI_EditScriptedParm &parm)
Returns the best suited Usd attribute type given the Houdini parameter.
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
HUSD_API bool HUSDgetCustomData(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Fetch custom data.
Definition: core.h:1131
HUSD_API bool HUSDgetFirstConnectedSrc(const UsdAttribute &attribute, UsdShadeConnectionSourceInfo &src_info_value)
Obtains the source the given destination attribute is connected to.
HUSD_API bool HUSDgetMetadata(const UsdObject &object, const TfToken &name, UT_VALUE_TYPE &value)
Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
HUSD_API const char * HUSDgetSdfTypeName()
Returns the SdfValueTypeName string best corresponding to the UT type.
Definition: value.h:164
HUSD_API bool HUSDsetAttribute(const UsdAttribute &attribute, const UT_VALUE_TYPE &value, const UsdTimeCode &timecode, bool clear_existing=true)
Sets the given attribute to the given value.
HUSD_API bool HUSDgetAttributeSpecDefault(const SdfAttributeSpec &spec, UT_VALUE_TYPE &value)
HUSD_API SdfValueTypeName HUSDgetShaderOutputSdfTypeName(const VOP_Node &vop, int output_idx, const PRM_Parm *parm_hint=nullptr)