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