Revision 2575,
1.5 KB
checked in by bittner, 17 years ago
(diff) |
big merge: preparation for havran ray caster, check if everything works
|
Rev | Line | |
---|
[162] | 1 | #include "common.h"
|
---|
| 2 | #include "Material.h"
|
---|
| 3 |
|
---|
[863] | 4 | namespace GtpVisibilityPreprocessor {
|
---|
[162] | 5 |
|
---|
[860] | 6 |
|
---|
[2575] | 7 | RgbColor
|
---|
| 8 | RandomColor(const float a, const float b)
|
---|
| 9 | {
|
---|
| 10 | return RgbColor(a + Random(b),
|
---|
| 11 | a + Random(b),
|
---|
| 12 | a + Random(b));
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 |
|
---|
[162] | 16 | Material
|
---|
| 17 | RandomMaterial()
|
---|
| 18 | {
|
---|
| 19 | float a = 0.1f;
|
---|
| 20 | float b = 0.9f;
|
---|
| 21 |
|
---|
| 22 | Material m;
|
---|
[608] | 23 | m.mDiffuseColor = RandomColor(a, b);
|
---|
[162] | 24 |
|
---|
| 25 | return m;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
[608] | 28 |
|
---|
[860] | 29 |
|
---|
[2148] | 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.