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.
28 ContentFeatures::~ContentFeatures()
34 struct ContentFeatures g_content_features[256];
36 ContentFeatures & content_features(u8 i)
38 return g_content_features[i];
41 void init_mapnode(IIrrlichtWrapper *irrlicht)
43 bool new_style_water = g_settings.getBool("new_style_water");
44 bool new_style_leaves = g_settings.getBool("new_style_leaves");
47 ContentFeatures *f = NULL;
50 f = &g_content_features[i];
51 f->setAllTextures(irrlicht->getTextureId("stone.png"));
52 f->param_type = CPT_MINERAL;
53 f->is_ground_content = true;
56 f = &g_content_features[i];
57 f->setAllTextures(TextureSpec(irrlicht->getTextureId("mud.png"),
58 irrlicht->getTextureId("grass_side.png")));
59 f->setTexture(0, irrlicht->getTextureId("grass.png"));
60 f->setTexture(1, irrlicht->getTextureId("mud.png"));
61 f->setInventoryTexture(irrlicht->getTextureId("grass.png"));
62 f->param_type = CPT_MINERAL;
63 f->is_ground_content = true;
65 i = CONTENT_GRASS_FOOTSTEPS;
66 f = &g_content_features[i];
67 f->setAllTextures(TextureSpec(irrlicht->getTextureId("mud.png"),
68 irrlicht->getTextureId("grass_side.png")));
69 f->setTexture(0, irrlicht->getTextureId("grass_footsteps.png"));
70 f->setTexture(1, irrlicht->getTextureId("mud.png"));
71 f->setInventoryTexture(irrlicht->getTextureId("grass_footsteps.png"));
72 f->param_type = CPT_MINERAL;
73 f->is_ground_content = true;
76 f = &g_content_features[i];
77 f->setAllTextures(irrlicht->getTextureId("mud.png"));
78 f->param_type = CPT_MINERAL;
79 f->is_ground_content = true;
82 f = &g_content_features[i];
83 f->setAllTextures(irrlicht->getTextureId("sand.png"));
84 f->param_type = CPT_MINERAL;
85 f->is_ground_content = true;
88 f = &g_content_features[i];
89 f->setAllTextures(irrlicht->getTextureId("tree.png"));
90 f->setTexture(0, irrlicht->getTextureId("tree_top.png"));
91 f->setTexture(1, irrlicht->getTextureId("tree_top.png"));
92 f->setInventoryTexture(irrlicht->getTextureId("tree_top.png"));
93 f->param_type = CPT_MINERAL;
94 f->is_ground_content = true;
97 f = &g_content_features[i];
98 f->light_propagates = true;
99 //f->param_type = CPT_MINERAL;
100 f->param_type = CPT_LIGHT;
101 f->is_ground_content = true;
104 f->solidness = 0; // drawn separately, makes no faces
108 f->setAllTextures(irrlicht->getTextureId("leaves.png"));
112 t.spec = TextureSpec(irrlicht->getTextureId("leaves.png"));
113 //t.material_type = MATERIAL_ALPHA_SIMPLE;
114 //t.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
118 i = CONTENT_COALSTONE;
119 f = &g_content_features[i];
120 //f->translate_to = new MapNode(CONTENT_STONE, MINERAL_COAL);
121 f->setAllTextures(TextureSpec(irrlicht->getTextureId("coal.png"),
122 irrlicht->getTextureId("mineral_coal.png")));
123 f->is_ground_content = true;
126 f = &g_content_features[i];
127 f->setAllTextures(irrlicht->getTextureId("wood.png"));
128 f->is_ground_content = true;
131 f = &g_content_features[i];
132 f->setAllTextures(irrlicht->getTextureId("mese.png"));
133 f->is_ground_content = true;
136 f = &g_content_features[i];
137 f->setAllTextures(irrlicht->getTextureId("cloud.png"));
138 f->is_ground_content = true;
141 f = &g_content_features[i];
142 f->param_type = CPT_LIGHT;
143 f->light_propagates = true;
144 f->sunlight_propagates = true;
147 f->pointable = false;
149 f->buildable_to = true;
152 f = &g_content_features[i];
153 f->setInventoryTexture(irrlicht->getTextureId("water.png"));
154 f->param_type = CPT_LIGHT;
155 f->light_propagates = true;
156 f->solidness = 0; // Drawn separately, makes no faces
158 f->pointable = false;
160 f->buildable_to = true;
161 f->liquid_type = LIQUID_FLOWING;
163 i = CONTENT_WATERSOURCE;
164 f = &g_content_features[i];
165 f->setInventoryTexture(irrlicht->getTextureId("water.png"));
168 f->solidness = 0; // drawn separately, makes no faces
172 f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
174 t.spec = TextureSpec(irrlicht->getTextureId("water.png"));
175 t.alpha = WATER_ALPHA;
176 t.material_type = MATERIAL_ALPHA_VERTEX;
177 t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
181 f->param_type = CPT_LIGHT;
182 f->light_propagates = true;
184 f->pointable = false;
186 f->buildable_to = true;
187 f->liquid_type = LIQUID_SOURCE;
190 f = &g_content_features[i];
191 f->setInventoryTexture(irrlicht->getTextureId("torch_on_floor.png"));
192 f->param_type = CPT_LIGHT;
193 f->light_propagates = true;
194 f->solidness = 0; // drawn separately, makes no faces
196 f->wall_mounted = true;
200 TileSpec MapNode::getTile(v3s16 dir)
206 if(dir == v3s16(0,0,0))
208 else if(dir == v3s16(0,1,0))
210 else if(dir == v3s16(0,-1,0))
212 else if(dir == v3s16(1,0,0))
214 else if(dir == v3s16(-1,0,0))
216 else if(dir == v3s16(0,0,1))
218 else if(dir == v3s16(0,0,-1))
223 spec = content_features(d).tiles[0];
225 spec = content_features(d).tiles[dir_i];
227 if(content_features(d).param_type == CPT_MINERAL)
229 u8 mineral = param & 0x1f;
230 // Add mineral block texture
231 textureid_t tid = mineral_block_texture(mineral);
233 spec.spec.addTid(tid);
239 u8 MapNode::getMineral()
241 if(content_features(d).param_type == CPT_MINERAL)
249 // Pointers to c_str()s g_content_features[i].inventory_image_path
250 //const char * g_content_inventory_texture_paths[USEFUL_CONTENT_COUNT] = {0};
252 void init_content_inventory_texture_paths()
254 dstream<<"DEPRECATED "<<__FUNCTION_NAME<<std::endl;
255 /*for(u16 i=0; i<USEFUL_CONTENT_COUNT; i++)
257 g_content_inventory_texture_paths[i] =
258 g_content_features[i].inventory_image_path.c_str();