]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/tile.h
Irrlicht 1.9 support
[dragonfireclient.git] / src / client / tile.h
index 674da66f22903a3d1836f860f1392c3a1cbb8ce8..b759168413be36687a2432bb6b3d1b7fa3c91f4e 100644 (file)
@@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #define TILE_HEADER
 
 #include "irrlichttypes.h"
-#include "irr_v2d.h"
 #include "irr_v3d.h"
 #include <ITexture.h>
 #include <IrrlichtDevice.h>
@@ -31,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/numeric.h"
 
 class IGameDef;
+struct TileSpec;
+struct TileDef;
 
 /*
        tile.{h,cpp}: Texture handling stuff.
@@ -111,6 +112,7 @@ class ITextureSource : public ISimpleTextureSource
                        const TextureFromMeshParams &params)=0;
        virtual video::ITexture* getNormalTexture(const std::string &name)=0;
        virtual video::SColor getTextureAverageColor(const std::string &name)=0;
+       virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
 };
 
 class IWritableTextureSource : public ITextureSource
@@ -133,6 +135,7 @@ class IWritableTextureSource : public ITextureSource
        virtual void rebuildImagesAndTextures()=0;
        virtual video::ITexture* getNormalTexture(const std::string &name)=0;
        virtual video::SColor getTextureAverageColor(const std::string &name)=0;
+       virtual video::ITexture *getShaderFlagsTexture(bool normalmap_present)=0;
 };
 
 IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
@@ -162,6 +165,8 @@ enum MaterialType{
 // defined by extra parameters
 #define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
 #define MATERIAL_FLAG_HIGHLIGHTED 0x10
+#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
+#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
 
 /*
        This fully defines the looks of a tile.
@@ -172,12 +177,14 @@ struct FrameSpec
        FrameSpec():
                texture_id(0),
                texture(NULL),
-               normal_texture(NULL)
+               normal_texture(NULL),
+               flags_texture(NULL)
        {
        }
        u32 texture_id;
        video::ITexture *texture;
        video::ITexture *normal_texture;
+       video::ITexture *flags_texture;
 };
 
 struct TileSpec
@@ -186,6 +193,7 @@ struct TileSpec
                texture_id(0),
                texture(NULL),
                normal_texture(NULL),
+               flags_texture(NULL),
                alpha(255),
                material_type(TILE_MATERIAL_BASIC),
                material_flags(
@@ -241,17 +249,32 @@ struct TileSpec
                }
                material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
                        ? true : false;
+               if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
+                       material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
+               }
+               if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
+                       material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
+               }
        }
 
        void applyMaterialOptionsWithShaders(video::SMaterial &material) const
        {
                material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING)
                        ? true : false;
+               if (!(material_flags & MATERIAL_FLAG_TILEABLE_HORIZONTAL)) {
+                       material.TextureLayer[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
+                       material.TextureLayer[1].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
+               }
+               if (!(material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL)) {
+                       material.TextureLayer[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
+                       material.TextureLayer[1].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
+               }
        }
        
        u32 texture_id;
        video::ITexture *texture;
        video::ITexture *normal_texture;
+       video::ITexture *flags_texture;
        
        // Vertex alpha (when MATERIAL_ALPHA_VERTEX is used)
        u8 alpha;
@@ -266,5 +289,4 @@ struct TileSpec
 
        u8 rotation;
 };
-
 #endif