HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GEO_AttributeCaptureRegion.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: GEO_AttributeCaptureRegion.h ( GB Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GEO_AttributeCaptureRegion__
12 #define __GEO_AttributeCaptureRegion__
13 
14 #include "GEO_API.h"
15 #include "GEO_Detail.h"
16 #include <SYS/SYS_Types.h>
17 #include <UT/UT_Matrix4.h>
18 #include <GA/GA_Handle.h>
19 #include <GA/GA_Types.h>
20 
21 class GA_ROAttributeRef;
22 class GA_RWAttributeRef;
24 
25 /// @brief Convenience class to store a bone capture region
27 {
28  inline
30  : myXform(1.0)
31  , myTCap(1)
32  , myBCap(1)
33  , myTaperX(1)
34  , myTaperZ(1)
35  {
36  }
37 
38  static const int tuple_size = 20;
39 
40  inline float * floatPtr()
41  { return reinterpret_cast<float*>(this); }
42  inline const float * floatPtr() const
43  { return reinterpret_cast<const float*>(this); }
44 
45  UT_Matrix4 myXform; // The order matters (see enum inside)
46  float myBCap; // The order matters (see enum inside)
47  float myTCap; // The order matters (see enum inside)
48  float myTaperX; // The order matters (see enum inside)
49  float myTaperZ; // The order matters (see enum inside)
50 };
51 
53 {
54 public:
57 
58  bool isValid() const;
59  int getNumEntries() const;
60  int getTupleSize() const;
61  fpreal getEntry(int i, int component) const;
62  const GA_Attribute *getAttribute() const { return myAttribute; }
63 
64 protected:
69 };
70 
71 /// @brief Interface class for tube capture attributes
72 ///
73 /// There are three types of capture regions used in Houdini
74 /// - Bone: @n
75 /// A transform, bottom/top caps and taperx/taperz
76 /// - Metaball: @n
77 /// A single transform
78 /// - Tube: @n
79 /// Bottom/Top caps, taperx/taperz and inside/outside weights
80 /// (the transform is picked up from the tube primitive)
81 ///
82 /// @warning This is being used internally by Side Effects to simplify forward
83 /// compatibility issues. The lifetime of this class is not well known and
84 /// code should not rely on any methods herein.
86 {
87 public:
88  /// @{
89  /// Get/Set bone capture region attribute data values
90  /// The object should usually be gdp.attribs().getElement()
91  static void getBoneCaptureRegion(const GA_ROAttributeRef &h,
92  int index,
93  UT_Matrix4 &xform,
94  float &tcap,
95  float &bcap,
96  float &taperx,
97  float &taperz);
99  int index,
101  {
102  getBoneCaptureRegion(h, index, s.floatPtr(),
104  }
105  static void getBoneCaptureRegion(const GA_ROAttributeRef &h,
106  int index,
107  float *array,
108  int array_size);
109 
110  static void setBoneCaptureRegion(const GA_RWAttributeRef &h,
111  int index,
112  const UT_Matrix4 &xform,
113  fpreal tcap,
114  fpreal bcap,
115  fpreal taperx,
116  fpreal taperz);
118  int index,
119  const GEO_CaptureBoneStorage &s)
120  {
121  setBoneCaptureRegion(h, index, s.floatPtr(),
123  }
124  static void setBoneCaptureRegion(const GA_RWAttributeRef &h,
125  int index,
126  const float *array,
127  int array_size);
128  static void setBoneCaptureRegion(GA_AIFIndexPairObjects *objects,
129  int index,
130  const UT_Matrix4 &xform,
131  fpreal tcap,
132  fpreal bcap,
133  fpreal taperx,
134  fpreal taperz);
136  int index,
138  {
139  setBoneCaptureRegion(objects, index, s.floatPtr(),
141  }
142  static void setBoneCaptureRegion(GA_AIFIndexPairObjects *objects,
143  int index,
144  const float *array,
145  int array_size);
146  /// @}
147 
148  /// Given an bone point capture attribute, retrieve the index pair object
149  /// and index for the capture region property. Returns NULL if the
150  /// attribute isn't of the right type.
151  /// @{
152  static GA_AIFIndexPairObjects *
153  getBoneCaptureRegionObjects(
154  const GA_RWAttributeRef &h, int &property_i);
155  static const GA_AIFIndexPairObjects *
156  getBoneCaptureRegionObjects(
157  const GA_ROAttributeRef &h, int &property_i);
158  /// @}
159 
160  /// Copy a bone capture region from one to another
161  static void copyBoneCaptureRegion(const GA_RWAttributeRef &dh,
162  int dindex,
163  const GA_ROAttributeRef &sh,
164  int sindex);
165 
166  /// Initialize bone capture region
167  static void initBoneCapture(float *array, int array_size);
168 
169  /// Initialize tube capture region
170  static void initTubeCapture(float *array, int array_size);
171 
172  /// All in one method that creates a tube capture attribute with
173  /// appropriate defaults.
174  static bool addTubeCaptureRegionAttrib(
175  GEO_Detail *gdp, GA_RWAttributeRef &h);
176 
177  /// @{
178  /// Get/Set tube capture region attribute data values
179  /// The attribute element should be the primitive
180  static void getTubeCaptureRegion(GA_Offset prim_offset,
181  const GA_ROAttributeRef &h,
182  float &bcap,
183  float &tcap,
184  float &taperx,
185  float &taperz,
186  float &in_weight,
187  float &out_weight);
188  static void setTubeCaptureRegion(GA_Offset prim_offset,
189  const GA_RWAttributeRef &h,
190  fpreal bcap,
191  fpreal tcap,
192  fpreal taperx = 1.0,
193  fpreal taperz = 1.0,
194  fpreal in_weight = 1.0,
195  fpreal out_weight = 0.0);
196  /// @}
197 
198  /// @{
199  /// Access specific tube attributes through an attribute handle
200  static fpreal getTubeBCap(const GA_ROHandleR &h, GA_Offset primoff);
201  static fpreal getTubeTCap(const GA_ROHandleR &h, GA_Offset primoff);
202  static void setTubeBCap(const GA_RWHandleR &h, GA_Offset primoff, fpreal v);
203  static void setTubeTCap(const GA_RWHandleR &h, GA_Offset primoff, fpreal v);
204  /// @}
205 
206  /// @{
207  /// Get/Set metaball capture region attribute values
208  /// The object should usually be gdp.attribs().getElement()
209  static void getMetaCaptureRegion(const GA_ROAttributeRef &h,
210  int index,
211  int propid,
212  int objset,
213  UT_Matrix4 &xform);
214  static void setMetaCaptureRegion(const GA_RWAttributeRef &h,
215  int index,
216  int prop,
217  int objset,
218  const UT_Matrix4 &xform);
219  /// @}
220 
221  /// Get the inverted metaball capture region transform
222  static void getMetaCaptureRegionInverted(const GA_ROAttributeRef &h,
223  int index,
224  int propid,
225  int objset,
226  UT_Matrix4 &xform);
227 
228  /// @{
229  /// Get/Set the anchor/rest metaball attribute
231  int index,
232  int prop,
233  int objset,
234  UT_Matrix4 &xform)
235  { getMetaCaptureRegion(h, index, prop, objset, xform); }
237  int index,
238  int prop,
239  int objset,
240  const UT_Matrix4 &xform)
241  { setMetaCaptureRegion(h, index, prop, objset, xform); }
242  /// @}
243 
244  /// @{
245  /// Return the number of floats in each type of capture region
246  static int getBoneSize() { return theBoneSize; }
247  static int getTubeSize() { return theTubeSize; }
248  static int getMetaSize() { return theMetaSize; }
249  static int getMetaRestSize() { return theMetaSize; }
250  /// @}
251 
252 private:
253  static const int theBoneSize; // Size of a bone capture region
254  static const int theTubeSize; // Size of a tube capture region
255  static const int theMetaSize; // Size of a meta capture region
256 };
257 
258 #endif
259 
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
Generic Attribute Interface class to get/set data as index pairs.
static void setBoneCaptureRegion(GA_AIFIndexPairObjects *objects, int index, GEO_CaptureBoneStorage &s)
static void setBoneCaptureRegion(const GA_RWAttributeRef &h, int index, const GEO_CaptureBoneStorage &s)
const GLdouble * v
Definition: glcorearb.h:836
Convenience class to store a bone capture region.
const GA_Attribute * getAttribute() const
png_uint_32 i
Definition: png.h:2877
const float * floatPtr() const
GA_Size GA_Offset
Definition: GA_Types.h:617
This class provides a way to manage a reference to an attribute permitting Read-Write access...
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:915
static void getMetaRestCaptureRegion(const GA_ROAttributeRef &h, int index, int prop, int objset, UT_Matrix4 &xform)
This class provides a way to manage a reference to an attribute permitting Read-Only access...
#define GEO_API
Definition: GEO_API.h:10
const GA_AIFIndexPair * myIndexPair
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:263
Interface class for tube capture attributes.
GLuint index
Definition: glcorearb.h:785
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
static void setMetaRestCaptureRegion(const GA_RWAttributeRef &h, int index, int prop, int objset, const UT_Matrix4 &xform)
static void getBoneCaptureRegion(const GA_ROAttributeRef &h, int index, GEO_CaptureBoneStorage &s)