1
0
Fork 0

Patch from Erik Hofman:

I've updated the instrument modulator code to allow tricks like the one
described by Andy. It is now possible to define <min>, <max> and
<modulator> in one layer and if <min> and/or <max> ore within the range
of the <modulator> tag, their value will be honoured.

So, if you define

  <layer>
   <min>0</min>
   <max>50</max>
   <modulator>100</modulator>
  </layer>

The value will stay at 50, until the modulator forces it back to 0.
This commit is contained in:
david 2003-03-02 14:19:24 +00:00
parent c8b8722a14
commit 45f3eb7f99
3 changed files with 10 additions and 0 deletions

View file

@ -847,11 +847,15 @@ FGInstrumentLayer::transform () const
FGPanelTransformation *t = *it; FGPanelTransformation *t = *it;
if (t->test()) { if (t->test()) {
float val = (t->node == 0 ? 0.0 : t->node->getFloatValue()); float val = (t->node == 0 ? 0.0 : t->node->getFloatValue());
if (t->has_mod)
val = fmod(val, t->mod);
if (val < t->min) { if (val < t->min) {
val = t->min; val = t->min;
} else if (val > t->max) { } else if (val > t->max) {
val = t->max; val = t->max;
} }
if(t->table==0) { if(t->table==0) {
val = val * t->factor + t->offset; val = val * t->factor + t->offset;
} else { } else {

View file

@ -44,6 +44,7 @@
#include <simgear/misc/props.hxx> #include <simgear/misc/props.hxx>
#include <simgear/timing/timestamp.hxx> #include <simgear/timing/timestamp.hxx>
#include <cmath>
#include <vector> #include <vector>
#include <map> #include <map>
#include <plib/fnt.h> #include <plib/fnt.h>
@ -303,6 +304,8 @@ public:
const SGPropertyNode * node; const SGPropertyNode * node;
float min; float min;
float max; float max;
bool has_mod;
float mod;
float factor; float factor;
float offset; float offset;
SGInterpTable * table; SGInterpTable * table;

View file

@ -251,6 +251,9 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
t->node = target; t->node = target;
t->min = node->getFloatValue("min", -9999999); t->min = node->getFloatValue("min", -9999999);
t->max = node->getFloatValue("max", 99999999); t->max = node->getFloatValue("max", 99999999);
t->has_mod = node->hasChild("modulator");
if (t->has_mod)
t->mod = node->getFloatValue("modulator");
t->factor = node->getFloatValue("scale", 1.0); t->factor = node->getFloatValue("scale", 1.0);
t->offset = node->getFloatValue("offset", 0.0); t->offset = node->getFloatValue("offset", 0.0);