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

Revision 2844, 2.2 KB checked in by mattausch, 16 years ago (diff)

lod starting to work

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