#ifndef __MATERIAL_H #define __MATERIAL_H namespace CHCDemo { class Texture; class RgbColor { public: float r, g, b; RgbColor(): r(0.5f), g(0.5f), b(0.5f) { } RgbColor(float _r, float _g, float _b): r(_r), g(_g), b(_b) { } friend RgbColor RandomColor(float a = 0.0f, float b = 1.0f); // Mapping from interval 0.0-1.0 to RGB using "rainbow" color map // (range of hue from 0-240) friend RgbColor RainbowColorMapping(float value); }; // Forward declarations RgbColor RandomColor(const float a, const float b); // Mapping from interval 0.0-1.0 to RGB using "rainbow" color map // (range of hue from 0-240) RgbColor RainbowColorMapping(const float value); class Material { public: RgbColor mDiffuseColor; RgbColor mSpecularColor; RgbColor mAmbientColor; Material(); Material(int id); Material(const RgbColor &color); /** Returns unique material id. */ int GetId() const; friend Material RandomMaterial(); Texture *GetTexture() const { return mTexture; } void SetTexture(Texture *texture) { mTexture = texture; } /** Renders this material. */ void Render(); protected: /** Initialize the material with default values */ void InitMaterial(); /// unique material id int mId; /// the assciated texture Texture *mTexture; }; extern Material RandomMaterial(); } #endif