Logo Search packages:      
Sourcecode: ktechlab version File versions

void Connector::incrementCurrentAnimation ( double  deltaTime  )  [inherited]

Increases the currentAnimationOffset according to the current flowing in the connector and deltaTime.

Definition at line 518 of file connector.cpp.

                                                          {
      // The values and equations used in this function have just been developed
      // empircally to be able to show a nice range of currents while still giving
      // a good indication of the amount of current flowing

      double I_min = 1e-4;
      double sf    = 3.0; // scaling factor

      for (unsigned i = 0; i < m_wires.size(); ++i) {
            if (!m_wires[i]) continue;

            double I = m_wires[i]->current();
            double sign  = (I > 0) ? 1 : -1;
            double I_abs = I * sign;
            double prop  = (I_abs > I_min) ? std::log(I_abs / I_min) : 0.0;

            m_currentAnimationOffset += deltaTime * sf * std::pow(prop, 1.3) * sign;
      }
}


Generated by  Doxygen 1.6.0   Back to index