From: Perttu Ahola Date: Mon, 24 Jan 2011 11:32:11 +0000 (+0200) Subject: Mainly some texture tweaking X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=24e41ab4c892a7cecee2d4e5e625afd83de43034;p=zefram%2Fminetest%2Fminetest_engine.git Mainly some texture tweaking --- diff --git a/data/coalstone.png b/data/coalstone.png index c993a02f..0c62a192 100644 Binary files a/data/coalstone.png and b/data/coalstone.png differ diff --git a/data/grass.png b/data/grass.png index 30ef3859..91cc0c0f 100644 Binary files a/data/grass.png and b/data/grass.png differ diff --git a/data/grass_footsteps.png b/data/grass_footsteps.png index 26bd236c..57e063d8 100644 Binary files a/data/grass_footsteps.png and b/data/grass_footsteps.png differ diff --git a/data/grass_side.png b/data/grass_side.png new file mode 100644 index 00000000..ee12491e Binary files /dev/null and b/data/grass_side.png differ diff --git a/data/leaves.png b/data/leaves.png index 086da809..ecd1f9a7 100644 Binary files a/data/leaves.png and b/data/leaves.png differ diff --git a/data/mud_with_grass.png b/data/mud_with_grass.png deleted file mode 100644 index 60ae4eec..00000000 Binary files a/data/mud_with_grass.png and /dev/null differ diff --git a/data/stone.png b/data/stone.png index daf2cceb..c7a453e3 100644 Binary files a/data/stone.png and b/data/stone.png differ diff --git a/data/water.png b/data/water.png index 98cda277..6b693f19 100644 Binary files a/data/water.png and b/data/water.png differ diff --git a/src/constants.h b/src/constants.h index 3cb28506..f90b278d 100644 --- a/src/constants.h +++ b/src/constants.h @@ -32,6 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define DEBUGFILE "debug.txt" +#define WATER_ALPHA 160 + // Define for simulating the quirks of sending through internet. // Causes the socket class to deliberately drop random packets. // This disables unit testing of socket and connection. diff --git a/src/irrlichtwrapper.cpp b/src/irrlichtwrapper.cpp index fe4ff277..e26cbfd1 100644 --- a/src/irrlichtwrapper.cpp +++ b/src/irrlichtwrapper.cpp @@ -175,6 +175,40 @@ video::ITexture * CrackTextureMod::make(video::ITexture *original, return newtexture; } +video::ITexture * SideGrassTextureMod::make(video::ITexture *original, + const char *newname, video::IVideoDriver* driver) +{ + // Size of the base image + core::dimension2d dim(16, 16); + // Position to copy the grass to in the base image + core::position2d pos_base(0, 0); + // Position to copy the grass from in the grass image + core::position2d pos_other(0, 0); + + video::IImage *baseimage = driver->createImage(original, pos_base, dim); + assert(baseimage); + + video::IImage *grassimage = driver->createImageFromFile(porting::getDataPath("grass_side.png").c_str()); + assert(grassimage); + + // Then copy the right part of grassimage to baseimage + + grassimage->copyToWithAlpha(baseimage, v2s32(0,0), + core::rect(pos_other, dim), + video::SColor(255,255,255,255), + NULL); + + grassimage->drop(); + + // Create texture from resulting image + + video::ITexture *newtexture = driver->addTexture(newname, baseimage); + + baseimage->drop(); + + return newtexture; +} + video::ITexture * ProgressBarTextureMod::make(video::ITexture *original, const char *newname, video::IVideoDriver* driver) { diff --git a/src/irrlichtwrapper.h b/src/irrlichtwrapper.h index ce54b70c..97607e57 100644 --- a/src/irrlichtwrapper.h +++ b/src/irrlichtwrapper.h @@ -97,6 +97,16 @@ struct CrackTextureMod: public TextureMod u16 progression; }; +struct SideGrassTextureMod: public TextureMod +{ + SideGrassTextureMod() + { + } + + virtual video::ITexture * make(video::ITexture *original, + const char *newname, video::IVideoDriver* driver); +}; + struct ProgressBarTextureMod: public TextureMod { // value is from 0.0 to 1.0 diff --git a/src/main.cpp b/src/main.cpp index 7c5f6bf3..092d6298 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,9 +76,6 @@ SUGG: Split MapBlockObject serialization to to-client and to-disk - This will allow saving ages of rats on disk but not sending them to clients -SUGG: Implement lighting using VoxelManipulator - - Would it be significantly faster? - SUGG: MovingObject::move and Player::move are basically the same. combine them. @@ -168,6 +165,8 @@ TODO: Make fetching sector's blocks more efficient when rendering sectors that have very large amounts of blocks (on client) - Is this necessary at all? +TODO: Flowing water animation + Configuration: -------------- @@ -231,8 +230,8 @@ Block object server side: - TODO: For incoming blocks, time difference is calculated and objects are stepped according to it. -Map generator: --------------- +Map: +---- NOTE: There are some lighting-related todos and fixmes in ServerMap::emergeBlock. And there always will be. 8) @@ -245,6 +244,8 @@ TODO: Map generator version 2 - Cliffs, arcs - There could be a certain height (to which mountains only reach) where some minerals are found + - Create a system that allows a huge amount of different "map + generator modules/filters" TODO: Change AttributeList to split the area into smaller sections so that searching won't be as heavy. @@ -256,6 +257,10 @@ FIXME: The new pre-sunlight-propagation code messes up with initial TODO: Remove HMParams +TODO: Flowing water to actually contain flow direction information + +TODO: Faster lighting using VoxelManipulator + Doing now: ---------- @@ -1532,8 +1537,7 @@ int main(int argc, char *argv[]) */ init_content_inventory_texture_paths(); - init_tile_texture_paths(); - tile_materials_preload(g_irrlicht); + init_tile_textures(); /* GUI stuff diff --git a/src/map.cpp b/src/map.cpp index 5655ee9e..09fb154a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1624,7 +1624,7 @@ void Map::transformLiquids(core::map & modified_blocks) } // If n2_changed to bottom, don't flow anywhere else - if(to_bottom && flowed) + if(to_bottom && flowed && !is_source) break; }catch(InvalidPositionException &e) @@ -1770,7 +1770,7 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): float randmax = 0; float randfactor = 0; - if(myrand()%4 == 0) + if(myrand()%5 == 0) { baseheight = 100; randmax = 50; @@ -2602,7 +2602,7 @@ continue_generating: (float)(myrand()%ued)+0.5 ); s16 min_d = 0; - s16 max_d = 6; + s16 max_d = 4; s16 rs = (myrand()%(max_d-min_d+1))+min_d; v3f vec = rp - orp; diff --git a/src/mapblock.cpp b/src/mapblock.cpp index f18cb2fd..620c29fd 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -268,7 +268,7 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p, if(tile.id == TILE_WATER) { - alpha = 128; + alpha = WATER_ALPHA; } video::SColor c = video::SColor(alpha,li,li,li); @@ -797,7 +797,7 @@ void MapBlock::updateMesh(u32 daynight_ratio) }catch(InvalidPositionException &e){} u8 l = decode_light(n.getLightBlend(daynight_ratio)); - video::SColor c(128,l,l,l); + video::SColor c(WATER_ALPHA,l,l,l); // Neighbor water levels (key = relative position) // Includes current node diff --git a/src/tile.cpp b/src/tile.cpp index 90de1164..79d68d4c 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., // A mapping from tiles to paths of textures -const char * g_tile_texture_filenames[TILES_COUNT] = +/*const char * g_tile_texture_filenames[TILES_COUNT] = { NULL, "stone.png", @@ -37,13 +37,19 @@ const char * g_tile_texture_filenames[TILES_COUNT] = "mese.png", "mud.png", "tree_top.png", - "mud_with_grass.png", + "mud.png_sidegrass", "cloud.png", "coalstone.png", "wood.png", -}; +};*/ + +/* + These can either be real paths or generated names of preloaded + textures (like "mud.png_sidegrass") +*/ +std::string g_tile_texture_paths[TILES_COUNT]; -std::string g_tile_texture_path_strings[TILES_COUNT]; +/*std::string g_tile_texture_path_strings[TILES_COUNT]; const char * g_tile_texture_paths[TILES_COUNT] = {0}; void init_tile_texture_paths() @@ -60,30 +66,86 @@ void init_tile_texture_paths() g_tile_texture_path_strings[i].c_str(); } } -} +}*/ const char * tile_texture_path_get(u32 i) { assert(i < TILES_COUNT); - return g_tile_texture_paths[i]; + //return g_tile_texture_paths[i]; + return g_tile_texture_paths[i].c_str(); } // A mapping from tiles to materials // Initialized at run-time. video::SMaterial g_tile_materials[TILES_COUNT]; -void tile_materials_preload(IrrlichtWrapper *irrlicht) +enum TileTextureModID +{ + TTMID_NONE, + TTMID_SIDEGRASS, +}; + +struct TileTextureSpec +{ + const char *filename; + enum TileTextureModID mod; +}; + +/* + Initializes g_tile_texture_paths with paths of textures, + generates generated textures and creates the tile material array. +*/ +void init_tile_textures() { + TileTextureSpec tile_texture_specs[TILES_COUNT] = + { + {NULL, TTMID_NONE}, + {"stone.png", TTMID_NONE}, + {"water.png", TTMID_NONE}, + {"grass.png", TTMID_NONE}, + {"tree.png", TTMID_NONE}, + {"leaves.png", TTMID_NONE}, + {"grass_footsteps.png", TTMID_NONE}, + {"mese.png", TTMID_NONE}, + {"mud.png", TTMID_NONE}, + {"tree_top.png", TTMID_NONE}, + {"mud.png", TTMID_SIDEGRASS}, + {"cloud.png", TTMID_NONE}, + {"coalstone.png", TTMID_NONE}, + {"wood.png", TTMID_NONE}, + }; + + for(s32 i=0; igetTexture(TextureSpec(path + mod_postfix, + path, mod)); + } + g_tile_texture_paths[i] = path + mod_postfix; + } + } + for(s32 i=0; igetTexture(path); + t = g_irrlicht->getTexture(path); assert(t != NULL); } @@ -99,7 +161,7 @@ void tile_materials_preload(IrrlichtWrapper *irrlicht) g_tile_materials[i].setTexture(0, t); } - + g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; } diff --git a/src/tile.h b/src/tile.h index b6dcb249..5869c03e 100644 --- a/src/tile.h +++ b/src/tile.h @@ -99,13 +99,10 @@ struct TileSpec Functions */ -void init_tile_texture_paths(); +void init_tile_textures(); const char * tile_texture_path_get(u32 i); -// Initializes g_tile_materials -void tile_materials_preload(IrrlichtWrapper *irrlicht); - video::SMaterial & tile_material_get(u32 i); #endif