Go to the documentation of this file.00001 #ifndef __NYTRO_Material_H
00002 #define __NYTRO_Material_H
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "system/nyCommon.h"
00012 #include "graphics/nyTexture.h"
00013 #include "physics/nyPhysicsBody.h"
00014
00015 namespace Nytro
00016 {
00017 namespace Game
00018 {
00019 using namespace Core;
00020 using namespace Math;
00021 using namespace Physics;
00022
00024 class NYTRO_API Material : public Resource, public ResourceObserver
00025 {
00026 public:
00027
00028 NYTRO_CLASS_NAME( Material );
00029
00030 Material();
00031 virtual ~Material();
00032
00035 EResult load( const char* pFilename = NULL );
00037 EResult unload();
00039 EResult save( const char* pFilename = NULL );
00041 void setShaderName( const char* pValue );
00043 void setShaderPresetName( const char* pValue );
00045 void setPhysicsMaterialFile( const char* pValue );
00047 void setShader( Shader* pValue );
00049 void setPhysicsMaterial( PhysicsMaterial* pValue );
00050
00051 Material* getParentMaterial();
00053 bool hasSubMaterials();
00055 vector<Material*>& getSubMaterials();
00057 Material* getSubMaterialByName( const char* pName );
00059 string getShaderName();
00061 string getPhysicsMaterialFile();
00063 vector<string>& getTextureFiles();
00065 map<string,string>& getSoundFiles();
00067 Shader* getShader();
00069 ShaderPreset& getShaderPreset();
00071 vector<Texture*>& getTextures();
00073 PhysicsMaterial* getPhysicsMaterial();
00075 map<string,SoundBufferData*>& getSounds();
00077 void resolveReferences();
00081 void preCacheResources( bool bForceReload = false );
00083 bool isPreCached();
00085 void free();
00087 void loadFromXml( XmlElement* pMaterialElem );
00089 void useTextures();
00090
00091 virtual void onBeforeUnloadResource( Resource* pRes );
00092 virtual void onAfterReloadResource( Resource* pRes );
00093
00094 protected:
00095
00096 string m_shaderFile,
00097 m_physicsMaterialFile;
00098 vector<string> m_textureFiles;
00099 map<string,string> m_soundFiles;
00100 Shader* m_pShader;
00101 ShaderPreset m_shaderPreset;
00102 vector<Texture*> m_textures;
00103 PhysicsMaterial* m_pPhysicsMaterial;
00104 map<string,SoundBufferData*> m_sounds;
00105 vector<Material*> m_subMaterials;
00106 Material* m_pParentMaterial;
00107 };
00108 };
00109 };
00110
00111 #endif