12 float VART::Dof::axisSize = 0.5;
14 list<VART::Dof*> VART::Dof::instanceList;
25 axis.SetXYZW(0,0,1,0);
26 position.SetXYZW(0,0,0,1);
34 instanceList.push_back(
this);
40 description = dof.description;
43 evoluta = dof.evoluta;
45 minAngle = dof.minAngle;
46 maxAngle = dof.maxAngle;
47 currentMinAngle = dof.currentMinAngle;
48 currentMaxAngle = dof.currentMaxAngle;
49 confortMinAngle = dof.confortMinAngle;
50 confortMaxAngle = dof.confortMaxAngle;
51 rangeModifier = dof.rangeModifier;
52 currentPosition = dof.currentPosition;
53 restPosition = dof.restPosition;
54 ownerJoint = dof.ownerJoint;
55 instanceList.push_back(
this);
66 currentMinAngle = min;
68 currentMaxAngle = max;
69 currentPosition = (0-min)/(max-min);
72 instanceList.push_back(
this);
78 list<VART::Dof*>::iterator iter = find(instanceList.begin(), instanceList.end(),
this);
79 instanceList.erase(iter);
84 description = dof.description;
87 evoluta = dof.evoluta;
89 minAngle = dof.minAngle;
90 maxAngle = dof.maxAngle;
91 currentMinAngle = dof.currentMinAngle;
92 currentMaxAngle = dof.currentMaxAngle;
93 confortMinAngle = dof.confortMinAngle;
94 confortMaxAngle = dof.confortMaxAngle;
95 rangeModifier = dof.rangeModifier;
96 currentPosition = dof.currentPosition;
97 restPosition = dof.restPosition;
98 ownerJoint = dof.ownerJoint;
107 currentMinAngle = min;
109 currentMaxAngle = max;
112 currentPosition = (0-min)/(max-min);
131 lim.GetTranslation(&result);
197 float minModif = minAngle;
199 minModif = rangeModifier->GetMin();
200 if (minAngle < minModif)
207 float maxModif = maxAngle;
209 maxModif = rangeModifier->GetMax();
210 if (maxAngle > maxModif)
217 return currentPosition;
260 if (pos > 1.0) pos = 1.0;
261 if (pos < 0.0) pos = 0.0;
264 double newAngle = currentMinAngle + pos * (currentMaxAngle - currentMinAngle);
272 evoluta->GetPoint(currentPosition, &bezierPoint);
274 center = position + bezierPoint;
278 currentPosition = pos;
279 lim.MakeRotation(center, axis, newAngle);
282 ownerJoint->MakeLim();
287 if (newPriority > priority)
291 priority = newPriority;
299 double angle = currentMinAngle + currentPosition * (currentMaxAngle - currentMinAngle);
306 evoluta->GetPoint(currentPosition, &bezierPoint);
308 center = position + bezierPoint;
313 lim.MakeRotation(center, axis, angle);
328 MoveTo(restPosition);
338 return rangeModifier;
352 double radians = acos(newTarget.
DotProduct(realState));
360 double angle = currentMinAngle + currentPosition * (currentMaxAngle - currentMinAngle);
362 double newAngle = angle + radians;
363 if (newAngle < currentMinAngle)
364 newAngle = currentMinAngle;
366 if (newAngle > currentMaxAngle)
367 newAngle = currentMaxAngle;
371 MoveTo(newAngle/(currentMaxAngle - currentMinAngle));
375 bool VART::Dof::DrawInstanceOGL()
const
378 float width = axisSize * 0.04;
384 scaledAxis = axis * axisSize;
391 axisRotation.
MakeRotation(axis, 1.57079632679489661923);
392 vertexVector[0] = position + baseVector;
393 vertexVector[1] = vertexVector[0] + scaledAxis;
396 for (
int i = 1; i < 5; ++i)
398 axisRotation.
ApplyTo(&baseVector);
399 vertexVector[2] = (position + scaledAxis) + baseVector;
400 vertexVector[3] = position + baseVector;
402 glVertex4dv(vertexVector[3].VetXYZW());
403 glVertex4dv(vertexVector[2].VetXYZW());
404 glVertex4dv(vertexVector[1].VetXYZW());
405 glVertex4dv(vertexVector[0].VetXYZW());
407 vertexVector[0] = vertexVector[3];
408 vertexVector[1] = vertexVector[2];
416 #endif // VISUAL_JOINTS
421 list<VART::Dof*>::iterator iter;
422 for (iter = instanceList.begin(); iter != instanceList.end(); ++iter)
423 (*iter)->priority = 0;
429 string indentStr(indent,
' ');
431 os << indentStr <<
"<dof description=\"" << description <<
"\">\n"
432 << indentStr <<
" <position x=\"" << position.GetX() <<
"\" y=\"" << position.GetY()
433 <<
"\" z=\"" << position.GetZ() <<
"\"/>\n"
434 << indentStr <<
" <axis x=\"" << axis.GetX() <<
"\" y=\"" << axis.GetY()
435 <<
"\" z=\"" << axis.GetZ() <<
"\"/>\n"
436 << indentStr <<
" <range min=\"" << minAngle <<
"\" max=\"" << maxAngle
437 <<
"\" rest=\"" << restPosition <<
"\"/>\n"
438 << indentStr <<
"</dof>\n";
A modifier controls how one DOF influences other DOF.
Header file for V-ART class "Dof".
void Reconfigure(const Point4D &state, const Point4D &target)
Reconfigure DOF to match a target direction.
Representation of joints.
Points and vectors using homogeneous coordinates.
void SetEvoluta(Bezier *evol)
static const Point4D & Y()
The Y vector (0,1,0,0).
A "Memory Object" is a V-ART object that has some memory allocation attributes, allowing V-ART to aut...
float GetCurrentMax() const
Point4D GetOrigin() const
static void ClearPriorities()
Resets priorities of all DOF instances.
void Normalize()
Normalizes the point/vector.
float GetRest() const
Returns DOF's rest position.
void SetAxis(Point4D vec)
void SetOwnerJoint(Joint *ow)
void SetDescription(const std::string &desc)
Header file for V-ART class "Modifier".
float GetCurrentMin() const
void SetLim(const Transform &t)
Point4D CrossProduct(const Point4D &p) const
Computes the cross product between "this" and "p".
Header file for V-ART class "Joint".
Point4D axis
Together with "position", defines the rotation axis. Relative to the parent reference system...
Modifier * GetRangeModifier()
static const Point4D & X()
The X vector (1,0,0,0).
void MoveTo(float pos)
Sets DOF's current position.
float GetCurrent() const
Gets DOF's current position.
void SetRangeModifier(Modifier *m)
const Transform & GetLim() const
double DotProduct(const Point4D &p) const
Computes the dot product between "this" and "p".
void SetMin(float min)
Sets DOF's minimal state.
Joint * GetOwnerJoint() const
void SetMax(float max)
Sets DOF's maximal state.
Point4D position
Together with "axis", defines the rotation axis. Relative to the parent reference system...
void ApplyTransformTo(Transform *ptrTrans) const
Apply internal transform to some external transform.
Degree Of Freedom - basic component of a Joint.
void XmlPrintOn(std::ostream &os, unsigned int indent) const
Outputs XML representation of the scene.
void Set(const Point4D &vec, const Point4D &pos, float min, float max)
Initializes a DOF previouly created with default constructor.
Dof & operator=(const Dof &dof)