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

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