Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
E:/Programming/MyProject/K_Game_hg/GameEngine/include/render/Material.h
Go to the documentation of this file.
00001 // Copyright 2006-2011 by Kat'Oun
00002 
00003 #ifndef _RENDERMATERIAL_H_
00004 #define _RENDERMATERIAL_H_
00005 
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <resource/Resource.h>
00009 #include <render/Color.h>
00010 #include <render/BlendMode.h>
00011 
00012 #include <string>
00013 #include <list>
00014 
00015 namespace resource
00016 {
00017 class Serializer;
00018 }
00019 
00020 namespace render
00021 {
00022 
00024 enum ShadeOptions
00025 {
00026         SO_FLAT,
00027         SO_GOURAUD,
00028         SO_PHONG
00029 };
00030 
00032 enum FogMode
00033 {
00034         FM_NONE,        
00035         FM_EXP,         
00036         FM_EXP2,        
00037         FM_LINEAR       
00038 };
00039 
00040 
00041 class Shader;
00042 class TextureUnit;
00043 
00050 class ENGINE_PUBLIC_EXPORT Material : public resource::Resource
00051 {
00052 public:
00053 
00054         Material(const std::string& name, resource::Serializer* serializer);
00055         ~Material();
00056 
00058         void setAmbient(f32 red, f32 green, f32 blue);
00059         void setAmbient(const Color& ambient);
00060 
00062         void setDiffuse(f32 red, f32 green, f32 blue);
00063         void setDiffuse(const Color& diffuse);
00064 
00066         void setSpecular(f32 red, f32 green, f32 blue);
00067         void setSpecular(const Color& specular);
00068 
00070         void setEmissive(f32 red, f32 green, f32 blue);
00071         void setEmissive(const Color& emissive);
00072 
00074         void setShininess(f32 shininess);
00075 
00077         const Color& getAmbient() const;
00078 
00080         const Color& getDiffuse() const;
00081 
00083         const Color& getSpecular() const;
00084 
00086         const Color& getEmissive() const;
00087 
00089         f32 getShininess() const;
00090 
00092         void setLightingEnabled(bool enabled);
00093 
00095         bool getLightingEnabled() const;
00096 
00098         void setShadingMode(ShadeOptions mode);
00099 
00101         ShadeOptions getShadingMode() const;
00102 
00104         void setFog(bool overrideScene = true, FogMode mode = FM_NONE, const Color& color = Color::White, f32 density = 0.001f, f32 start = 0.0f, f32 end = 1.0f);
00105         
00107         bool getFogOverride() const;
00108 
00110         FogMode getFogMode() const;
00111 
00113         const Color& getFogColor() const;
00114 
00116         f32 getFogDensity() const;
00117 
00119         f32 getFogStart() const;
00120 
00122         f32 getFogEnd() const;
00123 
00125         void setSceneBlending(const SceneBlendType sbt);
00126         
00128         void setSceneBlending(const SceneBlendFactor sourceFactor, const SceneBlendFactor destFactor);
00129 
00131         SceneBlendFactor getSourceBlendFactor() const;
00132 
00134         SceneBlendFactor getDestBlendFactor() const;
00135 
00137         bool isTransparent() const;
00138 
00140         void setDepthCheckEnabled(bool enabled);
00141 
00143         bool getDepthCheckEnabled() const;
00144 
00146         void setDepthWriteEnabled(bool enabled);
00147 
00149         bool getDepthWriteEnabled() const;
00150 
00152         void addTextureUnit(TextureUnit* tu);
00153 
00155         TextureUnit* getTextureUnit(u32 index) const;
00156 
00158         u32 getNumTextureUnits() const; 
00159         
00161         void removeTextureUnit(u32 index);
00162 
00164         void removeAllTextureUnits();
00165 
00166         void setVertexShader(const std::string& filename);
00167         void setVertexShader(Shader* shader);
00168         Shader* getVertexShader();
00169 
00170         void setFragmentShader(const std::string& filename);
00171         void setFragmentShader(Shader* shader);
00172         Shader* getFragmentShader();
00173 
00174         void setGeometryShader(const std::string& filename);
00175         void setGeometryShader(Shader* shader);
00176         Shader* getGeometryShader();
00177 
00178         bool isProgrammable();
00179         bool hasVertexShader();
00180         bool hasFragmentShader();
00181         bool hasGeometryShader();
00182 
00183 protected:
00184 
00185         void initProperties();
00186         void unloadImpl();
00187 
00188         // Color properties
00189         Color mAmbient;
00190         Color mDiffuse;
00191         Color mSpecular;
00192         Color mEmissive;
00193         f32 mShininess;
00194 
00195         // Blending factors
00196         SceneBlendFactor mSourceBlendFactor;
00197         SceneBlendFactor mDestBlendFactor;
00198 
00199         // Depth buffer settings
00200         bool mDepthCheck;
00201         bool mDepthWrite;
00202 
00203         bool mLightingEnabled;
00204 
00205         ShadeOptions mShadeOptions;
00206 
00207         // Fog
00208         bool mFogOverride;
00209         FogMode mFogMode;
00210         Color mFogColor;
00211         f32 mFogDensity;
00212         f32 mFogStart;
00213         f32 mFogEnd;
00214 
00215         // Textures
00216         std::list<TextureUnit*> mTextureUnits;
00217 
00218         Shader* mVertexShader;
00219         Shader* mFragmentShader;
00220         Shader* mGeometryShader;
00221 };
00222 
00223 } //namespace render
00224 
00225 #endif

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:04 by Doxygen (1.7.4)