aboutsummaryrefslogtreecommitdiff
path: root/src/tile.h
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-06-24 04:17:50 +0200
committerKahrl <kahrl@gmx.net>2013-07-02 03:03:10 +0200
commit8161ab573fd6f8a45b3986278ce7fc1596140526 (patch)
tree0aea4fce4e14e035b386ee773e8abd68bc51bea6 /src/tile.h
parentcaf0b67e47fd4c6b2a2bc61c36010e2adf9db388 (diff)
downloadminetest-8161ab573fd6f8a45b3986278ce7fc1596140526.tar.gz
minetest-8161ab573fd6f8a45b3986278ce7fc1596140526.tar.bz2
minetest-8161ab573fd6f8a45b3986278ce7fc1596140526.zip
Remove texture atlas / AtlasPointer, rename getTextureRaw to getTexture
Diffstat (limited to 'src/tile.h')
-rw-r--r--src/tile.h114
1 files changed, 21 insertions, 93 deletions
diff --git a/src/tile.h b/src/tile.h
index 531a93172..144cb6475 100644
--- a/src/tile.h
+++ b/src/tile.h
@@ -58,69 +58,6 @@ std::string getImagePath(std::string path);
std::string getTexturePath(const std::string &filename);
/*
- Specifies a texture in an atlas.
-
- This is used to specify single textures also.
-
- This has been designed to be small enough to be thrown around a lot.
-*/
-struct AtlasPointer
-{
- u32 id; // Texture id
- video::ITexture *atlas; // Atlas in where the texture is
- v2f pos; // Position in atlas
- v2f size; // Size in atlas
- u16 tiled; // X-wise tiling count. If 0, width of atlas is width of image.
-
- AtlasPointer():
- id(0),
- atlas(NULL),
- pos(0,0),
- size(1,1),
- tiled(1)
- {}
-
- AtlasPointer(
- u16 id_,
- video::ITexture *atlas_=NULL,
- v2f pos_=v2f(0,0),
- v2f size_=v2f(1,1),
- u16 tiled_=1
- ):
- id(id_),
- atlas(atlas_),
- pos(pos_),
- size(size_),
- tiled(tiled_)
- {
- }
-
- bool operator==(const AtlasPointer &other) const
- {
- return (
- id == other.id
- );
- /*return (
- id == other.id &&
- atlas == other.atlas &&
- pos == other.pos &&
- size == other.size &&
- tiled == other.tiled
- );*/
- }
-
- bool operator!=(const AtlasPointer &other) const
- {
- return !(*this == other);
- }
-
- float x0(){ return pos.X; }
- float x1(){ return pos.X + size.X; }
- float y0(){ return pos.Y; }
- float y1(){ return pos.Y + size.Y; }
-};
-
-/*
TextureSource creates and caches textures.
*/
@@ -132,16 +69,14 @@ public:
virtual u32 getTextureId(const std::string &name){return 0;}
virtual u32 getTextureIdDirect(const std::string &name){return 0;}
virtual std::string getTextureName(u32 id){return "";}
- virtual AtlasPointer getTexture(u32 id){return AtlasPointer(0);}
- virtual AtlasPointer getTexture(const std::string &name)
- {return AtlasPointer(0);}
- virtual video::ITexture* getTextureRaw(const std::string &name)
- {return NULL;}
- virtual AtlasPointer getTextureRawAP(const AtlasPointer &ap)
- {return AtlasPointer(0);}
+ virtual video::ITexture* getTexture(u32 id){return NULL;}
+ virtual video::ITexture* getTexture(
+ const std::string &name, u32 *id = NULL){
+ if(id) *id = 0;
+ return NULL;
+ }
virtual IrrlichtDevice* getDevice()
{return NULL;}
- virtual void updateAP(AtlasPointer &ap){};
virtual bool isKnownSourceImage(const std::string &name)=0;
};
@@ -153,20 +88,18 @@ public:
virtual u32 getTextureId(const std::string &name){return 0;}
virtual u32 getTextureIdDirect(const std::string &name){return 0;}
virtual std::string getTextureName(u32 id){return "";}
- virtual AtlasPointer getTexture(u32 id){return AtlasPointer(0);}
- virtual AtlasPointer getTexture(const std::string &name)
- {return AtlasPointer(0);}
- virtual video::ITexture* getTextureRaw(const std::string &name)
- {return NULL;}
- virtual IrrlichtDevice* getDevice()
- {return NULL;}
- virtual void updateAP(AtlasPointer &ap){};
+ virtual video::ITexture* getTexture(u32 id){return NULL;}
+ virtual video::ITexture* getTexture(
+ const std::string &name, u32 *id = NULL){
+ if(id) *id = 0;
+ return NULL;
+ }
+ virtual IrrlichtDevice* getDevice(){return NULL;}
virtual bool isKnownSourceImage(const std::string &name)=0;
virtual void processQueue()=0;
virtual void insertSourceImage(const std::string &name, video::IImage *img)=0;
virtual void rebuildImagesAndTextures()=0;
- virtual void buildMainAtlas(class IGameDef *gamedef)=0;
};
IWritableTextureSource* createTextureSource(IrrlichtDevice *device);
@@ -189,8 +122,6 @@ enum MaterialType{
// Animation made up by splitting the texture to vertical frames, as
// defined by extra parameters
#define MATERIAL_FLAG_ANIMATION_VERTICAL_FRAMES 0x08
-// Whether liquid shader should be used
-#define MATERIAL_FLAG_
/*
This fully defines the looks of a tile.
@@ -199,7 +130,8 @@ enum MaterialType{
struct TileSpec
{
TileSpec():
- texture(0),
+ texture_id(0),
+ texture(NULL),
alpha(255),
material_type(TILE_MATERIAL_BASIC),
material_flags(
@@ -207,14 +139,16 @@ struct TileSpec
MATERIAL_FLAG_BACKFACE_CULLING
),
animation_frame_count(1),
- animation_frame_length_ms(0)
+ animation_frame_length_ms(0),
+ rotation(0)
{
}
bool operator==(const TileSpec &other) const
{
return (
- texture == other.texture &&
+ texture_id == other.texture_id &&
+ /* texture == other.texture && */
alpha == other.alpha &&
material_type == other.material_type &&
material_flags == other.material_flags &&
@@ -268,14 +202,8 @@ struct TileSpec
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
}
- // NOTE: Deprecated, i guess?
- void setTexturePos(u8 tx_, u8 ty_, u8 tw_, u8 th_)
- {
- texture.pos = v2f((float)tx_/256.0, (float)ty_/256.0);
- texture.size = v2f(((float)tw_ + 1.0)/256.0, ((float)th_ + 1.0)/256.0);
- }
-
- AtlasPointer texture;
+ u32 texture_id;
+ video::ITexture *texture;
// Vertex alpha (when MATERIAL_ALPHA_VERTEX is used)
u8 alpha;
// Material parameters