HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primvarUtils.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5 */
6 
7 #ifndef GUSD_PRIMVARUTILS_H
8 #define GUSD_PRIMVARUTILS_H
9 
10 #include "api.h"
11 
12 #include <GT/GT_Handles.h>
13 #include <GT/GT_Types.h>
14 #include <UT/UT_Optional.h>
15 #include <UT/UT_StringHolder.h>
16 
17 #include <pxr/base/vt/value.h>
18 #include <pxr/pxr.h>
19 #include <pxr/usd/sdf/path.h>
20 
22 
23 /// Contains the primvar's name, value, and related metadata. This can be
24 /// populated from various sources (e.g. USD or Hydra prims) to share common
25 /// code for converting primvars to GT attributes.
27 {
28  explicit operator bool() const { return !myFlattenedValue.IsEmpty(); }
29 
30  /// Path of the associated prim, used for error reporting.
32  /// The attribute name to use in Houdini (e.g. `P` rather than `points`).
34  /// The original USD name for the primvar.
36  /// Flattened value of the primvar.
38  /// Records whether the primvar was an indexed primvar.
39  bool myIsIndexed = false;
40  /// The primvar's element size.
41  int myElementSize = 1;
42  /// The GT equivalent of the primvar's interpolation mode.
44  /// The GT equivalent of the primvar's role, e.g. normal or color.
45  GT_Type myTypeInfo = GT_TYPE_NONE;
46  /// Scale to apply when translating the values to Houdini. This can be used
47  /// for converting diameter to radius, radians to degrees, etc.
49 };
50 
51 /// Converts the primvar to a GT_DataArray. The caller is responsible for
52 /// choosing how to insert it into the appropriate GT_AttributeList that it
53 /// manages.
57 
58 /// Index-pair attributes are a special case, which are represented in USD with
59 /// separate primvars for the indices and weights.
63  const GusdPrimvarInfo &indices_primvar,
64  const GusdPrimvarInfo &weights_primvar,
65  const VtTokenArray &joint_names);
66 
68 
69 #endif
GUSD_API GT_DataArrayHandle GusdConvertPrimvarsToIndexPairData(const GusdPrimvarInfo &indices_primvar, const GusdPrimvarInfo &weights_primvar, const VtTokenArray &joint_names)
VtValue myFlattenedValue
Flattened value of the primvar.
Definition: primvarUtils.h:37
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
TfToken myOrigName
The original USD name for the primvar.
Definition: primvarUtils.h:35
GT_Type
Definition: GT_Types.h:36
SdfPath myPrimPath
Path of the associated prim, used for error reporting.
Definition: primvarUtils.h:31
OutGridT const XformOp bool bool
std::optional< T > UT_Optional
Definition: UT_Optional.h:26
Definition: token.h:70
Definition: path.h:280
UT_Optional< fpreal > myValueScale
Definition: primvarUtils.h:48
GT_Owner
Definition: GT_Types.h:90
UT_StringHolder myName
The attribute name to use in Houdini (e.g. P rather than points).
Definition: primvarUtils.h:33
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
GUSD_API GT_DataArrayHandle GusdConvertPrimvarData(const GusdPrimvarInfo &primvar)
#define GUSD_API
Definition: api.h:42
Definition: value.h:89