Mainly some texture tweaking

master
Perttu Ahola 2011-01-24 13:32:11 +02:00
parent 4a952f22d7
commit 24e41ab4c8
16 changed files with 135 additions and 26 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 856 B

BIN
data/grass_side.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 913 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View 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.

View 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)
{

View 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

View 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
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

View 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;

View 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

View 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",
};
};*/
std::string g_tile_texture_path_strings[TILES_COUNT];
/*
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];
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;
}

View 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