HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WIRE_SimpleDetailReader.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  */
7 
8 #ifndef __WIRE_SimpleDetailReader_h__
9 #define __WIRE_SimpleDetailReader_h__
10 
11 #include "WIRE_API.h"
12 
13 #include <GU/GU_Detail.h>
14 #include <GA/GA_Handle.h>
15 #include <GA/GA_Types.h>
16 #include <UT/UT_Quaternion.h>
17 #include <SIM/SIM_Object.h>
18 
19 // float
20 #define WIRE_SIMPLEDETAILREADER_GET_VT_F_INTERNAL(name) \
21  private: fpreal get##name##Internal(GA_Index primind, GA_Size vtx) const \
22  { \
23  const GA_Attribute *a = my##name.getAttribute(); \
24  GA_AttributeOwner owner = a->getOwner(); \
25  if (owner == GA_ATTRIB_DETAIL) \
26  return my##name.get(GA_DETAIL_OFFSET); \
27  if (primind >= myGdpConst->getNumPrimitives()) \
28  return 0; \
29  GA_Offset offset = myGdpConst->primitiveOffset(primind); \
30  if(owner == GA_ATTRIB_PRIMITIVE) \
31  return my##name.get(offset); \
32  const GEO_Primitive *prim = myGdpConst->getGEOPrimitive(offset); \
33  if (vtx >= prim->getVertexCount()) \
34  return 0; \
35  if (owner == GA_ATTRIB_VERTEX) \
36  return my##name.get(prim->getVertexOffset(vtx)); \
37  return my##name.get(prim->getPointOffset(vtx)); \
38  }
39 #define WIRE_SIMPLEDETAILREADER_GET_VT_F(name) \
40  WIRE_SIMPLEDETAILREADER_GET_VT_F_INTERNAL(name) \
41  public: fpreal get##name(GA_Index primind, GA_Size vtx) const \
42  { \
43  fpreal result = my##name##Default; \
44  if(my##name.isValid()) \
45  result *= get##name##Internal(primind, vtx); \
46  return result; \
47  }
48 
49 // int
50 #define WIRE_SIMPLEDETAILREADER_GET_VT_I(name) \
51  public: int get##name(GA_Index primind, GA_Size vtx) const \
52  { \
53  const GA_Attribute *a = my##name.getAttribute(); \
54  if (!a) \
55  return 0; \
56  GA_AttributeOwner owner = a->getOwner(); \
57  if (owner == GA_ATTRIB_DETAIL) \
58  return my##name.get(GA_DETAIL_OFFSET); \
59  if (primind >= myGdpConst->getNumPrimitives()) \
60  return 0; \
61  GA_Offset offset = myGdpConst->primitiveOffset(primind); \
62  if(owner == GA_ATTRIB_PRIMITIVE) \
63  return my##name.get(offset); \
64  const GEO_Primitive *prim = myGdpConst->getGEOPrimitive(offset); \
65  if (vtx >= prim->getVertexCount()) \
66  return 0; \
67  if (owner == GA_ATTRIB_VERTEX) \
68  return my##name.get(prim->getVertexOffset(vtx)); \
69  return my##name.get(prim->getPointOffset(vtx)); \
70  }
71 
72 #define WIRE_SIMPLEDETAILREADER_GET_PT_F(name) \
73  public: fpreal get##name(GA_Index ptind) const \
74  { \
75  fpreal retval = my##name##Default; \
76  if(my##name.isValid()) \
77  { \
78  GA_Offset offset = myGdpConst->pointOffset(ptind); \
79  if (offset != GA_INVALID_OFFSET) \
80  retval *= my##name.get(offset); \
81  } \
82  return retval; \
83  }
84 #define WIRE_SIMPLEDETAILREADER_GET_VT_B(name) \
85  WIRE_SIMPLEDETAILREADER_GET_VT_F_INTERNAL(name##F) \
86  WIRE_SIMPLEDETAILREADER_GET_VT_I(name##I) \
87  public: bool get##name(GA_Index primind, GA_Size vtx) const \
88  { \
89  if(my##name##I.isValid()) \
90  return get##name##I(primind, vtx) != 0; \
91  if(my##name##F.isValid()) \
92  return get##name##FInternal(primind, vtx) > 0.5; \
93  return false; \
94  }
95 
97 {
98 public:
99  WIRE_SimpleDetailReader(const SIM_Object &object);
101 
102  bool isValid() const { return myGdpConst; }
103 
104  const GU_Detail *getDetailConst() const { return myGdpConst; }
105 
106  const UT_DMatrix4 &getTransform() const { return myTransform; }
107 
111  WIRE_SIMPLEDETAILREADER_GET_PT_F(DynamicFriction)
112 
113  UT_Vector3 getPosition(GA_Index i) const
114  { return myGdpConst->getPos3(myGdpConst->pointOffset(i)) * myTransform; }
116  {
117  if (myVelocity.isInvalid())
118  return UT_Vector3(0, 0, 0);
119  return rowVecMult3(myVelocity.get(myGdpConst->pointOffset(i)), myTransform);
120  }
121 
122 protected:
124 
126 
128 
137 
139 };
140 
141 #endif
const UT_DMatrix4 & getTransform() const
#define WIRE_SIMPLEDETAILREADER_GET_VT_B(name)
#define WIRE_API
Definition: WIRE_API.h:10
UT_Vector3T< float > UT_Vector3
GU_DetailHandleAutoReadLock * myGdpLock
#define WIRE_SIMPLEDETAILREADER_GET_VT_F(name)
UT_Vector3 getVelocity(GA_Index i) const
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
#define WIRE_SIMPLEDETAILREADER_GET_PT_F(name)
UT_Vector3T< T > rowVecMult3(const UT_Vector3T< T > &v, const UT_Matrix4T< S > &m)
Definition: UT_Matrix4.h:1926
fpreal64 fpreal
Definition: SYS_Types.h:277
const GU_Detail * getDetailConst() const