Added min/max parameters to clamp range of movement. These are
actually very powerful when combined with factor and offset -- for example, on the C310 model the nose wheel can now retract completely before the doors start closing.
This commit is contained in:
parent
173251885b
commit
00738f22f7
2 changed files with 21 additions and 1 deletions
|
@ -231,6 +231,18 @@ FGAircraftModel::read_animation (const string &object_name,
|
||||||
|
|
||||||
animation.position = node->getFloatValue("initial-position", 0);
|
animation.position = node->getFloatValue("initial-position", 0);
|
||||||
animation.offset = node->getFloatValue("offset", 0);
|
animation.offset = node->getFloatValue("offset", 0);
|
||||||
|
if (node->hasValue("min")) {
|
||||||
|
animation.has_min = true;
|
||||||
|
animation.min = node->getFloatValue("min");
|
||||||
|
} else {
|
||||||
|
animation.has_min = false;
|
||||||
|
}
|
||||||
|
if (node->hasValue("max")) {
|
||||||
|
animation.has_max = true;
|
||||||
|
animation.max = node->getFloatValue("max");
|
||||||
|
} else {
|
||||||
|
animation.has_max = false;
|
||||||
|
}
|
||||||
animation.factor = node->getFloatValue("factor", 1);
|
animation.factor = node->getFloatValue("factor", 1);
|
||||||
|
|
||||||
// Get the center and axis
|
// Get the center and axis
|
||||||
|
@ -238,7 +250,7 @@ FGAircraftModel::read_animation (const string &object_name,
|
||||||
animation.center[1] = node->getFloatValue("center/y-m", 0);
|
animation.center[1] = node->getFloatValue("center/y-m", 0);
|
||||||
animation.center[2] = node->getFloatValue("center/z-m", 0);
|
animation.center[2] = node->getFloatValue("center/z-m", 0);
|
||||||
animation.axis[0] = node->getFloatValue("axis/x", 0);
|
animation.axis[0] = node->getFloatValue("axis/x", 0);
|
||||||
animation.axis[1] = node->getFloatValue("axis/y", 1);
|
animation.axis[1] = node->getFloatValue("axis/y", 0);
|
||||||
animation.axis[2] = node->getFloatValue("axis/z", 0);
|
animation.axis[2] = node->getFloatValue("axis/z", 0);
|
||||||
|
|
||||||
sgNormalizeVec3(animation.axis);
|
sgNormalizeVec3(animation.axis);
|
||||||
|
@ -264,6 +276,10 @@ FGAircraftModel::do_animation (Animation &animation, long elapsed_ms)
|
||||||
animation.position = ((animation.prop->getFloatValue()
|
animation.position = ((animation.prop->getFloatValue()
|
||||||
+ animation.offset)
|
+ animation.offset)
|
||||||
* animation.factor);
|
* animation.factor);
|
||||||
|
if (animation.has_min && animation.position < animation.min)
|
||||||
|
animation.position = animation.min;
|
||||||
|
if (animation.has_max && animation.position > animation.max)
|
||||||
|
animation.position = animation.max;
|
||||||
animation.setRotation();
|
animation.setRotation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,10 @@ private:
|
||||||
float factor;
|
float factor;
|
||||||
float offset;
|
float offset;
|
||||||
float position;
|
float position;
|
||||||
|
bool has_min;
|
||||||
|
float min;
|
||||||
|
bool has_max;
|
||||||
|
float max;
|
||||||
sgVec3 center;
|
sgVec3 center;
|
||||||
sgVec3 axis;
|
sgVec3 axis;
|
||||||
void setRotation ();
|
void setRotation ();
|
||||||
|
|
Loading…
Add table
Reference in a new issue