HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_ForceField.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 __SIM_ForceField_h__
9 #define __SIM_ForceField_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_Force.h"
13 #include "SIM_OptionsUser.h"
14 #include <UT/UT_Matrix.h>
15 #include <GA/GA_Handle.h>
16 
17 /// This is an implementation of the SIM_Force interface. This implementation
18 /// calculates the interpolated value from a point cloud with force and
19 /// torque attributes attached to it.
21  public SIM_OptionsUser
22 {
23 public:
24  /// The name of the point attribute holding the force values.
26  /// Scale the calculated force value.
28  /// The name of the point attribute holding the torque values.
30  /// Scale the calculated torque value.
32  /// Determines whether or not there is a maximum distance to check.
34  /// The maximum distance we are allowed to search for a point.
36  /// Whether to treat the force as a wind or a force.
38  /// Whether to sample by point, circle, or sphere.
40 
41 protected:
42  explicit SIM_ForceField(const SIM_DataFactory *factory);
43  virtual ~SIM_ForceField();
44 
45  /// Returns the force and torque on a point. The returned values are
46  /// exact copies of the force and torque attributes. The
47  /// getForceOnCircleSubclass() and getForceOnSphereSubclass()
48  /// functions use the default implementations which scale the point
49  /// force by the area or volume of the circle or sphere. This means
50  /// that regardless of the size of samples used to quantize an object,
51  /// the total force on the object should remain roughly constant.
52  virtual void getForceSubclass(const SIM_Object &object,
53  const UT_Vector3 &position,
54  const UT_Vector3 &velocity,
55  const UT_Vector3 &angvel,
56  const fpreal mass,
57  UT_Vector3 &force,
58  UT_Vector3 &torque) const;
59  virtual SIM_ForceResolver *getForceResolverSubclass(const SIM_Object &object) const;
60 
61  virtual void getForceOnCircleSubclass(const SIM_Object &object,
62  const UT_Vector3 &position,
63  const UT_Vector3 &normal,
64  const fpreal radius,
65  const UT_Vector3 &velocity,
66  const UT_Vector3 &angvel,
67  const fpreal mass,
68  UT_Vector3 &force,
69  UT_Vector3 &torque) const;
70 
71  virtual void getForceJacobianSubclass(const SIM_Object &object,
72  const UT_Vector3 &position,
73  const UT_Vector3 &velocity,
74  const UT_Vector3 &angvel,
75  const fpreal mass,
76  UT_Matrix &dFdX,
77  UT_Matrix &dFdV) const;
78 
79  /// We want to use area sampling if treat as wind is on.
81 
82  /// Override this to return a SIM_GuideShared so we only have to draw
83  /// our guide geometry once regardless of how many objects we are
84  /// attached to.
85  virtual SIM_Guide *createGuideObjectSubclass() const;
86  /// Build guide geometry by copying the points from the source geometry,
87  /// and adding lines to represent the force and torque vectors.
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 private:
95  void createVectorGuide(GU_Detail *gdp,
96  const UT_Vector3 &pos,
97  UT_Vector3 f,
98  fpreal scale,
99  const GA_RWHandleV3 &colour_attrib,
100  const UT_Vector3 &colour) const;
101  void getAttribOffsets(const GU_Detail *gdp,
102  const char *forceattribname,
103  GA_ROHandleV3 &force_attrib,
104  const char *torqueattribname,
105  GA_ROHandleV3 &torque_attrib) const;
106  void getPositionTransform(UT_DMatrix4 &xform) const;
107  void getPositionInverseTransform(UT_DMatrix4 &ixform) const;
108 
109  static const SIM_DopDescription *getForceFieldDopDescription();
110 
113  SIM_Force,
114  "Field Force",
115  getForceFieldDopDescription());
116 
117  friend class SIM_ForceResolverField;
118 };
119 
120 #endif
121 
#define SIM_NAME_TORQUEATTRIBNAME
Definition: SIM_Names.h:203
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 GETSET_DATA_FUNCS_B(DataName, FuncName)
#define SIM_NAME_MAXDISTANCE
Definition: SIM_Names.h:144
#define GETSET_DATA_FUNCS_S(DataName, FuncName)
SIM_ForceSample
Definition: SIM_Force.h:49
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
#define SIM_NAME_SAMPLEMODE
Definition: SIM_Names.h:180
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_TORQUESCALE
Definition: SIM_Names.h:204
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_API const UT_StringHolder scale
GLfloat f
Definition: glcorearb.h:1925
virtual void getForceOnCircleSubclass(const SIM_Object &object, const UT_Vector3 &position, const UT_Vector3 &normal, const fpreal radius, const UT_Vector3 &velocity, const UT_Vector3 &angvel, const fpreal mass, UT_Vector3 &force, UT_Vector3 &torque) const
virtual SIM_ForceSample getOptimalForceSamplingSubclass() const
virtual SIM_ForceResolver * getForceResolverSubclass(const SIM_Object &object) const
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
#define SIM_NAME_USEMAXDISTANCE
Definition: SIM_Names.h:210
#define SIM_NAME_FORCESCALE
Definition: SIM_Names.h:124
GA_API const UT_StringHolder mass
double fpreal
Definition: SYS_Types.h:263
#define SIM_NAME_FORCEATTRIBNAME
Definition: SIM_Names.h:119
#define SIM_API
Definition: SIM_API.h:10
virtual void getForceJacobianSubclass(const SIM_Object &object, const UT_Vector3 &position, const UT_Vector3 &velocity, const UT_Vector3 &angvel, const fpreal mass, UT_Matrix &dFdX, UT_Matrix &dFdV) const
#define SIM_NAME_TREATASWIND
Definition: SIM_Names.h:200
virtual SIM_Guide * createGuideObjectSubclass() const