| 1 | /* |
|---|
| 2 | ----------------------------------------------------------------------------- |
|---|
| 3 | This source file is part of LEXIExporter |
|---|
| 4 | |
|---|
| 5 | Copyright 2006 NDS Limited |
|---|
| 6 | |
|---|
| 7 | Author(s): |
|---|
| 8 | Mark Folkenberg, |
|---|
| 9 | Bo Krohn |
|---|
| 10 | |
|---|
| 11 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 12 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 13 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 14 | version. |
|---|
| 15 | |
|---|
| 16 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 18 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 19 | |
|---|
| 20 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 23 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 24 | ----------------------------------------------------------------------------- |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | #include "LexiStdAfx.h" |
|---|
| 28 | #include "LexiIntermediateAPI.h" |
|---|
| 29 | |
|---|
| 30 | // |
|---|
| 31 | |
|---|
| 32 | CIntermediateMaterial::CIntermediateMaterial( Ogre::String name ) |
|---|
| 33 | { |
|---|
| 34 | m_sName = name; |
|---|
| 35 | m_Mask = 0; |
|---|
| 36 | m_b2Sided = false; |
|---|
| 37 | m_bWire = false; |
|---|
| 38 | m_bFaceted = false; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | CIntermediateMaterial::CIntermediateMaterial(const CIntermediateMaterial& other) |
|---|
| 42 | { |
|---|
| 43 | m_sName = other.m_sName; |
|---|
| 44 | m_sParentName = other.m_sParentName; |
|---|
| 45 | m_vAmbientColor = other.m_vAmbientColor; |
|---|
| 46 | m_vDiffuseColor = other.m_vDiffuseColor; |
|---|
| 47 | m_vSpecularColor = other.m_vSpecularColor; |
|---|
| 48 | m_fSpecularLevel = other.m_fSpecularLevel; |
|---|
| 49 | m_fGlossiness = other.m_fGlossiness; |
|---|
| 50 | m_fOpacity = other.m_fOpacity; |
|---|
| 51 | m_b2Sided = other.m_b2Sided; |
|---|
| 52 | m_bWire = other.m_bWire; |
|---|
| 53 | m_bFaceted = other.m_bFaceted; |
|---|
| 54 | m_lTextureMaps = other.m_lTextureMaps; |
|---|
| 55 | m_Mask = other.m_Mask; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | CIntermediateMaterial::~CIntermediateMaterial( void ) |
|---|
| 59 | { |
|---|
| 60 | |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | void CIntermediateMaterial::AddTextureMap( Ogre::String identifier, STextureMapInfo texInfo) |
|---|
| 64 | { |
|---|
| 65 | std::map< Ogre::String, STextureMapInfo >::iterator it = m_lTextureMaps.find( identifier ); |
|---|
| 66 | if (it != m_lTextureMaps.end()) |
|---|
| 67 | return; |
|---|
| 68 | |
|---|
| 69 | std::pair< Ogre::String, STextureMapInfo > entry(identifier, texInfo); |
|---|
| 70 | m_lTextureMaps.insert( entry ); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | short& CIntermediateMaterial::GetMask( void ) |
|---|
| 74 | { |
|---|
| 75 | return m_Mask; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | const std::map< Ogre::String, STextureMapInfo >& CIntermediateMaterial::GetTextureMaps( void ) |
|---|
| 79 | { |
|---|
| 80 | return m_lTextureMaps; |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | STextureMapInfo CIntermediateMaterial::GetTextureMapInfoFromName( Ogre::String name ) |
|---|
| 84 | { |
|---|
| 85 | std::map< Ogre::String, STextureMapInfo >::iterator it = m_lTextureMaps.find( name ); |
|---|
| 86 | if ( it == m_lTextureMaps.end() ) |
|---|
| 87 | return STextureMapInfo(); |
|---|
| 88 | else |
|---|
| 89 | return it->second; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | bool CIntermediateMaterial::UsesSameTextureMaps( CIntermediateMaterial* pIMat ) |
|---|
| 93 | { |
|---|
| 94 | short& mask2 = pIMat->GetMask(); |
|---|
| 95 | |
|---|
| 96 | if ( (m_Mask^mask2) == 0 ) |
|---|
| 97 | return true; |
|---|
| 98 | else |
|---|
| 99 | return false; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 104 | // Gets |
|---|
| 105 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 106 | |
|---|
| 107 | Ogre::String CIntermediateMaterial::GetName( void ) |
|---|
| 108 | { |
|---|
| 109 | return m_sName; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | Ogre::String CIntermediateMaterial::GetParentName( void ) |
|---|
| 113 | { |
|---|
| 114 | return m_sParentName; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | const Ogre::ColourValue& CIntermediateMaterial::GetAmbientColor( void ) const |
|---|
| 118 | { |
|---|
| 119 | return m_vAmbientColor; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | const Ogre::ColourValue& CIntermediateMaterial::GetDiffuseColor( void ) const |
|---|
| 123 | { |
|---|
| 124 | return m_vDiffuseColor; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | const Ogre::ColourValue& CIntermediateMaterial::GetSpecularColor( void ) const |
|---|
| 128 | { |
|---|
| 129 | return m_vSpecularColor; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | const Ogre::ColourValue& CIntermediateMaterial::GetEmissiveColor( void ) const |
|---|
| 133 | { |
|---|
| 134 | return m_vEmissiveColor; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | float CIntermediateMaterial::GetSpecularLevel( void ) const |
|---|
| 138 | { |
|---|
| 139 | return m_fSpecularLevel; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | float CIntermediateMaterial::GetGlossiness( void ) const |
|---|
| 143 | { |
|---|
| 144 | return m_fGlossiness; |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | float CIntermediateMaterial::GetOpacity( void ) const |
|---|
| 148 | { |
|---|
| 149 | return m_fOpacity; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | bool CIntermediateMaterial::Get2Sided( void ) const |
|---|
| 153 | { |
|---|
| 154 | return m_b2Sided; |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | bool CIntermediateMaterial::GetWired( void ) const |
|---|
| 158 | { |
|---|
| 159 | return m_bWire; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | bool CIntermediateMaterial::GetFaceted( void ) const |
|---|
| 163 | { |
|---|
| 164 | return m_bFaceted; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 168 | // Sets |
|---|
| 169 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 170 | |
|---|
| 171 | void CIntermediateMaterial::SetParentName( Ogre::String parentName ) |
|---|
| 172 | { |
|---|
| 173 | m_sParentName = parentName; |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | void CIntermediateMaterial::SetAmbientColor( const Ogre::Vector4& color ) |
|---|
| 177 | { |
|---|
| 178 | m_vAmbientColor = Ogre::ColourValue(color.x,color.y, color.z, color.w); |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | void CIntermediateMaterial::SetAmbientColor( const Ogre::Vector3& color ) |
|---|
| 182 | { |
|---|
| 183 | m_vAmbientColor = Ogre::ColourValue(color.x, color.y, color.x, 1.0f); |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | void CIntermediateMaterial::SetAmbientColor( float r, float g, float b, float a ) |
|---|
| 187 | { |
|---|
| 188 | m_vAmbientColor = Ogre::ColourValue(r,g,b,a); |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | void CIntermediateMaterial::SetDiffuseColor( const Ogre::Vector4& color ) |
|---|
| 192 | { |
|---|
| 193 | m_vDiffuseColor = Ogre::ColourValue(color.x,color.y, color.z, color.w); |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | void CIntermediateMaterial::SetDiffuseColor( const Ogre::Vector3& color ) |
|---|
| 197 | { |
|---|
| 198 | m_vDiffuseColor = Ogre::ColourValue(color.x, color.y, color.x, 1.0f); |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | void CIntermediateMaterial::SetDiffuseColor( float r, float g, float b, float a ) |
|---|
| 202 | { |
|---|
| 203 | m_vDiffuseColor = Ogre::ColourValue(r,g,b,a); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | void CIntermediateMaterial::SetSpecularColor( const Ogre::Vector4& color ) |
|---|
| 207 | { |
|---|
| 208 | m_vSpecularColor = Ogre::ColourValue(color.x,color.y, color.z, color.w);; |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | void CIntermediateMaterial::SetSpecularColor( const Ogre::Vector3& color ) |
|---|
| 212 | { |
|---|
| 213 | m_vSpecularColor = Ogre::ColourValue(color.x, color.y, color.x, 1.0f); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | void CIntermediateMaterial::SetSpecularColor( float r, float g, float b, float a ) |
|---|
| 217 | { |
|---|
| 218 | m_vSpecularColor = Ogre::ColourValue(r,g,b,a); |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | void CIntermediateMaterial::SetEmissiveColor( const Ogre::Vector4& color ) |
|---|
| 222 | { |
|---|
| 223 | m_vEmissiveColor = Ogre::ColourValue(color.x,color.y, color.z, color.w);; |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | void CIntermediateMaterial::SetEmissiveColor( const Ogre::Vector3& color ) |
|---|
| 227 | { |
|---|
| 228 | m_vEmissiveColor = Ogre::ColourValue(color.x, color.y, color.x, 1.0f); |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | void CIntermediateMaterial::SetEmissiveColor( float r, float g, float b, float a ) |
|---|
| 232 | { |
|---|
| 233 | m_vEmissiveColor = Ogre::ColourValue(r,g,b,a); |
|---|
| 234 | } |
|---|
| 235 | |
|---|
| 236 | void CIntermediateMaterial::SetSpecularLevel( float level ) |
|---|
| 237 | { |
|---|
| 238 | m_fSpecularLevel = level; |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | void CIntermediateMaterial::SetGlosiness( float glossiness ) |
|---|
| 242 | { |
|---|
| 243 | m_fGlossiness = glossiness; |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | void CIntermediateMaterial::SetOpacity( float opacity ) |
|---|
| 247 | { |
|---|
| 248 | m_fOpacity = opacity; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | void CIntermediateMaterial::Set2Sided( bool b2Sided ) |
|---|
| 252 | { |
|---|
| 253 | m_b2Sided = b2Sided; |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | void CIntermediateMaterial::SetWired( bool bWired ) |
|---|
| 257 | { |
|---|
| 258 | m_bWire = bWired; |
|---|
| 259 | } |
|---|
| 260 | |
|---|
| 261 | void CIntermediateMaterial::SetFaceted( bool bFaceted ) |
|---|
| 262 | { |
|---|
| 263 | m_bFaceted = bFaceted; |
|---|
| 264 | } |
|---|
| 265 | |
|---|