| | 163 | /// Elastic function |
| | 164 | struct OutElasticFunction |
| | 165 | { |
| | 166 | inline static void getValueAt(float t, float& result) |
| | 167 | { |
| | 168 | result = pow(2.0f, -10.0f * t) * sinf((t - 0.3f / 4.0f) * (2.0f * osg::PI) / 0.3f) + 1.0f; |
| | 169 | } |
| | 170 | }; |
| | 171 | |
| | 172 | struct InElasticFunction |
| | 173 | { |
| | 174 | inline static void getValueAt(float t, float& result) |
| | 175 | { |
| | 176 | OutElasticFunction::getValueAt(1.0f - t, result); |
| | 177 | result = 1.0f - result; |
| | 178 | } |
| | 179 | }; |
| | 180 | |
| | 181 | struct InOutElasticFunction |
| | 182 | { |
| | 183 | inline static void getValueAt(float t, float& result) |
| | 184 | { |
| | 185 | t *= 2.0f; |
| | 186 | if (t < 1.0f) |
| | 187 | { |
| | 188 | t -= 1.0f; |
| | 189 | result = -0.5 * (1.0f * pow(2.0f, 10.0f * t) * sinf((t - 0.45f / 4.0f) * (2.0f * osg::PI) / 0.45f)); |
| | 190 | } |
| | 191 | else |
| | 192 | { |
| | 193 | t -= 1.0f; |
| | 194 | result = pow(2.0f, -10.0f * t) * sinf((t - 0.45f / 4.0f) * (2.0f * osg::PI) / 0.45f) * 0.5f + 1.0f; |
| | 195 | } |
| | 196 | } |
| | 197 | }; |