HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_AgentTransformGroup.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  * NAME: GU_AgentTransformGroup.h (GU Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GU_AgentTransformGroup__
12 #define __GU_AgentTransformGroup__
13 
14 #include "GU_API.h"
15 
16 #include "GU_AgentRig.h"
17 
18 #include <UT/UT_BitArray.h>
19 #include <UT/UT_IntrusivePtr.h>
20 #include <UT/UT_StringHolder.h>
21 
22 class UT_JSONParser;
23 class UT_JSONWriter;
24 
30 
31 /// Specifies a subset of the transforms (and channels) in the agent's rig,
32 /// which is useful for things such as clip blending.
34  : public UT_IntrusiveRefCounter<GU_AgentTransformGroup>
35 {
36 public:
37  /// Used to store the result of parsing the JSON file.
38  struct GroupData
39  {
44  };
45 
46  static GU_AgentTransformGroupPtr addGroup(const UT_StringHolder &name,
47  const GU_AgentRigConstPtr &rig);
48  static GU_AgentTransformGroupPtr addGroupFromFile(
50  const GU_AgentRigConstPtr &rig,
51  UT_StringArray &errors);
52  /// Create a clone of the group, referencing the specified rig.
53  /// 'copy_external_ref' should be disabled if the new group will be
54  /// further modified.
55  static GU_AgentTransformGroupPtr addGroupCopy(
57  const GU_AgentRigConstPtr &rig,
58  bool copy_external_ref);
59 
60 private:
62  const GU_AgentRigConstPtr &rig, const UT_StringHolder &name,
64 
65 public:
67 
68  /// Build from a list of transform indices & weights, and channels.
69  bool construct(const UT_ExintArray &transforms,
70  const UT_FprealArray &weights,
71  const UT_ExintArray &channels,
72  UT_StringArray &errors);
73 
74  int64 getMemoryUsage(bool inclusive) const;
75 
76  /// Name of the group.
77  const UT_StringHolder &name() const { return myName; }
78 
79  /// Returns whether the group was loaded from disk.
80  bool isFile() const { return myFileName.isstring(); }
81  /// Clear the flag marking that the group references a file on disk.
82  void clearIsFile();
83  /// Returns the file that the group was loaded from.
84  const UT_StringHolder &fileName() const
85  {
86  UT_ASSERT(isFile());
87  return myFileName;
88  }
89 
90  /// The referenced rig.
91  const GU_AgentRigConstPtr &rig() const { return myRig; }
92 
93  /// Ordered list of transform indices in the group.
94  const UT_BitArray &transforms() const { return myTransforms; }
95 
96  /// Returns the weight of the specified joint (0 is returned if the joint
97  /// is not in the transform group).
98  fpreal weight(exint i) const { return myWeights[i]; }
99 
100  /// Returns true if all joints in the group have a weight of 1.
101  bool hasTrivialWeights() const { return myHasTrivialWeights; }
102 
103  /// Ordered list of channel indices in the group.
104  const UT_BitArray &channels() const { return myChannels; }
105 
106  /// Save to JSON.
107  bool save(UT_JSONWriter &w) const;
108  /// Load from JSON.
109  bool load(UT_JSONParser &p);
110  /// @{
111  /// Parse the JSON file into an intermediate format, which can be used to
112  /// finish loading the group at a later time (e.g. after the rig has also
113  /// been loaded).
114  static bool load(UT_JSONParser &p, GroupData &data);
115  bool load(const GroupData &data, UT_StringArray &errors);
116  /// @}
117 
118 private:
119  UT_BitArray myTransforms;
120  UT_FprealArray myWeights;
121  bool myHasTrivialWeights;
122  UT_BitArray myChannels;
123 
124  GU_AgentRigConstPtr myRig;
125  UT_StringHolder myName;
126  UT_StringHolder myFileName;
127 };
128 
129 #endif
const UT_BitArray & transforms() const
Ordered list of transform indices in the group.
GT_API const UT_StringHolder filename
int64 exint
Definition: SYS_Types.h:125
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
A reference counter base class for use with UT_IntrusivePtr.
bool isFile() const
Returns whether the group was loaded from disk.
const UT_StringHolder & name() const
Name of the group.
static const UT_StringHolder theEmptyString
Wrapper around hboost::intrusive_ptr.
long long int64
Definition: SYS_Types.h:116
fpreal weight(exint i) const
#define GU_API
Definition: GU_API.h:14
GLuint const GLchar * name
Definition: glcorearb.h:786
const GU_AgentRigConstPtr & rig() const
The referenced rig.
const UT_BitArray & channels() const
Ordered list of channel indices in the group.
const UT_StringHolder & fileName() const
Returns the file that the group was loaded from.
fpreal64 fpreal
Definition: SYS_Types.h:277
bool hasTrivialWeights() const
Returns true if all joints in the group have a weight of 1.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
Used to store the result of parsing the JSON file.
Definition: format.h:895
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
GLenum src
Definition: glcorearb.h:1793