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

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