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
26 // A mapping from tiles to paths of textures
28 /*const char * g_tile_texture_filenames[TILES_COUNT] =
36 "grass_footsteps.png",
47 These can either be real paths or generated names of preloaded
48 textures (like "mud.png_sidegrass")
50 std::string g_tile_texture_paths[TILES_COUNT];
52 /*std::string g_tile_texture_path_strings[TILES_COUNT];
53 const char * g_tile_texture_paths[TILES_COUNT] = {0};
55 void init_tile_texture_paths()
57 for(s32 i=0; i<TILES_COUNT; i++)
59 const char *filename = g_tile_texture_filenames[i];
63 g_tile_texture_path_strings[i] =
64 porting::getDataPath(filename);
65 g_tile_texture_paths[i] =
66 g_tile_texture_path_strings[i].c_str();
71 const char * tile_texture_path_get(u32 i)
73 assert(i < TILES_COUNT);
75 //return g_tile_texture_paths[i];
76 return g_tile_texture_paths[i].c_str();
79 // A mapping from tiles to materials
80 // Initialized at run-time.
81 video::SMaterial g_tile_materials[TILES_COUNT];
89 struct TileTextureSpec
92 enum TileTextureModID mod;
96 Initializes g_tile_texture_paths with paths of textures,
97 generates generated textures and creates the tile material array.
99 void init_tile_textures()
101 TileTextureSpec tile_texture_specs[TILES_COUNT] =
104 {"stone.png", TTMID_NONE},
105 {"water.png", TTMID_NONE},
106 {"grass.png", TTMID_NONE},
107 {"tree.png", TTMID_NONE},
108 {"leaves.png", TTMID_NONE},
109 {"grass_footsteps.png", TTMID_NONE},
110 {"mese.png", TTMID_NONE},
111 {"mud.png", TTMID_NONE},
112 {"tree_top.png", TTMID_NONE},
113 {"mud.png", TTMID_SIDEGRASS},
114 {"cloud.png", TTMID_NONE},
115 {"coalstone.png", TTMID_NONE},
116 {"wood.png", TTMID_NONE},
119 for(s32 i=0; i<TILES_COUNT; i++)
121 const char *filename = tile_texture_specs[i].filename;
122 enum TileTextureModID mod_id = tile_texture_specs[i].mod;
124 if(filename != NULL && std::string("") != filename)
126 std::string path = porting::getDataPath(filename);
127 std::string mod_postfix = "";
128 if(mod_id == TTMID_SIDEGRASS)
130 mod_postfix = "_sidegrass";
132 TextureMod *mod = new SideGrassTextureMod();
133 g_irrlicht->getTexture(TextureSpec(path + mod_postfix,
136 g_tile_texture_paths[i] = path + mod_postfix;
140 for(s32 i=0; i<TILES_COUNT; i++)
142 const char *path = tile_texture_path_get(i);
144 video::ITexture *t = NULL;
146 if(path != NULL && std::string("") != path)
148 t = g_irrlicht->getTexture(path);
152 g_tile_materials[i].Lighting = false;
153 g_tile_materials[i].BackfaceCulling = false;
154 g_tile_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false);
155 g_tile_materials[i].setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
156 //if(i != TILE_WATER)
157 g_tile_materials[i].setFlag(video::EMF_FOG_ENABLE, true);
159 //g_tile_materials[i].setFlag(video::EMF_TEXTURE_WRAP, video::ETC_REPEAT);
160 //g_tile_materials[i].setFlag(video::EMF_ANISOTROPIC_FILTER, false);
162 g_tile_materials[i].setTexture(0, t);
165 g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
166 //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
169 video::SMaterial & tile_material_get(u32 i)
171 assert(i < TILES_COUNT);
173 return g_tile_materials[i];