#include "common.h" #include "Material.h" namespace GtpVisibilityPreprocessor { Material RandomMaterial() { float a = 0.1f; float b = 0.9f; Material m; m.mDiffuseColor = RandomColor(a, b); return m; } RgbColor RandomColor(const float a, const float b) { return RgbColor(a + Random(b), a + Random(b), a + Random(b)); } RgbColor RainbowColorMapping(const float _value) { RgbColor color; float value = 1.0f - _value; #define MAX_COLOR_VALUE 1.0f int band = (int)(value*4.0f); value = value - band; switch (band) { case 0: color.r = MAX_COLOR_VALUE; color.g = value*MAX_COLOR_VALUE; color.b = 0.0f; break; case 1: color.r = (1.0f - value)*MAX_COLOR_VALUE;; color.g = MAX_COLOR_VALUE; color.b = 0.0f; break; case 2: color.r = 0.0f; color.g = MAX_COLOR_VALUE; color.b = value*MAX_COLOR_VALUE; break; case 3: color.r = 0.0f; color.g = (1.0f - value)*MAX_COLOR_VALUE;; color.b = MAX_COLOR_VALUE; break; default: color.r = value*MAX_COLOR_VALUE; color.g = 0.0f; color.b = MAX_COLOR_VALUE; break; } return color; } RgbColor GreenRedColorMap(const float value) { RgbColor color; #define MAX_COLOR_VALUE 1.0f color.r = MAX_COLOR_VALUE*value; color.g = MAX_COLOR_VALUE*(1.0f - value); color.b = 0.0f; return color; } }