source: GTP/trunk/App/Demos/Vis/CHC_revisited/Material.h @ 2767

Revision 2767, 1.4 KB checked in by mattausch, 16 years ago (diff)
Line 
1#ifndef __MATERIAL_H
2#define __MATERIAL_H
3
4
5namespace CHCDemo
6{
7
8class Texture;
9
10class RgbColor
11{
12
13public:
14
15  float r, g, b;
16
17  RgbColor(): r(0.5f), g(0.5f), b(0.5f)
18  {
19  }
20
21  RgbColor(float _r, float _g, float _b): r(_r), g(_g), b(_b)
22  {
23  }
24
25  friend RgbColor
26  RandomColor(float a = 0.0f, float b = 1.0f);
27
28  // Mapping from interval 0.0-1.0 to RGB using "rainbow" color map
29  // (range of hue from 0-240)
30
31  friend RgbColor RainbowColorMapping(float value);
32 
33};
34
35
36// Forward declarations
37RgbColor RandomColor(const float a, const float b);
38
39// Mapping from interval 0.0-1.0 to RGB using "rainbow" color map
40// (range of hue from 0-240)
41RgbColor RainbowColorMapping(const float value);
42
43 
44
45class Material
46{
47public:
48
49  RgbColor mDiffuseColor;
50  RgbColor mSpecularColor;
51  RgbColor mAmbientColor;
52 
53  Material();
54 
55  Material(int id);
56
57  Material(const RgbColor &color);
58  /** Returns unique material id.
59  */
60  int GetId() const;
61
62  friend Material RandomMaterial();
63
64  Texture *GetTexture() const { return mTexture; }
65
66  void SetTexture(Texture *texture) { mTexture = texture; }
67  /** Renders this material.
68  */
69  void Render();
70
71protected:
72
73        /** Initialize the material with default values
74        */
75        void InitMaterial();
76
77        /// unique material id
78        int mId;
79        /// the assciated texture
80        Texture *mTexture;
81};
82
83
84extern Material RandomMaterial();
85
86}
87
88#endif
Note: See TracBrowser for help on using the repository browser.