source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h @ 2795

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