CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

material.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2000 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_IVIDEO_MATERIAL_H__
00020 #define __CS_IVIDEO_MATERIAL_H__
00021 
00029 #include "csutil/scf.h"
00030 #include "csutil/strset.h"
00031 #include "csutil/strhash.h"
00032 
00033 #include "ivideo/rndbuf.h"
00034 #include "ivideo/rendermesh.h"
00035 #include "ivideo/shader/shader.h"
00036 
00038 #define CS_DEFMAT_DIFFUSE 0.7f
00039 
00040 #define CS_DEFMAT_AMBIENT 0.0f
00041 
00042 #define CS_DEFMAT_REFLECTION  0.0f
00043 
00045 #define CS_MATERIAL_VARNAME_DIFFUSE             "mat diffuse"
00046 
00047 #define CS_MATERIAL_VARNAME_AMBIENT             "mat ambient"
00048 
00049 #define CS_MATERIAL_VARNAME_REFLECTION          "mat reflection"
00050 
00051 #define CS_MATERIAL_VARNAME_FLATCOLOR           "mat flatcolor"
00052 
00053 #define CS_MATERIAL_TEXTURE_DIFFUSE             "tex diffuse"
00054 
00056 #define CS_MATERIAL_TEXTURE_LAYER1              "tex layer1"
00057 
00058 #define CS_MATERIAL_TEXTURE_LAYER2              "tex layer2"
00059 
00060 #define CS_MATERIAL_TEXTURE_LAYER3              "tex layer3"
00061 
00062 #define CS_MATERIAL_TEXTURE_LAYER4              "tex layer4"
00063 
00064 struct iTextureHandle;
00065 struct csRGBpixel;
00066 struct csRGBcolor;
00067 
00072 struct csTextureLayer
00073 {
00075   csRef<iTextureHandle> txt_handle;
00077   uint mode;    
00079   float uscale, vscale; 
00081   float ushift, vshift; 
00082 };
00083 
00084 SCF_VERSION (iMaterial, 0, 0, 6);
00085 
00106 struct iMaterial : public iShaderVariableContext
00107 {
00111   virtual void SetShader (csStringID type, iShader* shader) = 0;
00112 
00116   virtual iShader* GetShader (csStringID type) = 0;
00117 
00121   virtual const csHash<csRef<iShader>, csStringID>& GetShaders() const =0;
00122 
00126   virtual iTextureHandle *GetTexture () = 0;
00127 
00131   virtual iTextureHandle* GetTexture (csStringID name) = 0;
00132 
00138   virtual int GetTextureLayerCount () = 0;
00139 
00144   virtual csTextureLayer* GetTextureLayer (int idx) = 0;
00145 
00150   virtual void GetFlatColor (csRGBpixel &oColor,
00151     bool useTextureMean = true) = 0;
00155   virtual void SetFlatColor (const csRGBcolor& col) = 0;
00156 
00160   virtual void GetReflection (
00161     float &oDiffuse, float &oAmbient, float &oReflection) = 0;
00165   virtual void SetReflection (float oDiffuse, float oAmbient,
00166     float oReflection) = 0;
00167 };
00168 
00169 SCF_VERSION (iMaterialHandle, 0, 0, 2);
00170 
00188 struct iMaterialHandle : public iBase
00189 {
00193   virtual iShader* GetShader (csStringID type) = 0;
00194 
00198   virtual iTextureHandle *GetTexture () = 0;
00199 
00204   virtual void GetFlatColor (csRGBpixel &oColor) = 0;
00205 
00209   virtual void GetReflection (float &oDiffuse, float &oAmbient,
00210         float &oReflection) = 0;
00211 };
00212 
00215 #endif // __CS_IVIDEO_MATERIAL_H__

Generated for Crystal Space by doxygen 1.3.9.1