HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_AgentDefinition.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_AgentDefinition.h (GU Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GU_AgentDefinition__
12 #define __GU_AgentDefinition__
13 
14 #include "GU_API.h"
15 #include "GU_AgentClip.h"
16 #include "GU_AgentLayer.h"
17 #include "GU_AgentRig.h"
18 #include "GU_AgentShapeLib.h"
19 #include "GU_AgentTransformGroup.h"
20 
21 #include <UT/UT_Array.h>
22 #include <UT/UT_IntrusivePtr.h>
23 #include <UT/UT_StringMap.h>
24 
27 
28 /// An agent definition contains a rig, a shape library, a set of available
29 /// clips, a set of available layers, and a set of transform groups.
30 class GU_API GU_AgentDefinition : public UT_IntrusiveRefCounter<GU_AgentDefinition>
31 {
32 public:
34  const GU_AgentShapeLibConstPtr &shapelib);
35 
36  /// Create a copy of the given agent definition, but referencing a new
37  /// version of the shape library.
38  GU_AgentDefinition(const GU_AgentDefinition &src_defn,
39  const GU_AgentShapeLibConstPtr &new_shapelib);
40 
41  int64 getMemoryUsage(bool inclusive) const;
42 
43  const GU_AgentRigConstPtr &rig() const { return myRig; }
44  const GU_AgentShapeLibConstPtr &shapeLibrary() const { return myShapeLib; }
45 
46  /// Add a layer to the agent definition. Replaces any pre-existing layer of
47  /// the same name.
48  void addLayer(const GU_AgentLayerConstPtr &layer);
49 
50  /// Return the list of layers.
52  { sortLayersIfNeeded(); return myLayers; }
53 
54  /// Get a pointer to a specfic layer. This may be a NULL pointer.
55  const GU_AgentLayer *layer(const UT_StringRef &name) const;
56 
57  /// Get a reference to the ith layer.
58  const GU_AgentLayer &layer(exint i) const
59  { sortLayersIfNeeded(); return *myLayers(i); }
60 
61  /// Return the layer count.
62  exint numLayers() const { return myLayers.size(); }
63 
64  /// Add a clip to the agent definition. Replaces any pre-existing clip of
65  /// the same name.
66  void addClip(const GU_AgentClipConstPtr &clip);
67 
68  /// Return the list of clips.
70  { sortClipsIfNeeded(); return myClips; }
71 
72  /// Get a pointer to a specfic clip. This may be a NULL pointer.
73  const GU_AgentClip *clip(const UT_StringRef &name) const;
74 
75  /// Get a reference to the ith clip.
76  const GU_AgentClip &clip(exint i) const
77  { sortClipsIfNeeded(); return *myClips(i); }
78 
79  /// Return the clip count.
80  exint numClips() const { return myClips.size(); }
81 
82  /// Add a transform group to the agent definition. Replaces any
83  /// pre-existing group of the same name.
84  void addTransformGroup(const GU_AgentTransformGroupConstPtr &group);
85 
86  /// Return the list of groups.
88  { sortTransformGroupsIfNeeded(); return myTransformGroups; }
89 
90  /// Get a pointer to a specfic group. This may be a NULL pointer.
91  const GU_AgentTransformGroup *transformGroup(const UT_StringRef &name) const;
92 
93  /// Get the index of a transform group, or -1 if it does not exist.
94  exint transformGroupIndex(const UT_StringRef &name) const;
95 
96  /// Get the default transform group, which contains all transforms in the
97  /// rig.
99  { return *myDefaultTransformGroup; }
100 
101  /// Get a reference to the ith group.
103  { sortTransformGroupsIfNeeded(); return *myTransformGroups(i); }
104 
105  /// Return the transform group count.
106  exint numTransformGroups() const { return myTransformGroups.size(); }
107 
108 private:
109  void sortLayersIfNeeded() const;
110  void sortClipsIfNeeded() const;
111  void sortTransformGroupsIfNeeded() const;
112 
113 private:
114  GU_AgentRigConstPtr myRig;
115  GU_AgentShapeLibConstPtr myShapeLib;
117  UT_StringMap<exint> myLayersIndex;
119  UT_StringMap<exint> myClipsIndex;
121  UT_StringMap<exint> myTransformGroupsIndex;
122  GU_AgentTransformGroupConstPtr myDefaultTransformGroup;
123  bool myAreLayersSorted;
124  bool myAreClipsSorted;
125  bool myAreTransformGroupsSorted;
126 };
127 
128 #endif
exint numTransformGroups() const
Return the transform group count.
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1298
const GU_AgentTransformGroup & defaultTransformGroup() const
const UT_Array< GU_AgentClipConstPtr > & clips() const
Return the list of clips.
const UT_Array< GU_AgentLayerConstPtr > & layers() const
Return the list of layers.
A reference counter base class for use with UT_IntrusivePtr.
const GU_AgentShapeLibConstPtr & shapeLibrary() const
UT_IntrusivePtr< GU_AgentDefinition > GU_AgentDefinitionPtr
png_uint_32 i
Definition: png.h:2877
exint numLayers() const
Return the layer count.
const GU_AgentRigConstPtr & rig() const
long long int64
Definition: SYS_Types.h:100
const GU_AgentLayer & layer(exint i) const
Get a reference to the ith layer.
const GU_AgentTransformGroup & transformGroup(exint i) const
Get a reference to the ith group.
int64 exint
Definition: SYS_Types.h:109
exint numClips() const
Return the clip count.
const GU_AgentClip & clip(exint i) const
Get a reference to the ith clip.
#define GU_API
Definition: GU_API.h:11
GLuint const GLchar * name
Definition: glcorearb.h:785
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
const UT_Array< GU_AgentTransformGroupConstPtr > & transformGroups() const
Return the list of groups.