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 in the agent's rig, which is useful
32 /// 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  {
43  };
44 
45  static GU_AgentTransformGroupPtr addGroup(const UT_StringHolder &name,
46  const GU_AgentRigConstPtr &rig);
47  static GU_AgentTransformGroupPtr addGroupFromFile(
49  const GU_AgentRigConstPtr &rig,
50  UT_StringArray &errors);
51 
52 private:
54  const GU_AgentRigConstPtr &rig, const UT_StringHolder &name,
56 
57 public:
59 
60  /// Build from a list of transform indices and weights.
61  bool construct(const UT_ExintArray &transforms,
62  const UT_FprealArray &weights, UT_StringArray &errors);
63 
64  int64 getMemoryUsage(bool inclusive) const;
65 
66  /// Name of the group.
67  const UT_StringHolder &name() const { return myName; }
68 
69  /// Returns whether the group was loaded from disk.
70  bool isFile() const { return myFileName.isstring(); }
71  /// Clear the flag marking that the group references a file on disk.
72  void clearIsFile();
73  /// Returns the file that the group was loaded from.
74  const UT_StringHolder &fileName() const
75  {
76  UT_ASSERT(isFile());
77  return myFileName;
78  }
79 
80  /// The referenced rig.
81  const GU_AgentRigConstPtr &rig() const { return myRig; }
82 
83  /// Ordered list of transform indices in the group.
84  const UT_BitArray &transforms() const { return myTransforms; }
85 
86  /// Returns the weight of the specified joint (0 is returned if the joint
87  /// is not in the transform group).
88  fpreal weight(exint i) const { return myWeights[i]; }
89 
90  /// Returns true if all joints in the group have a weight of 1.
91  bool hasTrivialWeights() const { return myHasTrivialWeights; }
92 
93  /// Save to JSON.
94  bool save(UT_JSONWriter &w) const;
95  /// Load from JSON.
96  bool load(UT_JSONParser &p);
97  /// @{
98  /// Parse the JSON file into an intermediate format, which can be used to
99  /// finish loading the group at a later time (e.g. after the rig has also
100  /// been loaded).
101  static bool load(UT_JSONParser &p, GroupData &data);
102  bool load(const GroupData &data, UT_StringArray &errors);
103  /// @}
104 
105 private:
106  UT_BitArray myTransforms;
107  UT_FprealArray myWeights;
108  bool myHasTrivialWeights;
109  GU_AgentRigConstPtr myRig;
110  UT_StringHolder myName;
111  UT_StringHolder myFileName;
112 };
113 
114 #endif
const UT_BitArray & transforms() const
Ordered list of transform indices in the group.
GT_API const UT_StringHolder filename
png_infop int transforms
Definition: png.h:2591
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
A reference counter base class for use with UT_IntrusivePtr.
png_uint_32 i
Definition: png.h:2877
long long int64
Definition: SYS_Types.h:107
bool isFile() const
Returns whether the group was loaded from disk.
const UT_StringHolder & name() const
Name of the group.
int64 exint
Definition: SYS_Types.h:116
static const UT_StringHolder theEmptyString
Wrapper around hboost::intrusive_ptr.
fpreal weight(exint i) const
#define GU_API
Definition: GU_API.h:12
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
const GU_AgentRigConstPtr & rig() const
The referenced rig.
double fpreal
Definition: SYS_Types.h:270
const UT_StringHolder & fileName() const
Returns the file that the group was loaded from.
bool hasTrivialWeights() const
Returns true if all joints in the group have a weight of 1.
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:126
Used to store the result of parsing the JSON file.