From 3b0bff2f743a3abf100368f94efafa7c2843a9b7 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 21 Dec 2010 02:25:47 +0200 Subject: Cracking blocks while digging --- src/irrlichtwrapper.cpp | 71 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 16 deletions(-) (limited to 'src/irrlichtwrapper.cpp') diff --git a/src/irrlichtwrapper.cpp b/src/irrlichtwrapper.cpp index 69b08a6d8..51511eb34 100644 --- a/src/irrlichtwrapper.cpp +++ b/src/irrlichtwrapper.cpp @@ -17,7 +17,8 @@ void IrrlichtWrapper::Run() GetRequest request = m_get_texture_queue.pop(); - dstream<<"got request with key.name="<getTexture(spec.path.c_str()); } - return driver->getTexture(spec.path.c_str()); + + dstream<<"IrrlichtWrapper::getTextureDirect: Loading and modifying " + "texture "<getTexture(spec.path.c_str()); + video::ITexture *result = spec.mod->make(base, spec.name.c_str(), driver); + + delete spec.mod; + + return result; } video::ITexture * CrackTextureMod::make(video::ITexture *original, - video::IVideoDriver* driver) + const char *newname, video::IVideoDriver* driver) { - //TODO - dstream<<__FUNCTION_NAME< dim(16, 16); + core::position2d pos_base(0, 0); + core::position2d pos_other(0, 16 * progression); + + video::IImage *baseimage = driver->createImage(original, pos_base, dim); + assert(baseimage); + + video::ITexture *other = driver->getTexture("../data/crack.png"); + // We have to get the whole texture because getting a smaller area + // messes the whole thing. It is probably a bug in Irrlicht. + video::IImage *otherimage = driver->createImage( + other, core::position2d(0,0), other->getSize()); + + assert(otherimage); + + /*core::rect clip_rect(v2s32(0,0), dim); + otherimage->copyToWithAlpha(baseimage, v2s32(0,0), + core::rect(pos_other, dim), + video::SColor(255,255,255,255), + &clip_rect);*/ + + otherimage->copyToWithAlpha(baseimage, v2s32(0,0), + core::rect(pos_other, dim), + video::SColor(255,255,255,255), + NULL); + + otherimage->drop(); + + video::ITexture *newtexture = driver->addTexture(newname, baseimage); + + baseimage->drop(); + + return newtexture; } #if 0 -- cgit v1.2.3