00001 /* 00002 * Matrix texture header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_UTILITY_MATRIX_TEXTURE_H__ 00009 #define __SP_UTILITY_MATRIX_TEXTURE_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 00014 #ifdef SP_COMPILE_WITH_MATRIXTEXTURE 00015 00016 00017 #include "Base/spDimensionMatrix4.hpp" 00018 #include "RenderSystem/spTextureBase.hpp" 00019 00020 00021 namespace sp 00022 { 00023 namespace tool 00024 { 00025 00026 00033 class SP_EXPORT GeneralPurposeTexture 00034 { 00035 00036 public: 00037 00038 virtual ~GeneralPurposeTexture(); 00039 00040 /* === Functions === */ 00041 00043 virtual dim::point2di getTexCoord(u32 Index) const = 0; 00044 00046 virtual void resize(u32 Count) = 0; 00047 00054 virtual void update(); 00055 00056 /* === Static functions === */ 00057 00064 static dim::size2di getSizeByCount(u32 Count); 00065 00066 /* === Inline functions === */ 00067 00069 inline u32 getCount() const 00070 { 00071 return Count_; 00072 } 00073 00075 inline video::Texture* getTexture() const 00076 { 00077 return Tex_; 00078 } 00079 00080 protected: 00081 00082 GeneralPurposeTexture(const io::stringc &TypeName, const dim::size2di &TexSize, u32 Count); 00083 00084 /* === Functions === */ 00085 00086 void generate(const dim::size2di &TexSize, u32 Count); 00087 00088 /* === Members === */ 00089 00090 video::Texture* Tex_; 00091 u32 Count_; 00092 00093 }; 00094 00095 00106 class SP_EXPORT MatrixTexture : public GeneralPurposeTexture 00107 { 00108 00109 public: 00110 00112 MatrixTexture(u32 Count); 00113 ~MatrixTexture(); 00114 00115 /* === Functions === */ 00116 00125 void setMatrix(u32 Index, const dim::matrix4f &Matrix, bool ImmediateUpdate = false); 00127 dim::matrix4f getMatrix(u32 Index) const; 00128 00130 dim::point2di getTexCoord(u32 Index) const; 00131 00133 void resize(u32 Count); 00134 00135 }; 00136 00137 00148 class SP_EXPORT VectorTexture : public GeneralPurposeTexture 00149 { 00150 00151 public: 00152 00154 VectorTexture(u32 Count); 00155 ~VectorTexture(); 00156 00157 /* === Functions === */ 00158 00167 void setVector(u32 Index, const dim::vector4df &Vector, bool ImmediateUpdate = false); 00169 dim::vector4df getVector(u32 Index) const; 00170 00172 dim::point2di getTexCoord(u32 Index) const; 00173 00175 void resize(u32 Count); 00176 00177 }; 00178 00179 00180 } // /namespace tool 00181 00182 } // /namespace sp 00183 00184 00185 #endif 00186 00187 #endif 00188 00189 00190 00191 // ================================================================================