00001 #ifndef MERCURYMATERIAL_H 00002 #define MERCURYMATERIAL_H 00003 00004 #include "MercuryColor.h" 00005 #include "MercuryVector.h" 00006 #include "MercuryMessages.h" 00007 class MercuryTexture; 00008 00010 class MercuryMaterial : public MercuryMessageHandler 00011 { 00012 public: 00013 MercuryMaterial(); 00014 ~MercuryMaterial(); 00015 00016 virtual void Message( int Message, PStack & data, const MString & name ); 00017 void AddTexture(MercuryTexture* texture); 00018 inline MercuryTexture* EditTexture(unsigned int i) { return m_textures[i]; } 00019 inline const MercuryTexture* GetTexture(unsigned int i) const { return m_textures[i]; } 00020 inline unsigned int NumTextures() const { return m_textures.size(); } 00021 bool LoadMaterial(const MString& filename, const MString& path = ""); 00022 void ClearTextures(); 00023 int GetShaderID() const { return m_iGLSLShaderID; } 00024 00025 const MercuryMaterial& operator=(const MercuryMaterial& m); 00026 const MercuryMaterial operator*(const MercuryMaterial& m); 00027 const MercuryMaterial& operator*=(const MercuryMaterial& m); 00028 00029 MString m_name; 00030 00031 //NOTE: Keep order for colors and shininess. This way we can use it as the D3D structure. 00032 MercuryColor m_diffuse; 00033 MercuryColor m_ambient; 00034 MercuryColor m_specular; 00035 MercuryColor m_emissive; 00036 float m_shininess; 00037 00038 float m_alpha; 00039 00040 MVector<MString> m_vUniformNames; 00041 MVector<PStack> m_vUniformValues; 00042 00043 private: 00044 void BuildShader(); 00045 00046 MString m_completePath; 00047 MVector< MAutoPtr<MercuryTexture> > m_textures; 00048 00049 //-1 if no GLSL Shader was loaded 00050 int m_iGLSLShaderID; 00051 00052 unsigned m_iGLSLVertTime; 00053 unsigned m_iGLSLFragTime; 00054 MString m_GLSLFragmentFile; 00055 MString m_GLSLVertexFile; 00056 bool m_bHasRegistered; 00057 }; 00058 00059 #endif 00060 00061 /* 00062 * Copyright (c) 2005-2006, Joshua Allen 00063 * All rights reserved. 00064 * 00065 * Redistribution and use in source and binary forms, with or 00066 * without modification, are permitted provided that the following 00067 * conditions are met: 00068 * - Redistributions of source code must retain the above 00069 * copyright notice, this list of conditions and the following disclaimer. 00070 * - Redistributions in binary form must reproduce the above copyright 00071 * notice, this list of conditions and the following disclaimer in 00072 * the documentation and/or other materials provided with the distribution. 00073 * - Neither the name of the Mercury Engine nor the names of its 00074 * contributors may be used to endorse or promote products derived from 00075 * this software without specific prior written permission. 00076 * 00077 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00078 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00079 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00080 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 00081 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00082 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00083 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00084 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00085 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00086 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00087 */