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 
40 /// Returns the SdfValueTypeName string best corresponding to the UT type.
41 template<typename UT_VALUE_TYPE>
42 HUSD_API const char *
44 
45 /// Sets the given @p attribute to the given @p value.
46 template<typename UT_VALUE_TYPE>
47 HUSD_API bool
49  const UT_VALUE_TYPE &value,
50  const UsdTimeCode &timecode,
51  bool clear_existing = true);
52 
53 /// Sets the given @p attribute to the value of a given @p parm.
54 /// @note HUSD_TimeCode allows evaluating a parameter at a given frame
55 /// while authoring an attribute value at the default time code.
56 HUSD_API bool
58  const PRM_Parm &parm,
59  const HUSD_TimeCode &timecode);
60 
61 HUSD_API bool
63  const UsdAttribute &attribute,
64  const UsdTimeCode &timecode,
65  bool save_for_undo = false);
66 
67 HUSD_API bool
69  const UsdRelationship &relationship,
70  bool save_for_undo = false);
71 
72 /// Gets the @p value of the given @p attribute at specified @p timecode.
73 template<typename UT_VALUE_TYPE>
74 HUSD_API bool
75 HUSDgetAttribute(const UsdAttribute &attribute, UT_VALUE_TYPE &value,
76  const UsdTimeCode &timecode);
77 
78 template<typename UT_VALUE_TYPE>
79 HUSD_API bool
81  UT_VALUE_TYPE &value);
82 
83 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
84 template<typename UT_VALUE_TYPE>
85 HUSD_API bool
86 HUSDsetMetadata(const UsdObject &object, const TfToken &name,
87  const UT_VALUE_TYPE &value);
88 
89 /// Gets obj's metadata given its name (eg, "active" or "customData:foo:bar").
90 template<typename UT_VALUE_TYPE>
91 HUSD_API bool
92 HUSDgetMetadata(const UsdObject &object, const TfToken &name,
93  UT_VALUE_TYPE &value);
94 
95 HUSD_API bool
96 HUSDclearMetadata(const UsdObject &object, const TfToken &name);
97 
98 /// Metadata utilities
99 HUSD_API bool HUSDhasMetadata(const UsdObject &object, const TfToken &name);
100 HUSD_API bool HUSDisArrayMetadata(const UsdObject &object, const TfToken &name);
102  const TfToken &name);
103 
104 /// Fetch custom data.
105 template<typename UT_VALUE_TYPE>
106 HUSD_API bool HUSDgetCustomData(const UsdObject &object, const TfToken &name,
107  UT_VALUE_TYPE &value);
108 
109 /// Fetch asset info.
110 template<typename UT_VALUE_TYPE>
111 HUSD_API bool HUSDgetAssetInfo(const UsdObject &object, const TfToken &name,
112  UT_VALUE_TYPE &value);
113 
114 /// Conversion function between VtValue and UT_* value objects.
115 template<typename UT_VALUE_TYPE>
116 HUSD_API bool
117 HUSDgetValue( const VtValue &vt_value, UT_VALUE_TYPE &ut_value );
118 
119 /// Conversion function between from UT_* value objects and a VtValue with
120 /// a matching GfValue inside.
121 template<typename UT_VALUE_TYPE>
123 HUSDgetVtValue( const UT_VALUE_TYPE &ut_value );
124 
125 
126 /// Returns the best suited Usd attribute type given the Houdini parameter.
128  const PI_EditScriptedParm &parm );
129 
130 /// Returns the value of the best suited Usd type given the Houdini parameter.
132 HUSDgetShaderParmValue( const PRM_Parm &parm, const HUSD_TimeCode &timecode);
135 
136 /// Returns the type of a shader input attribute given the VOP node input.
138  const PRM_Parm &parm );
140  const VOP_Node &vop, int input_idx,
141  const PRM_Parm *parm_hint = nullptr );
143  const VOP_Node &vop, int output_idx,
144  const PRM_Parm *parm_hint = nullptr );
146 
147 
149 
150 #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 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:1441
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 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:167
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)