Revision 2515,
1.5 KB
checked in by bittner, 18 years ago
(diff) |
update after long time
|
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 |
|
---|
[2515] | 35 |
|
---|
| 36 | float value = 4.0f*(1.0f - _value);
|
---|
[2148] | 37 |
|
---|
[2515] | 38 | if (value < 0.0f)
|
---|
| 39 | value = 0.0f;
|
---|
| 40 | else
|
---|
| 41 | if (value > 4.0f)
|
---|
| 42 | value = 4.0f;
|
---|
| 43 |
|
---|
[2148] | 44 | #define MAX_COLOR_VALUE 1.0f
|
---|
[2515] | 45 |
|
---|
| 46 | int band = (int)(value);
|
---|
[2148] | 47 |
|
---|
[2515] | 48 | value -= band;
|
---|
| 49 |
|
---|
[2173] | 50 | switch (band) {
|
---|
[2148] | 51 | case 0:
|
---|
| 52 | color.r = MAX_COLOR_VALUE;
|
---|
| 53 | color.g = value*MAX_COLOR_VALUE;
|
---|
| 54 | color.b = 0.0f;
|
---|
| 55 | break;
|
---|
| 56 | case 1:
|
---|
| 57 | color.r = (1.0f - value)*MAX_COLOR_VALUE;;
|
---|
| 58 | color.g = MAX_COLOR_VALUE;
|
---|
| 59 | color.b = 0.0f;
|
---|
| 60 | break;
|
---|
| 61 | case 2:
|
---|
| 62 | color.r = 0.0f;
|
---|
| 63 | color.g = MAX_COLOR_VALUE;
|
---|
| 64 | color.b = value*MAX_COLOR_VALUE;
|
---|
| 65 | break;
|
---|
| 66 | case 3:
|
---|
| 67 | color.r = 0.0f;
|
---|
| 68 | color.g = (1.0f - value)*MAX_COLOR_VALUE;;
|
---|
| 69 | color.b = MAX_COLOR_VALUE;
|
---|
| 70 | break;
|
---|
| 71 | default:
|
---|
| 72 | color.r = value*MAX_COLOR_VALUE;
|
---|
| 73 | color.g = 0.0f;
|
---|
| 74 | color.b = MAX_COLOR_VALUE;
|
---|
| 75 | break;
|
---|
| 76 | }
|
---|
| 77 | return color;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | RgbColor
|
---|
| 81 | GreenRedColorMap(const float value)
|
---|
| 82 | {
|
---|
| 83 | RgbColor color;
|
---|
| 84 |
|
---|
| 85 | #define MAX_COLOR_VALUE 1.0f
|
---|
| 86 |
|
---|
| 87 | color.r = MAX_COLOR_VALUE*value;
|
---|
| 88 | color.g = MAX_COLOR_VALUE*(1.0f - value);
|
---|
| 89 | color.b = 0.0f;
|
---|
| 90 |
|
---|
| 91 | return color;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.