HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_GEOPackedAgent.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: GT_GEOPackedAgent.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_GEOPackedAgent__
12 #define __GT_GEOPackedAgent__
13 
14 #include "GT_GEOPrimCollect.h"
15 #include "GT_GEOSupport.h"
16 #include "GT_Primitive.h"
17 #include "GT_PrimitiveTypes.h"
18 #include "GT_AgentSupport.h"
19 
20 #include <GU/GU_AgentClip.h>
21 
22 #include <UT/UT_ValArray.h>
23 #include <UT/UT_IntrusivePtr.h>
24 #include <UT/UT_NonCopyable.h>
25 #include <UT/UT_VectorTypes.h>
26 
27 #include <SYS/SYS_AtomicInt.h>
28 #include <SYS/SYS_Types.h>
29 
30 
31 class GU_PrimPacked;
32 class UT_StringRef;
33 
34 
35 /// Contains a list of agents.
37 {
38 public:
40  const char *rigname);
42  virtual ~GT_GEOPackedAgent();
43 
44  /// Main interface
45 
46  /// Number of agents in this agent list
47  int getNumAgents() const { return myPrimOffsets.entries(); }
48 
49  /// Rig this agent list represents.
50  const char *getRigName() const { return myRigName; }
51 
52  class RigElement
53  {
54  public:
55  RigElement(int idx, int pidx)
56  : bone_length(0.0), trans_idx(idx), parent_idx(pidx) {}
58  {
59  for(int i=0; i<children.entries(); i++)
60  delete children(i);
61  }
62 
64  int trans_idx;
67  };
68 
69  /// Return a list of bones corresponding to all the ones used by deforming
70  /// shapes. bone_transform_indices correspond to transforms in the rig and
71  /// bone_quats are the directions for the bone (assuming a source
72  /// orientation pointing in the -Z axis), and scaled to indicate the bone
73  /// length.
74  bool buildRig(UT_IntArray &bone_transform_indices,
75  UT_ValArray<UT_QuaternionF> &bone_quats,
76  UT_BoundingBox &rig_worst_case_bounds) const;
77 
78  /// Fetch bounding box of an agent, return false if bbox couldn't be
79  /// computed.
80  bool getBoundingBox(int agent_idx, UT_BoundingBox &box) const;
81 
82  /// Primitive IDs (GA_Index) of all agents in the agent list.
83  GT_DataArrayHandle getPrimIDs() const;
84 
85  /// Point IDs (GA_Index) of all agents in the agent list.
86  GT_DataArrayHandle getPointIDs() const;
87 
88  /// Point positions of all agents' points.
89  GT_DataArrayHandle getPointPos() const;
90 
91  /// Fetch a data array for the attribute named 'attrib_name'.
92  GT_DataArrayHandle fetchAttributeData(const UT_StringRef &attrib_name,
93  GT_Owner &attrib_list_owner) const;
94 
95  virtual bool hasDataArray(const UT_StringRef &name,
96  GT_Owner owner_scope[],
97  int num_owners,
98  GT_Storage *storage = NULL,
99  GT_Size *tuple_size = NULL) const;
100 
101  /// local transform for agent at idx. Returns false if no transform present
102  bool getTransform(int idx, UT_Matrix4D &mat) const;
103 
104  /// local transform for agent at idx.
105  bool getTransform(int idx, UT_Matrix4F &mat) const;
106 
107  /// computed main transforms for all visible agents
109  { return myAgentTransforms; }
110 
111  /// computed rig transforms for all visible agents
113  { return myAgentRigTransforms; }
114 
115  /// map GA index locations of agent prims to a flat list used by this rig
117  { return myAgentIndexMap; }
118 
119  /// list of selected agent primitives
120  GT_AgentSelectionHandle selection() const { return myAgentSelection; }
121 
122  /// list of agent primitive ids.
123  GT_AgentIDHandle primIDs() const { return myAgentPrimIDs; }
124 
125  /// List of agent colors;
126  GT_AgentColorsHandle colors() const { return myAgentColors; }
127 
128  /// Visibility information for agents.
129  GT_AgentVisibilityHandle visibility() const { return myVisibility; }
130 
131  const GT_GEOOffsetList &pointOffsets() const { return myPointOffsets; }
132  const GT_GEOOffsetList &primOffsets() const { return myPrimOffsets; }
133  const GT_GEOOffsetList &vtxOffsets() const { return myVertexOffsets; }
134 
135  void init();
136 
137  // GT Interface
138  virtual const char *className() const { return "GT_GEOPackedAgent"; }
139  virtual int getPrimitiveType() const { return GT_PRIM_AGENTS; }
140 
141  virtual int getMotionSegments() const { return 1; }
142  virtual int64 getMemoryUsage() const { return 0; }
144 
145  virtual void enlargeBounds(UT_BoundingBox boxes[],
146  int nsegments) const {}
147 
148  void append(const GU_PrimPacked *prim);
149 
150  const GU_PrimPacked *getPackedAgent(int agent_idx) const;
151 
152  /// compute transform information for those agents that are visible.
153  /// 'initial_pass' indicates a topology change where incremental updates
154  /// cannot be done.
155  void computeTransforms(bool initial_pass) const;
156 
157  void bumpTransformSerial() const { myTransformSerial++; }
158  int getTransformSerial() const { return myTransformSerial; }
159 
160 
161 private:
162 
163  GU_ConstDetailHandle myParentDetail;
164  const GU_Detail *myParentGdp;
165  UT_String myRigName;
166  GT_GEOOffsetList myPrimOffsets;
167  GT_GEOOffsetList myPointOffsets;
168  GT_GEOOffsetList myVertexOffsets;
169  UT_BoundingBox myBoundingBox;
170 
171  mutable int myTransformSerial;
172 
173  GT_AgentVisibilityHandle myVisibility;
174  GT_AgentTransformsHandle myAgentTransforms;
175  GT_AgentRigTransformsHandle myAgentRigTransforms;
176  GT_AgentIndexMapHandle myAgentIndexMap;
177  GT_AgentSelectionHandle myAgentSelection;
178  GT_AgentIDHandle myAgentPrimIDs;
179  GT_AgentColorsHandle myAgentColors;
180 };
181 
182 #endif
virtual GT_PrimitiveHandle doSoftCopy() const
GT_Storage
Definition: GT_Types.h:17
virtual bool hasDataArray(const UT_StringRef &name, GT_Owner owner_scope[], int num_owners, GT_Storage *storage=NULL, GT_Size *tuple_size=NULL) const
#define GT_API
Definition: GT_API.h:11
void bumpTransformSerial() const
GT_AgentIndexMapHandle indexMap() const
map GA index locations of agent prims to a flat list used by this rig
virtual int getMotionSegments() const
Contains a list of agents.
const GT_GEOOffsetList & pointOffsets() const
png_uint_32 i
Definition: png.h:2877
GT_AgentColorsHandle colors() const
List of agent colors;.
long long int64
Definition: SYS_Types.h:107
UT_Array< RigElement * > children
virtual int64 getMemoryUsage() const
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const
GLuint const GLchar * name
Definition: glcorearb.h:785
const char * getRigName() const
Rig this agent list represents.
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
GT_Owner
Definition: GT_Types.h:75
const GT_GEOOffsetList & vtxOffsets() const
virtual int getPrimitiveType() const
double fpreal
Definition: SYS_Types.h:270
GT_AgentRigTransformsHandle rigTransforms() const
computed rig transforms for all visible agents
int getTransformSerial() const
GT_AgentVisibilityHandle visibility() const
Visibility information for agents.
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
GT_AgentSelectionHandle selection() const
list of selected agent primitives
UT_IntrusivePtr< GT_Primitive > GT_PrimitiveHandle
Definition: GT_Handles.h:33
int64 GT_Size
Definition: GT_Types.h:112
int getNumAgents() const
Main interface.
GT_AgentIDHandle primIDs() const
list of agent primitive ids.
GT_AgentTransformsHandle agentTransforms() const
computed main transforms for all visible agents
const GT_GEOOffsetList & primOffsets() const
GLenum src
Definition: glcorearb.h:1792
virtual const char * className() const