V-ARTContributions
human.h
Go to the documentation of this file.
1 
5 #ifndef VART_HUMAN_H
6 #define VART_HUMAN_H
7 
8 #include "vart/graphicobj.h"
9 #include "vart/joint.h"
10 #include "vart/point4d.h"
11 #include "vart/sgpath.h"
12 #include "vart/callback.h"
13 #include <string>
14 #include <list>
15 #include <map>
16 
17 namespace VART {
18  class Scene;
19  class NoisyDofMover;
20  class Action;
21  class JointAction;
22  class XmlJointAction;
23  class DMModifier;
28  class Human : public GraphicObj
29  {
30  friend class StepManager;
31  public:
32  class StepManager : public VART::CallBack
33  {
34  public:
35  StepManager(Human* human);
36  virtual void Activate();
37  private:
38  Human* humanPtr;
39  bool steppingRight;
40  };
41  // PUBLIC STATIC METHODS
42  // PUBLIC METHODS
44  Human();
45  Human(VART::Human& human);
46  ~Human();
47 
48  virtual SceneNode* Copy();
49  virtual void ComputeBoundingBox();
50  virtual void TraverseDepthFirst(SNOperator* operatorPtr);
51  virtual void LocateDepthFirst(SNLocator* locatorPtr) const;
52  virtual void DrawForPicking() const;
57  bool LoadFromFile(const std::string& fileName);
58 
60  void PutIntoScene(Scene* scenePtr);
61 
62  //~ /// \brief Prints all noisy dof movers.
63  //~ void PrintMovers();
64 
66  XmlJointAction* LoadAction(const std::string& fileName);
67 
69  void ModifyActions(DMModifier& modifier);
70 
71  void ComputeStickPosition(Point4D* resultPtr);
72 
73  void AdjustPosition();
74 
75  void ComputeTransform(Transform* transPtr);
76 
77  void Move(const Point4D& offset);
78 
79  void ResetPosition();
80 
81  void RotateOnY(float radians);
82 
83  void Walk(bool status);
84 
85  bool WalkTo(const Point4D& dest, const Point4D& orientation);
86 
87  void SwapLegs();
88 
89  void StickRightFoot();
90 
91  void StickLeftFoot();
92 
94  bool ReachedDestiantion() const;
95 
96  Point4D Position() const;
97 
98  bool IsWalking() const { return isWalking; }
99 
100  void ChangeAdjustment(const Point4D& displacement);
101 
102  void ActivateBreatheAction(bool status);
103 
104  void ActivateRestAction(bool status);
105 
106  //~ void XmlPrintOn(std::ostream& os, unsigned int indent) const { Transform::XmlPrintOn(os,indent); }
107  protected:
109  void ComputeLocalStickPosition(Point4D* resultPtr);
110  //~ typedef std::map< Joint::DofID, std::list<NoisyDofMover*> > DofID2Movers;
111  //~ typedef std::map<Joint::DofID, float> DofID2Offset;
112  //~ typedef std::map< std::string, DofID2Movers > JointName2IDs;
113  // PROTECTED STATIC METHODS
114  // PROTECTED METHODS
115  virtual bool DrawInstanceOGL() const;
117  //~ void MapMoversFrom(Action& action);
118 
126  float AngleToPosition(const Point4D& pos, float* totalAngle) const;
127  // PROTECTED STATIC ATTRIBUTES
128  // PROTECTED ATTRIBUTES
130  //~ JointName2IDs dofs;
131  std::list<JointAction*> actionList;
132  Point4D rfFront; // right foot front
133  Point4D lfFront;
134  Point4D rfBack;
135  Point4D lfBack;
138  Transform position;
140  Transform adjustment;
143  Transform orientation;
144  Joint* hipJointPtr; // root node of a human
145  SGPath pathToRFoot; // from hip joint to right foot
146  SGPath pathToLFoot; // from hip joint to left foot
148  JointAction* moveLeftLegPtr;
149  JointAction* moveRightLegPtr;
150  JointAction* restPtr;
151  JointAction* breathePtr;
154  Point4D forward;
157  Point4D destination;
159  bool isWalking;
160  // Affective State
161  float anxiety;
162  float anger;
163  float joy;
164  float fear;
165  float disgust;
166  float surprise;
167  private:
168  }; // end class declaration
169 } // end namespace
170 
171 #endif
virtual void LocateDepthFirst(SNLocator *locatorPtr) const
Definition: human.cpp:170
void AdjustPosition()
Definition: human.cpp:371
SGPath pathToRFoot
Definition: human.h:145
Point4D lfFront
Definition: human.h:133
void Walk(bool status)
Definition: human.cpp:386
std::list< JointAction * > actionList
Maps joint names to its noisydofmovers.
Definition: human.h:131
void ModifyActions(DMModifier &modifier)
Modifies registered actions.
Definition: human.cpp:424
float disgust
Definition: human.h:165
XmlJointAction * LoadAction(const std::string &fileName)
Loads action from given file name.
Definition: human.cpp:328
float joy
Definition: human.h:163
virtual void DrawForPicking() const
Definition: human.cpp:179
virtual void Activate()
Definition: human.cpp:26
SGPath * pathToStickPosPtr
Definition: human.h:147
float surprise
Definition: human.h:166
Transform adjustment
A transform that makes a point on human's geometry to stick at the ground.
Definition: human.h:140
Transform position
A transform that puts the human at his position and orientation.
Definition: human.h:138
float anxiety
Definition: human.h:161
void RotateOnY(float radians)
Definition: human.cpp:284
Joint * hipJointPtr
Definition: human.h:144
virtual bool DrawInstanceOGL() const
Definition: human.cpp:246
void StickRightFoot()
Definition: human.cpp:130
Point4D rfBack
Definition: human.h:134
JointAction * moveRightLegPtr
Definition: human.h:149
Point4D destination
Definition: human.h:157
JointAction * restPtr
Definition: human.h:150
SGPath pathToLFoot
Definition: human.h:146
void ActivateBreatheAction(bool status)
Definition: human.cpp:255
Transform orientation
A transform that puts the human vertical on Y, scales him to the right size and puts his feet at Y = ...
Definition: human.h:143
float fear
Definition: human.h:164
Point4D lfBack
Definition: human.h:135
float AngleToPosition(const Point4D &pos, float *totalAngle) const
Builds its internal map of dof movers.
Definition: human.cpp:79
float anger
Definition: human.h:162
Articulated object for humanoid representation.
Definition: human.h:28
void ChangeAdjustment(const Point4D &displacement)
Definition: human.cpp:112
void StickLeftFoot()
Definition: human.cpp:146
bool IsWalking() const
Definition: human.h:98
StepManager stepManager
Definition: human.h:152
void ComputeStickPosition(Point4D *resultPtr)
Definition: human.cpp:364
virtual void ComputeBoundingBox()
Definition: human.cpp:125
void ComputeTransform(Transform *transPtr)
Definition: human.cpp:381
void SwapLegs()
Point4D Position() const
Definition: human.cpp:318
void Move(const Point4D &offset)
Definition: human.cpp:277
JointAction * breathePtr
Definition: human.h:151
bool isWalking
currently walking?
Definition: human.h:159
void ActivateRestAction(bool status)
Definition: human.cpp:266
bool LoadFromFile(const std::string &fileName)
Loads from a XML file.
Definition: human.cpp:187
virtual SceneNode * Copy()
Definition: human.cpp:119
Point4D forward
A vector that points forward on the floor plane (world coordinates)
Definition: human.h:154
void ComputeLocalStickPosition(Point4D *resultPtr)
Computes and returns the position of the right foot front.
Definition: human.cpp:356
Point4D * stickPositionPtr
Definition: human.h:136
bool WalkTo(const Point4D &dest, const Point4D &orientation)
Definition: human.cpp:415
bool ReachedDestiantion() const
Returns true if the human has reached its destination.
Definition: human.cpp:296
void ResetPosition()
Definition: human.cpp:308
JointAction * moveLeftLegPtr
Definition: human.h:148
Point4D rfFront
Definition: human.h:132
Human()
Creates an uninitialized humanoid.
Definition: human.cpp:46
void PutIntoScene(Scene *scenePtr)
Adds the humanoid to a scene.
Definition: human.cpp:323
virtual void TraverseDepthFirst(SNOperator *operatorPtr)
Definition: human.cpp:163
StepManager(Human *human)
Definition: human.cpp:21
float maxStepRotation
Maximal rotation (radians) during a single step.
Definition: human.h:156