vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConstraintDescription.h
Go to the documentation of this file.
1 #ifndef CONSTRAINT_DESCRIPTION_H
2 #define CONSTRAINT_DESCRIPTION_H
3 
4 #include <vrecko/Ability.h>
5 #include <set>
6 #include <vector>
7 #include "ConstraintArea.h"
8 
9 #include <osg/Matrix>
10 
11 using namespace vrecko;
12 
13 namespace APConstrainedMovement {
14  // Maximum distance for object snapping
15  #define CONSTRAINED_SNAPPING_DISTANCE 0.5
16  #define MAX_CONSTRAINED_SNAPPING_DISTANCE 10.0
17 
18  // Maximum distance for object rotation
19  #define CONSTRAINED_ROTATION_DISTANCE CONSTRAINED_SNAPPING_DISTANCE * 10
20 
21  typedef vector<ConstraintArea*> ConstraintAreas;
22  typedef set<int> EnvironmentObjectIDs;
23 
26  private:
27  ConstraintAreas offerAreas;
28  ConstraintAreas bindingAreas;
29  ConstraintAreas dualAreas;
30  bool justMoving;
31  bool wasTested;
32 
33  int constraintParentID;
34  EnvironmentObjectIDs constrainedChildrenIDs;
35  EnvironmentObjectIDs constrainedDualPartnerIDs;
36  EnvironmentObjectIDs freshDualPartnerIDs;
37 
38  int boundAreaCount;
39  osg::Vec3 boundAreaNormal;
40  public:
42  virtual ~ConstraintDescription();
43 
44  bool loadXMLFile(const char *xmlFile);
45  virtual bool loadXMLParameters(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pParametersNode);
46 
47  inline ConstraintAreas getOfferAreas() {return offerAreas;};
48  inline ConstraintAreas getBindingAreas() {return bindingAreas;};
49  inline ConstraintAreas getDualAreas() {return dualAreas;};
50 
51  inline bool getJustMoving() {return justMoving;};
52  inline void setJustMoving(bool justMoving) {this->justMoving = justMoving;};
53 
54  inline bool getWasTested() {return wasTested;};
55  inline void setWasTested(bool wasTested) {this->wasTested = wasTested;};
56 
57  inline int getConstraintParentID() {return constraintParentID;};
58  inline EnvironmentObjectIDs getConstrainedChildrenIDs() {return constrainedChildrenIDs;};
59  inline EnvironmentObjectIDs getConstrainedDualPartnerIDs() {return constrainedDualPartnerIDs;};
60  inline EnvironmentObjectIDs getFreshDualPartnerIDs() {return freshDualPartnerIDs;};
61  inline void clearFreshDualPartnerIDs() {freshDualPartnerIDs.clear();};
62 
63  void addConstrainedChildID(int id);
64  void removeConstrainedChildID(int id);
65  void addConstrainedDualPartnerID(int id, bool addAsFresh);
66  void removeConstrainedDualPartnerID(int id);
67  void freeFromConstraintParent();
68  void shiftAllConstrainedObjects(EnvironmentObject* eo, const osg::Matrix& transformationMatrix);
69  void processDualSplitting(EnvironmentObject* eo, osg::Vec3 splittingDirection);
70 
71  bool isConstraintParentOf(EnvironmentObject *eo);
72 
73  inline int getBoundAreaCount() {return boundAreaCount;};
74  inline osg::Vec3 getBoundAreaNormal() {return boundAreaNormal;};
75  inline void setBoundAreaCount(int boundAreaCount) {this->boundAreaCount = boundAreaCount;};
76  inline void setBoundAreaNormal(osg::Vec3 boundAreaNormal) {this->boundAreaNormal = boundAreaNormal;};
77 
78  void writeInfo();
79  protected:
80  };
81 
82 }
83 
84 #endif