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

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