"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSModelLib/Src/Models/LSDMaterial.h

00001 
00016 #ifndef __LSD_MATERIAL_H__
00017 #define __LSD_MATERIAL_H__
00018 
00019 #include "../LSDModelLib.h"
00020 #include "Streams/LSSTDStream.h"
00021 #include "String/LSTLString.h"
00022 #include "Vector/LSTLVector.h"
00023 
00024 namespace lsd {
00025 
00032         class CMaterial {
00033         public :
00034                 // == Various constructors.
00035                 LSE_CALLCTOR                                                    CMaterial();
00036                 virtual LSE_CALLCTOR                                    ~CMaterial();
00037 
00038 
00039                 // == Enumerations.
00043                 enum LSD_MATERIAL_TYPE {
00044                         LSD_MT_LAMBERT,
00045                         LSD_MT_PHONG,
00046                 };
00047 
00048 
00049                 // == Types.
00053                 typedef struct LSD_COLOR {
00054                         union {
00056                                 LSFLOAT                                                 fColors[3];
00057                                 struct LSD_RGB {
00059                                         LSFLOAT                                         fR;
00061                                         LSFLOAT                                         fG;
00063                                         LSFLOAT                                         fB;
00064                                 }                                                               rRgb;
00065                         }                                                                       u;
00066 
00070                         CString                                                         sTexture;
00071 
00072 
00073                         // == Operators.
00080                         LSD_COLOR & LSE_CALL                            operator = ( const LSD_COLOR &_cOther );
00081                 } * LPLSD_COLOR, * const LPCLSD_COLOR;
00082 
00083 
00084                 // == Operators.
00091                 CMaterial & LSE_CALL                                    operator = ( const CMaterial &_mOther );
00092 
00093 
00094                 // == Functions.
00101                 virtual CMaterial & LSE_CALL                    Copy( const CMaterial &_mOther );
00102 
00108                 virtual LSD_MATERIAL_TYPE LSE_CALL              GetType() const = 0;
00109 
00118                 virtual LSSTD_ERRORS LSE_CALL                   LoadFromStream( const lsstd::IStream &_sStream, CAllocator * _paAllocator, LSUINT32 _ui32Version ) = 0;
00119 
00125                 virtual LSVOID LSE_CALL                                 SetAllocator( CAllocator * _paAllocator );
00126 
00130                 virtual LSVOID LSE_CALL                                 Trash();
00131 
00137                 LSE_INLINE const CString & LSE_CALL             GetName() const;
00138 
00144                 LSE_INLINE CVector4 LSE_CALL                    GetDiffuseColor() const;
00145 
00151                 LSE_INLINE const CString & LSE_CALL             GetDiffuseTexture() const;
00152 
00158                 LSE_INLINE CVector4 LSE_CALL                    GetAmbientColor() const;
00159 
00165                 LSE_INLINE CVector4 LSE_CALL                    GetEmissiveColor() const;
00166 
00172                 LSE_INLINE CVector4 LSE_CALL                    GetTransparencyColor() const;
00173 
00179                 LSE_INLINE const CString & LSE_CALL             GetTransparencyTexture() const;
00180 
00186                 LSE_INLINE const CString & LSE_CALL             GetNormalTexture() const;
00187 
00193                 LSE_INLINE const CString & LSE_CALL             GetBumpTexture() const;
00194 
00195                 
00196 
00197         protected :
00198                 // == Members.
00202                 CString                                                                 m_sName;
00203 
00207                 CString                                                                 m_sNormalMap;
00208 
00212                 LSD_COLOR                                                               m_cDiffuse;
00213 
00217                 LSD_COLOR                                                               m_cAmbient;
00218 
00222                 LSD_COLOR                                                               m_cEmissive;
00223 
00227                 LSD_COLOR                                                               m_cBump;
00228 
00232                 LSD_COLOR                                                               m_cTransparent;
00233 
00237                 LSD_COLOR                                                               m_cDisplacement;
00238         };
00239 
00240 
00241         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00242         // DEFINITIONS
00243         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00249         LSE_INLINE const CString & LSE_CALL CMaterial::GetName() const {
00250                 return m_sName;
00251         }
00252 
00258         LSE_INLINE CVector4 LSE_CALL CMaterial::GetDiffuseColor() const {
00259                 return CVector4( static_cast<LSREAL>(m_cDiffuse.u.rRgb.fR),
00260                         static_cast<LSREAL>(m_cDiffuse.u.rRgb.fG),
00261                         static_cast<LSREAL>(m_cDiffuse.u.rRgb.fB),
00262                         LSM_ONE );
00263         }
00264 
00270         LSE_INLINE const CString & LSE_CALL CMaterial::GetDiffuseTexture() const {
00271                 return m_cDiffuse.sTexture;
00272         }
00273 
00279         LSE_INLINE CVector4 LSE_CALL CMaterial::GetAmbientColor() const {
00280                 return CVector4( static_cast<LSREAL>(m_cAmbient.u.rRgb.fR),
00281                         static_cast<LSREAL>(m_cAmbient.u.rRgb.fG),
00282                         static_cast<LSREAL>(m_cAmbient.u.rRgb.fB),
00283                         LSM_ONE );
00284         }
00285 
00291         LSE_INLINE CVector4 LSE_CALL CMaterial::GetEmissiveColor() const {
00292                 return CVector4( static_cast<LSREAL>(m_cEmissive.u.rRgb.fR),
00293                         static_cast<LSREAL>(m_cEmissive.u.rRgb.fG),
00294                         static_cast<LSREAL>(m_cEmissive.u.rRgb.fB),
00295                         LSM_ONE );
00296         }
00297 
00303         LSE_INLINE CVector4 LSE_CALL CMaterial::GetTransparencyColor() const {
00304                 return CVector4( static_cast<LSREAL>(m_cTransparent.u.rRgb.fR),
00305                         static_cast<LSREAL>(m_cTransparent.u.rRgb.fG),
00306                         static_cast<LSREAL>(m_cTransparent.u.rRgb.fB),
00307                         LSM_ONE );
00308         }
00309 
00315         LSE_INLINE const CString & LSE_CALL CMaterial::GetTransparencyTexture() const {
00316                 return m_cTransparent.sTexture;
00317         }
00318 
00324         LSE_INLINE const CString & LSE_CALL CMaterial::GetNormalTexture() const {
00325                 return m_sNormalMap;
00326         }
00327 
00333         LSE_INLINE const CString & LSE_CALL CMaterial::GetBumpTexture() const {
00334                 return m_cBump.sTexture;
00335         }
00336 
00337 }       // namespace lsd
00338 
00339 #endif  // __LSD_MATERIAL_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator