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

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