3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 // For IrrlichtWrapper
27 These can either be real paths or generated names of preloaded
28 textures (like "mud.png_sidegrass")
30 std::string g_tile_texture_paths[TILES_COUNT];
32 const char * tile_texture_path_get(u32 i)
34 assert(i < TILES_COUNT);
36 //return g_tile_texture_paths[i];
37 return g_tile_texture_paths[i].c_str();
40 // A mapping from tiles to materials
41 // Initialized at run-time.
42 video::SMaterial g_tile_materials[TILES_COUNT];
50 struct TileTextureSpec
53 enum TileTextureModID mod;
57 Initializes g_tile_texture_paths with paths of textures,
58 generates generated textures and creates the tile material array.
60 void init_tile_textures()
62 TileTextureSpec tile_texture_specs[TILES_COUNT] =
65 {"stone.png", TTMID_NONE},
66 {"water.png", TTMID_NONE},
67 {"grass.png", TTMID_NONE},
68 {"tree.png", TTMID_NONE},
69 {"leaves.png", TTMID_NONE},
70 {"grass_footsteps.png", TTMID_NONE},
71 {"mese.png", TTMID_NONE},
72 {"mud.png", TTMID_NONE},
73 {"tree_top.png", TTMID_NONE},
74 {"mud.png", TTMID_SIDEGRASS},
75 {"cloud.png", TTMID_NONE},
76 {"coalstone.png", TTMID_NONE},
77 {"wood.png", TTMID_NONE},
80 for(s32 i=0; i<TILES_COUNT; i++)
82 const char *filename = tile_texture_specs[i].filename;
83 enum TileTextureModID mod_id = tile_texture_specs[i].mod;
85 if(filename != NULL && std::string("") != filename)
87 std::string path = porting::getDataPath(filename);
88 std::string mod_postfix = "";
89 if(mod_id == TTMID_SIDEGRASS)
91 mod_postfix = "_sidegrass";
93 TextureMod *mod = new SideGrassTextureMod();
94 g_irrlicht->getTexture(TextureSpec(path + mod_postfix,
97 g_tile_texture_paths[i] = path + mod_postfix;
101 for(s32 i=0; i<TILES_COUNT; i++)
103 const char *path = tile_texture_path_get(i);
105 video::ITexture *t = NULL;
107 if(path != NULL && std::string("") != path)
109 t = g_irrlicht->getTexture(path);
113 g_tile_materials[i].Lighting = false;
114 g_tile_materials[i].BackfaceCulling = false;
115 g_tile_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false);
116 g_tile_materials[i].setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
117 //if(i != TILE_WATER)
118 g_tile_materials[i].setFlag(video::EMF_FOG_ENABLE, true);
120 //g_tile_materials[i].setFlag(video::EMF_TEXTURE_WRAP, video::ETC_REPEAT);
121 //g_tile_materials[i].setFlag(video::EMF_ANISOTROPIC_FILTER, false);
123 g_tile_materials[i].setTexture(0, t);
126 g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
127 //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
130 video::SMaterial & tile_material_get(u32 i)
132 assert(i < TILES_COUNT);
134 return g_tile_materials[i];