HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~SIM_ForceField() override;
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  void getForceSubclass(
53  const SIM_Object &object,
54  const UT_Vector3 &position,
55  const UT_Vector3 &velocity,
56  const UT_Vector3 &angvel,
57  const fpreal mass,
59  UT_Vector3 &torque) const override;
61  const SIM_Object &object) const override;
62 
64  const SIM_Object &object,
65  const UT_Vector3 &position,
66  const UT_Vector3 &normal,
67  const fpreal radius,
68  const UT_Vector3 &velocity,
69  const UT_Vector3 &angvel,
70  const fpreal mass,
71  UT_Vector3 &force,
72  UT_Vector3 &torque) const override;
73 
75  const SIM_Object &object,
76  const UT_Vector3 &position,
77  const UT_Vector3 &velocity,
78  const UT_Vector3 &angvel,
79  const fpreal mass,
80  UT_Matrix &dFdX,
81  UT_Matrix &dFdV) const override;
82 
83  /// We want to use area sampling if treat as wind is on.
85 
86  /// Override this to return a SIM_GuideShared so we only have to draw
87  /// our guide geometry once regardless of how many objects we are
88  /// attached to.
89  SIM_Guide *createGuideObjectSubclass() const override;
90  /// Build guide geometry by copying the points from the source geometry,
91  /// and adding lines to represent the force and torque vectors.
93  const SIM_RootData &root,
94  const SIM_Options &options,
95  const GU_DetailHandle &gdh,
96  UT_DMatrix4 *xform,
97  const SIM_Time &t) const override;
98 
99 private:
100  void createVectorGuide(GU_Detail *gdp,
101  const UT_Vector3 &pos,
102  UT_Vector3 f,
103  fpreal scale,
104  const GA_RWHandleV3 &colour_attrib,
105  const UT_Vector3 &colour) const;
106  void getAttribOffsets(const GU_Detail *gdp,
107  const char *forceattribname,
108  GA_ROHandleV3 &force_attrib,
109  const char *torqueattribname,
110  GA_ROHandleV3 &torque_attrib) const;
111  void getPositionTransform(UT_DMatrix4 &xform) const;
112  void getPositionInverseTransform(UT_DMatrix4 &ixform) const;
113 
114  static const SIM_DopDescription *getForceFieldDopDescription();
115 
118  SIM_Force,
119  "Field Force",
120  getForceFieldDopDescription());
121 
122  friend class SIM_ForceResolverField;
123 };
124 
125 #endif
126 
#define SIM_NAME_TORQUEATTRIBNAME
Definition: SIM_Names.h:204
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:50
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
#define SIM_NAME_MAXDISTANCE
Definition: SIM_Names.h:145
#define GETSET_DATA_FUNCS_S(DataName, FuncName)
SIM_API const UT_StringHolder torque
SIM_ForceSample
Definition: SIM_Force.h:49
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
#define SIM_NAME_SAMPLEMODE
Definition: SIM_Names.h:181
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:205
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
GA_API const UT_StringHolder scale
GLfloat f
Definition: glcorearb.h:1926
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:211
#define SIM_NAME_FORCESCALE
Definition: SIM_Names.h:125
GLdouble t
Definition: glad.h:2397
GA_API const UT_StringHolder mass
#define SIM_NAME_FORCEATTRIBNAME
Definition: SIM_Names.h:120
SIM_API const UT_StringHolder force
fpreal64 fpreal
Definition: SYS_Types.h:277
SIM_API const UT_StringHolder position
#define SIM_API
Definition: SIM_API.h:12
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:201
virtual SIM_Guide * createGuideObjectSubclass() const