| 34 | } |
| 35 | |
| 36 | void EffectFlicker(_zLight* zlight, F32 seconds, F32 min, F32 rnd) |
| 37 | { |
| 38 | iLight* l = &zlight->light; |
| 39 | F32* reg = zlight->reg; |
| 40 | |
| 41 | *reg -= seconds; |
| 42 | |
| 43 | if (*reg <= 0.0f) |
| 44 | { |
| 45 | *reg = (rnd * leGetRandom()); |
| 46 | *reg += min; |
| 47 | |
| 48 | l->color.r = zlight->tasset->lightColor[0] - (leGetRandom() * 0.2f + 0.1f); |
| 49 | l->color.g = zlight->tasset->lightColor[1] - (leGetRandom() * 0.2f + 0.1f); |
| 50 | l->color.b = zlight->tasset->lightColor[2] - (leGetRandom() * 0.2f + 0.1f); |
| 51 | |
| 52 | // Clamp light color RGB between 0.0 and 1.0 |
| 53 | |
| 54 | if (l->color.r > 1.0f) |
| 55 | { |
| 56 | l->color.r = 1.0f; |
| 57 | } |
| 58 | else if (l->color.r < 0.0f) |
| 59 | { |
| 60 | l->color.r = 0.0f; |
| 61 | } |
| 62 | |
| 63 | if (l->color.g > 1.0f) |
| 64 | { |
| 65 | l->color.g = 1.0f; |
| 66 | } |
| 67 | else if (l->color.g < 0.0f) |
| 68 | { |
| 69 | l->color.g = 0.0f; |
| 70 | } |
| 71 | |
| 72 | if (l->color.b > 1.0f) |
| 73 | { |
| 74 | l->color.b = 1.0f; |
| 75 | } |
| 76 | else if (l->color.b < 0.0f) |
| 77 | { |
| 78 | l->color.b = 0.0f; |
| 79 | } |
| 80 | |
| 81 | iLightSetColor(l, &l->color); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | void zLightEffectFlicker(_zLight* zlight, F32 seconds) |
| 86 | { |
no test coverage detected