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

Revision 2756, 1.5 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(const float _r,
22           const float _g,
23           const float _b):r(_r),g(_g),b(_b)
24  {
25  }
26
27  friend RgbColor
28  RandomColor(const float a=0.0f, const float b=1.0f);
29
30  // Mapping from interval 0.0-1.0 to RGB using "rainbow" color map
31  // (range of hue from 0-240)
32
33  friend RgbColor RainbowColorMapping(const float value);
34 
35};
36
37
38// Forward declarations
39RgbColor RandomColor(const float a, const float b);
40
41// Mapping from interval 0.0-1.0 to RGB using "rainbow" color map
42// (range of hue from 0-240)
43RgbColor RainbowColorMapping(const float value);
44
45 
46
47class Material
48{
49public:
50
51  RgbColor mDiffuseColor;
52  RgbColor mSpecularColor;
53  RgbColor mAmbientColor;
54 
55  Material();
56 
57  Material(int id);
58
59  Material(const RgbColor &color);
60  /** Returns unique material id.
61  */
62  int GetId() const;
63
64  friend Material RandomMaterial();
65
66  Texture *GetTexture() const { return mTexture; }
67
68  void SetTexture(Texture *texture) { mTexture = texture; }
69  /** Renders this material.
70  */
71  void Render();
72
73protected:
74
75        /** Initialize the material with default values
76        */
77        void InitMaterial();
78
79        /// unique material id
80        int mId;
81        /// the assciated texture
82        Texture *mTexture;
83};
84
85
86extern Material RandomMaterial();
87
88}
89
90#endif
Note: See TracBrowser for help on using the repository browser.