vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CollisionFilterBase.h
Go to the documentation of this file.
1 #ifndef COLLISION_FILTER_BASE_H
2 #define COLLISION_FILTER_BASE_H
3 
5 
6 #ifdef COMPILE_PHANTOM_DEVICE
7 
8 
9 #if 0
10  #define PH_LOG_WRITECOUNTER(name, value) logger.writeBMCounter(name, value)
11 #else
12  #define PH_LOG_WRITECOUNTER(name, value) {}
13 #endif
14 
15 
16 
17 namespace vreckoDP_PHANToM {
18 
19 
20 class CollisionFilterBase : public PHANToMFilter {
21 public:
22  CollisionFilterBase(const char* abName);
23  ~CollisionFilterBase() {};
24 
25  virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parameters);
26 
27  enum ForceCalcType {
28  // Probably in the order of complexity. The first ones may not support all features
29  // (such as negative distances, torque, multiple objects handling etc.)
30 
31 // This group is basically obsolete - no support for negative distances, torque or object sub-transforms (i.e. multiple held objects)
32  SimpleAverage, // average the forces
33  WeightedAverage, // average the forces, but give priority to the stronger ones
34  LargestOnly, // ONLY the largest force
35  SumAndClip, // Sum all the forces, clip to the largest one
36 // Methods below add support for negative distances and torque (which is calculated even for multiple objects),
37 // ignoring the held objects in intra-collision
38  SumNoClip, // Sum the forces, no clipping
39  SumByVoxels, // [NOT WORKING YET] (Similar to SumNoClip) Assume that the forces are generated using a VoxelGrid
40  // -> i.e. get the size of the VoxelGrid cell and calculate each force using this information
41  Envelope, // Create an envelope of the contact forces and use it to calculate the final one
42  };
43 
44  bool collisionsToForce(ForceCalcType calcType, CollisionParams *params, COLLISIONS_INFO_VECTOR *colInfo, osg::Vec3 *force, osg::Vec3 *torque, bool *bIntersection);
45  // Converts collision pairs into the force and torque.
46 
47 protected:
48  struct ForceCalcParams {
49  public:
50  float maxDistance;
51  float maxSingleForce;
52  float maxTotalForce;
53 
54  float forceScale;
55  float torqueScale;
56  };
57 
58  bool clusterizeContacts(COLLISIONS_INFO_VECTOR *colInfo);
59  string convertInt(int number);
60 
61  ForceCalcParams forceCalcParams;
62 };
63 
64 
65 }
66 
67 #endif
68 
69 #endif