Line | |
---|
1 | #ifndef __MATERIAL_H
|
---|
2 | #define __MATERIAL_H
|
---|
3 |
|
---|
4 |
|
---|
5 | namespace CHCDemo
|
---|
6 | {
|
---|
7 |
|
---|
8 | class Texture;
|
---|
9 | class RenderState;
|
---|
10 |
|
---|
11 |
|
---|
12 | class RgbaColor
|
---|
13 | {
|
---|
14 |
|
---|
15 | public:
|
---|
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
|
---|
30 | RgbaColor RandomColor(float a, float b);
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 | class Material
|
---|
35 | {
|
---|
36 | public:
|
---|
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 |
|
---|
65 | protected:
|
---|
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 |
|
---|
80 | extern Material RandomMaterial();
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|
84 | #endif
|
---|
Note: See
TracBrowser
for help on using the repository browser.