Mainly some texture tweaking
authorPerttu Ahola <celeron55@gmail.com>
Mon, 24 Jan 2011 11:32:11 +0000 (13:32 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 24 Jan 2011 11:32:11 +0000 (13:32 +0200)
16 files changed:
data/coalstone.png
data/grass.png
data/grass_footsteps.png
data/grass_side.png [new file with mode: 0644]
data/leaves.png
data/mud_with_grass.png [deleted file]
data/stone.png
data/water.png
src/constants.h
src/irrlichtwrapper.cpp
src/irrlichtwrapper.h
src/main.cpp
src/map.cpp
src/mapblock.cpp
src/tile.cpp
src/tile.h

index c993a02f04648f724961ca602c489a917d54fb86..0c62a192f605f02f7b24079808e034961b037885 100644 (file)
Binary files a/data/coalstone.png and b/data/coalstone.png differ
index 30ef385914f985fd39b85e23b5adfec17512494c..91cc0c0fc11637a0afb2b2a29788b79f31d65293 100644 (file)
Binary files a/data/grass.png and b/data/grass.png differ
index 26bd236c5b2be20e16cd8d23833666d3d6649ab6..57e063d8cf729a82c24c700bd49a025feece82fd 100644 (file)
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 (file)
index 0000000..ee12491
Binary files /dev/null and b/data/grass_side.png differ
index 086da80918c5f2e2c746d752bd7c3530566ca547..ecd1f9a730de19ff4edfe3a4fab9783419e94855 100644 (file)
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 (file)
index 60ae4ee..0000000
Binary files a/data/mud_with_grass.png and /dev/null differ
index daf2cceb88a063ad0c0acb0a44d3afb1703bd413..c7a453e3f7be95a2dd091542441108ad05b1bca5 100644 (file)
Binary files a/data/stone.png and b/data/stone.png differ
index 98cda2776b2204e58e3815c623db3c08010dacc9..6b693f196e6827c2eeafee2c2b71ef55c9e8c992 100644 (file)
Binary files a/data/water.png and b/data/water.png differ
index 3cb2850659571061f91bcfaf6ddc57d6f904843b..f90b278d2b25ade145f26c0ce1744e1431a84ec2 100644 (file)
@@ -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.
index fe4ff27712051b75e1163c2e89eb3a8579f51ef4..e26cbfd150040b2cf76b6ba9232b5c74fbf5f4d3 100644 (file)
@@ -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<u32> dim(16, 16);
+       // Position to copy the grass to in the base image
+       core::position2d<s32> pos_base(0, 0);
+       // Position to copy the grass from in the grass image
+       core::position2d<s32> 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<s32>(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)
 {
index ce54b70c0c86bb235ced5b35e2e52d20f7a55b55..97607e579037954d4a9d2949b7967b641baab2ae 100644 (file)
@@ -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
index 7c5f6bf3e0ec608748dab2e59710eccfc7abfc04..092d62988bb05a31ebadd33eb7c59306bba790fa 100644 (file)
@@ -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\r
            them to clients\r
 \r
-SUGG: Implement lighting using VoxelManipulator\r
-      - Would it be significantly faster?\r
-\r
 SUGG: MovingObject::move and Player::move are basically the same.\r
       combine them.\r
 \r
@@ -168,6 +165,8 @@ TODO: Make fetching sector's blocks more efficient when rendering
       sectors that have very large amounts of blocks (on client)\r
          - Is this necessary at all?\r
 \r
+TODO: Flowing water animation\r
+\r
 Configuration:\r
 --------------\r
 \r
@@ -231,8 +230,8 @@ Block object server side:
            - TODO: For incoming blocks, time difference is calculated and\r
              objects are stepped according to it.\r
 \r
-Map generator:\r
---------------\r
+Map:\r
+----\r
 \r
 NOTE: There are some lighting-related todos and fixmes in\r
       ServerMap::emergeBlock. And there always will be. 8)\r
@@ -245,6 +244,8 @@ TODO: Map generator version 2
     - Cliffs, arcs\r
        - There could be a certain height (to which mountains only reach)\r
          where some minerals are found\r
+       - Create a system that allows a huge amount of different "map\r
+         generator modules/filters"\r
 \r
 TODO: Change AttributeList to split the area into smaller sections so\r
       that searching won't be as heavy.\r
@@ -256,6 +257,10 @@ FIXME: The new pre-sunlight-propagation code messes up with initial
 \r
 TODO: Remove HMParams\r
 \r
+TODO: Flowing water to actually contain flow direction information\r
+\r
+TODO: Faster lighting using VoxelManipulator\r
+\r
 Doing now:\r
 ----------\r
 \r
@@ -1532,8 +1537,7 @@ int main(int argc, char *argv[])
        */\r
 \r
        init_content_inventory_texture_paths();\r
-       init_tile_texture_paths();\r
-       tile_materials_preload(g_irrlicht);\r
+       init_tile_textures();\r
 \r
        /*\r
                GUI stuff\r
index 5655ee9ec8d638e862cfe475fe547da731daad01..09fb154aadff189512e35360b93b8ff1b7bb9a33 100644 (file)
@@ -1624,7 +1624,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & 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;
index f18cb2fdd305c31665534d821985a5b5cc7f85dd..620c29fdd57ecb9e73bd695a9cd33cd42ac325be 100644 (file)
@@ -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
index 90de1164227d362d51d6f5aa0fd5aa4454067673..79d68d4c3cc46bce1e49c3a2146d714399e38e89 100644 (file)
@@ -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; i<TILES_COUNT; i++)
+       {
+               const char *filename = tile_texture_specs[i].filename;
+               enum TileTextureModID mod_id = tile_texture_specs[i].mod;
+
+               if(filename != NULL && std::string("") != filename)
+               {
+                       std::string path = porting::getDataPath(filename);
+                       std::string mod_postfix = "";
+                       if(mod_id == TTMID_SIDEGRASS)
+                       {
+                               mod_postfix = "_sidegrass";
+                               // Generate texture
+                               TextureMod *mod = new SideGrassTextureMod();
+                               g_irrlicht->getTexture(TextureSpec(path + mod_postfix,
+                                               path, mod));
+                       }
+                       g_tile_texture_paths[i] = path + mod_postfix;
+               }
+       }
+
        for(s32 i=0; i<TILES_COUNT; i++)
        {
                const char *path = tile_texture_path_get(i);
 
                video::ITexture *t = NULL;
 
-               if(path != NULL)
+               if(path != NULL && std::string("") != path)
                {
-                       t = irrlicht->getTexture(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;
 }
index b6dcb249acee73ff7f2254bbc9de996e86c7273c..5869c03eed027b50322eeb85cd1e324976c1e4fa 100644 (file)
@@ -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