Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

SMaterial.h

Go to the documentation of this file.
00001 /*
00002 
00003 AmnesiaEngine
00004 Copyright (c) 2006 John DiSanti.
00005 
00006 Permission is hereby granted, free of charge,
00007 to any person obtaining a copy of this software and associated
00008 documentation files (the "Software"), to deal in the Software
00009 without restriction, including without limitation the rights to
00010 use, copy, modify, merge, publish, distribute, sublicense,
00011 and/or sell copies of the Software, and to permit persons to
00012 whom the Software is furnished to do so, subject to the following
00013 conditions:
00014 
00015 The above copyright notice and this permission notice shall be included
00016 in all copies or substantial portions of the Software.
00017 
00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
00019 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
00020 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00021 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00022 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00023 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00024 
00025 */
00026 
00027 #ifndef AMN_SMATERIAL_H
00028 #define AMN_SMATERIAL_H
00029 
00030 namespace amn
00031 {
00032         class IMaterialRenderer;
00033         class STexture;
00034 
00035         enum E_MATERIAL_TYPE
00036         {
00038                 EMT_WIREFRAME = 0,      
00040                 EMT_SOLID,      
00042                 EMT_TRANSPARENT_ALPHA,  
00044                 EMT_TRANSPARENT_VERTEX_ALPHA,
00046                 EMT_TRANSPARENT_ADD_COLOR,
00048                 EMT_LIGHTMAP,
00050                 EMT_CUSTOM_SOLID,
00052                 EMT_CUSTOM_TRANSPARENT
00053         };
00054 
00055         class SColor
00056         {
00057         public:
00059                 SColor() {color.full = 0;}
00061                 SColor(int a, int r, int g, int b) {set(a,r,g,b);}
00062                 
00064                 SColor(const SColor& copy)
00065                 {
00066                         //color.full = copy.getIntegerColor();
00067                 }
00068 
00070                 inline void set(int a, int r, int g, int b)
00071                 {
00072                         color.indv[0] = a;
00073                         color.indv[1] = r;
00074                         color.indv[2] = g;
00075                         color.indv[3] = b;
00076                 }
00077 
00079                 inline unsigned char getAlpha() { return color.indv[0]; }
00081                 inline unsigned char getRed() { return color.indv[1]; }
00083                 inline unsigned char getBlue() { return color.indv[2]; }
00085                 inline unsigned char getGreen() { return color.indv[3]; }
00086 
00088                 inline int getIntegerColor() { return color.full; }
00089 
00090         private:
00091                 union
00092                 {
00093                         int full; // a8 r8 g8 b8 format
00094                         unsigned char indv[4];
00095                 }color;
00096         };
00097 
00098         class SMaterial
00099         {
00100         public:
00102                 SMaterial()
00103                 {
00104                         materialType = EMT_SOLID;
00105                         materialRenderer = NULL;
00106 
00107                         Texture1 = 0;
00108                         Texture2 = 0;
00109                         Texture3 = 0;
00110                         Texture4 = 0;
00111                         Texture5 = 0;
00112                         Texture6 = 0;
00113                         Texture7 = 0;
00114                         Texture8 = 0;
00115 
00116                         flagLighting = true;
00117                         flagDepthTesting = true;
00118                         flagBlending = false;
00119                 }
00121                 SMaterial(const SMaterial& copy)
00122                 {
00123                         memcpy(this, &copy, sizeof(SMaterial));
00124                 }
00125 
00127                 E_MATERIAL_TYPE materialType;
00129                 IMaterialRenderer* materialRenderer;
00130 
00131                 union
00132                 {
00133                         struct
00134                         {
00135                                 STexture* Texture1;
00136                                 STexture* Texture2;
00137                                 STexture* Texture3;
00138                                 STexture* Texture4;
00139                                 STexture* Texture5;
00140                                 STexture* Texture6;
00141                                 STexture* Texture7;
00142                                 STexture* Texture8;
00143                         };
00144 
00145                         STexture* Texture[8];
00146                 };
00147 
00148                 bool flagLighting;
00149                 bool flagDepthTesting;
00150                 bool flagBlending;
00151         };
00152 };
00153 
00154 #endif//AMN_SMATERIAL_H
00155 
00156 /* End of File */

Generated on Wed Feb 1 22:23:26 2006 for AmnesiaEngine by  doxygen 1.4.2