Rev | Line | |
---|
[162] | 1 | #include "common.h"
|
---|
| 2 | #include "Material.h"
|
---|
| 3 |
|
---|
[863] | 4 | namespace GtpVisibilityPreprocessor {
|
---|
[162] | 5 |
|
---|
[860] | 6 |
|
---|
[162] | 7 | Material
|
---|
| 8 | RandomMaterial()
|
---|
| 9 | {
|
---|
| 10 | float a = 0.1f;
|
---|
| 11 | float b = 0.9f;
|
---|
| 12 |
|
---|
| 13 | Material m;
|
---|
[608] | 14 | m.mDiffuseColor = RandomColor(a, b);
|
---|
[162] | 15 |
|
---|
| 16 | return m;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
[608] | 19 |
|
---|
| 20 | RgbColor
|
---|
| 21 | RandomColor(const float a, const float b)
|
---|
| 22 | {
|
---|
| 23 | return RgbColor(a + Random(b),
|
---|
| 24 | a + Random(b),
|
---|
| 25 | a + Random(b));
|
---|
| 26 | }
|
---|
[860] | 27 |
|
---|
[2148] | 28 |
|
---|
| 29 |
|
---|
| 30 | RgbColor
|
---|
| 31 | RainbowColorMapping(const float _value)
|
---|
| 32 | {
|
---|
| 33 | RgbColor color;
|
---|
| 34 |
|
---|
| 35 | float value = 1.0f - _value;
|
---|
| 36 |
|
---|
| 37 | #define MAX_COLOR_VALUE 1.0f
|
---|
[2173] | 38 | int band = (int)(value*4.0f);
|
---|
| 39 | value = value - band;
|
---|
[2148] | 40 |
|
---|
[2173] | 41 | switch (band) {
|
---|
[2148] | 42 | case 0:
|
---|
| 43 | color.r = MAX_COLOR_VALUE;
|
---|
| 44 | color.g = value*MAX_COLOR_VALUE;
|
---|
| 45 | color.b = 0.0f;
|
---|
| 46 | break;
|
---|
| 47 | case 1:
|
---|
| 48 | color.r = (1.0f - value)*MAX_COLOR_VALUE;;
|
---|
| 49 | color.g = MAX_COLOR_VALUE;
|
---|
| 50 | color.b = 0.0f;
|
---|
| 51 | break;
|
---|
| 52 | case 2:
|
---|
| 53 | color.r = 0.0f;
|
---|
| 54 | color.g = MAX_COLOR_VALUE;
|
---|
| 55 | color.b = value*MAX_COLOR_VALUE;
|
---|
| 56 | break;
|
---|
| 57 | case 3:
|
---|
| 58 | color.r = 0.0f;
|
---|
| 59 | color.g = (1.0f - value)*MAX_COLOR_VALUE;;
|
---|
| 60 | color.b = MAX_COLOR_VALUE;
|
---|
| 61 | break;
|
---|
| 62 | default:
|
---|
| 63 | color.r = value*MAX_COLOR_VALUE;
|
---|
| 64 | color.g = 0.0f;
|
---|
| 65 | color.b = MAX_COLOR_VALUE;
|
---|
| 66 | break;
|
---|
| 67 | }
|
---|
| 68 | return color;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | RgbColor
|
---|
| 72 | GreenRedColorMap(const float value)
|
---|
| 73 | {
|
---|
| 74 | RgbColor color;
|
---|
| 75 |
|
---|
| 76 | #define MAX_COLOR_VALUE 1.0f
|
---|
| 77 |
|
---|
| 78 | color.r = MAX_COLOR_VALUE*value;
|
---|
| 79 | color.g = MAX_COLOR_VALUE*(1.0f - value);
|
---|
| 80 | color.b = 0.0f;
|
---|
| 81 |
|
---|
| 82 | return color;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.