V-ART
offsetmodifier.cpp
Go to the documentation of this file.
1 
5 #include "vart/offsetmodifier.h"
6 #include "vart/dof.h"
7 #include "vart/noisydofmover.h"
8 
9 #include <iostream>
10 #include <fstream>
11 using namespace std;
12 
14 {
15 }
16 
18 {
19  string jointName = moverPtr->GetTarget()->GetOwnerJoint()->GetDescription();
20  Joint2DofIDs::iterator dofIDMapIter = offsetMap.find(jointName);
21  if (dofIDMapIter != offsetMap.end())
22  {
23  const Dof* dofPtr = moverPtr->GetTarget();
24  Joint::DofID dof = dofPtr->GetOwnerJoint()->GetDofID(dofPtr);
25  DofID2Offset::iterator offsetIter = dofIDMapIter->second.find(dof);
26  if (offsetIter != dofIDMapIter->second.end())
27  moverPtr->SetOffset(weight * offsetIter->second);
28  }
29 }
30 
31 void VART::OffsetModifier::LoadFromFile(const std::string& fileName)
32 {
33  ifstream inputFile(fileName.c_str());
34  string jointName;
35  Joint::DofID dof;
36  float offset;
37  while (inputFile >> jointName >> dof >> offset)
38  offsetMap[jointName][dof] = offset;
39 }
Header file for V-ART class "Dof".
const std::string & GetDescription() const
Returns a copy of the object's description.
Definition: scenenode.h:50
Header file for V-ART class "OffsetModifier".
const Dof * GetTarget()
Returns a pointer to the target DOF.
Definition: dofmover.h:31
virtual void Modify(NoisyDofMover *moverPtr)
Noisy Controller for DOF movement.
Definition: noisydofmover.h:17
void SetOffset(float newOffset)
Set the offset attribute.
Header file for V-ART class "NoisyDofMover".
DofID GetDofID(const Dof *dofPtr) const
Returns the DofID of some member Dof.
Definition: joint.cpp:127
void LoadFromFile(const std::string &fileName)
Joint * GetOwnerJoint() const
Definition: dof.cpp:225
Degree Of Freedom - basic component of a Joint.
Definition: dof.h:28