HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_ForceVortex.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 
9 #ifndef __SIM_ForceVortex_h__
10 #define __SIM_ForceVortex_h__
11 
12 #include "SIM_API.h"
13 #include "SIM_Force.h"
14 #include "SIM_OptionsUser.h"
15 
16 #include <GA/GA_Handle.h>
17 #include <GA/GA_Types.h>
19 
20 class GU_RayIntersect;
21 class GU_MinInfo;
22 
23 /// This is an implementation of the SIM_Force interface. This implementation
24 /// calculates the interpolated value from a point cloud with force and
25 /// torque attributes attached to it.
27  public SIM_OptionsUser
28 {
29 public:
30  /// The name of the point attribute holding the radius values
31  GETSET_DATA_FUNCS_S(SIM_NAME_RADIUS, RadiusAttribName);
32  /// The name of the velocity of the orbit
33  GETSET_DATA_FUNCS_S(SIM_NAME_VELOCITY, VelocityAttribName);
34  /// Get the veloicty type
36  /// The name of the direction of the orbit
37  GETSET_DATA_FUNCS_S(SIM_NAME_DIRECTION, DirectionAttribName);
38  /// Get the direction type
40  /// The drag constant for going into orbit
42  /// The name of maximum distance we are allowed to search for a point.
43  GETSET_DATA_FUNCS_S(SIM_NAME_MAXDISTANCE, MaxDistanceAttribName);
44  /// The linear orbital density
46  /// The lift force
47  GETSET_DATA_FUNCS_S(SIM_NAME_LIFTFORCE, LiftForceAttribName);
48  /// The falloff of lift force
50  /// The lift radius multiplier
52  /// Whether to sample by point, circle, or sphere.
54 
55 protected:
56  explicit SIM_ForceVortex(const SIM_DataFactory *factory);
57  virtual ~SIM_ForceVortex();
58 
59  /// Returns the force and torque on a point. The returned values are
60  /// exact copies of the force and torque attributes. The
61  /// getForceOnCircleSubclass() and getForceOnSphereSubclass()
62  /// functions use the default implementations which scale the point
63  /// force by the area or volume of the circle or sphere. This means
64  /// that regardless of the size of samples used to quantize an object,
65  /// the total force on the object should remain roughly constant.
66  virtual void getForceSubclass(const SIM_Object &object,
67  const UT_Vector3 &position,
68  const UT_Vector3 &velocity,
69  const UT_Vector3 &angvel,
70  const fpreal mass,
71  UT_Vector3 &force,
72  UT_Vector3 &torque) const;
73  /// Returns the forces and torques on a set of points. The results
74  /// will be same as those produced by getForceSubclass, with the
75  /// exception that this method computes forces for a set of points
76  /// instead of a single point.
77  virtual bool getForceSetSubclass(const SIM_Object &object,
78  const UT_Vector3Array &positions,
79  const UT_Vector3Array &velocities,
80  const UT_Vector3Array &angvelocities,
81  const UT_FloatArray &masses,
82  UT_Vector3Array &forces,
83  UT_Vector3Array &torques) const;
84 
86 
87  virtual SIM_Guide *createGuideObjectSubclass() const;
88  virtual void buildGuideGeometrySubclass(const SIM_RootData &root,
89  const SIM_Options &options,
90  const GU_DetailHandle &gdh,
91  UT_DMatrix4 *xform,
92  const SIM_Time &t) const;
93 
94  bool shouldMultiThread() const { return true; }
95 
96 private:
97  void createCircleGuide(GU_Detail *gdp,
98  const UT_Vector3 &center,
99  const UT_Quaternion &orient,
100  fpreal rad, fpreal frad,
101  int divisions,
102  const GA_RWHandleV3 &colour_attrib,
103  const UT_Vector3 &colour) const;
104  UT_Vector3 getPolyOrbitalDirection(const GEO_Primitive *prim,
105  int i, int j) const;
106  void getPointData(const GEO_Primitive * &prim,
107  GU_RayIntersect &ray,
108  const UT_DMatrix4 &geoxform,
109  const GA_ROHandleV3 &dir_attrib,
110  const GA_ROHandleF &rad_attrib,
111  const GA_ROHandleF &maxd_attrib,
112  GA_Size ind, int defaultval,
113  GA_Offset &pt,
114  UT_Vector3 &x,
115  UT_Vector3 &dir,
116  fpreal &u,
117  fpreal &rad, fpreal &maxd,
118  UT_Quaternion &rot, fpreal hack) const;
119 
120  /// A threaded algorithm to compute forces on a set of points.
121  THREADED_METHOD6_CONST(SIM_ForceVortex, shouldMultiThread(),
122  calculateForceSet,
123  const UT_Vector3Array &, positions,
124  const UT_Vector3Array &, velocities,
125  const UT_FloatArray &, masses,
126  UT_Vector3Array &, forces,
127  UT_Vector3Array &, torques,
129  void calculateForceSetPartial(
130  const UT_Vector3Array &positions,
131  const UT_Vector3Array &velocities,
132  const UT_FloatArray &masses,
133  UT_Vector3Array &forces,
134  UT_Vector3Array &torques,
136  const UT_JobInfo &info) const;
137 
138  static const SIM_DopDescription *getForceVortexDopDescription();
139 
142  SIM_Force,
143  "Vortex Force",
144  getForceVortexDopDescription());
145 };
146 
147 #endif
148 
virtual void getForceSubclass(const SIM_Object &object, const UT_Vector3 &position, const UT_Vector3 &velocity, const UT_Vector3 &angvel, const fpreal mass, UT_Vector3 &force, UT_Vector3 &torque) const
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
#define SIM_NAME_FALLOFF
Definition: SIM_Names.h:114
#define THREADED_METHOD6_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6)
#define SIM_NAME_DIRECTION
Definition: SIM_Names.h:101
#define SIM_NAME_MAXDISTANCE
Definition: SIM_Names.h:144
#define GETSET_DATA_FUNCS_S(DataName, FuncName)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GA_API const UT_StringHolder rot
#define SIM_NAME_RADIUS
Definition: SIM_Names.h:174
SIM_ForceSample
Definition: SIM_Force.h:49
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
png_uint_32 i
Definition: png.h:2877
#define SIM_NAME_SAMPLEMODE
Definition: SIM_Names.h:180
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
virtual void buildGuideGeometrySubclass(const SIM_RootData &root, const SIM_Options &options, const GU_DetailHandle &gdh, UT_DMatrix4 *xform, const SIM_Time &t) const
#define SIM_NAME_DRAGCONSTANT
Definition: SIM_Names.h:110
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_Size GA_Offset
Definition: GA_Types.h:617
bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front)
virtual SIM_ForceSample getOptimalForceSamplingSubclass() const
#define SIM_NAME_VELOCITYTYPE
Definition: SIM_Names.h:214
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
#define SIM_NAME_DIRECTIONTYPE
Definition: SIM_Names.h:102
GA_API const UT_StringHolder orient
GA_API const UT_StringHolder mass
double fpreal
Definition: SYS_Types.h:263
bool shouldMultiThread() const
#define SIM_API
Definition: SIM_API.h:10
GLint GLenum GLint x
Definition: glcorearb.h:408
virtual bool getForceSetSubclass(const SIM_Object &object, const UT_Vector3Array &positions, const UT_Vector3Array &velocities, const UT_Vector3Array &angvelocities, const UT_FloatArray &masses, UT_Vector3Array &forces, UT_Vector3Array &torque) const
#define SIM_NAME_LIFTMULT
Definition: SIM_Names.h:142
#define const
Definition: zconf.h:214
#define SIM_NAME_DENSITY
Definition: SIM_Names.h:99
#define SIM_NAME_LIFTFORCE
Definition: SIM_Names.h:141
#define SIM_NAME_VELOCITY
Definition: SIM_Names.h:213
virtual SIM_Guide * createGuideObjectSubclass() const