video::ITexture * CrackTextureMod::make(video::ITexture *original,
const char *newname, video::IVideoDriver* driver)
{
+ // Size of the base image
core::dimension2d<u32> dim(16, 16);
+ // Size of the crack image
+ //core::dimension2d<u32> dim_crack(16, 16 * CRACK_ANIMATION_LENGTH);
+ // Position to copy the crack to in the base image
core::position2d<s32> pos_base(0, 0);
+ // Position to copy the crack from in the crack image
core::position2d<s32> pos_other(0, 16 * progression);
video::IImage *baseimage = driver->createImage(original, pos_base, dim);
assert(baseimage);
+
+ video::IImage *crackimage = driver->createImageFromFile("../data/crack.png");
+ assert(crackimage);
+#if 0
video::ITexture *other = driver->getTexture("../data/crack.png");
dstream<<__FUNCTION_NAME<<": crack texture size is "
// the image to fit a texture or something...
video::IImage *otherimage = driver->createImage(
other, core::position2d<s32>(0,0), other->getSize());
- // This should work on more systems
- // - no, it doesn't, output is more random.
- /*video::IImage *otherimage = driver->createImage(
- other, core::position2d<s32>(0,0),
- v2u32(16, CRACK_ANIMATION_LENGTH * 16));*/
assert(otherimage);
+
+ // Now, the image might be 80 or 128 high depending on the computer
+ // Let's make an image of the right size and copy the possibly
+ // wrong sized one with scaling
+ // NOTE: This is an ugly hack.
+
+ video::IImage *crackimage = driver->createImage(
+ baseimage->getColorFormat(), dim_crack);
- /*core::rect<s32> clip_rect(v2s32(0,0), dim);
- otherimage->copyToWithAlpha(baseimage, v2s32(0,0),
- core::rect<s32>(pos_other, dim),
- video::SColor(255,255,255,255),
- &clip_rect);*/
+ assert(crackimage);
- otherimage->copyToWithAlpha(baseimage, v2s32(0,0),
+ otherimage->copyToScaling(crackimage);
+ otherimage->drop();
+#endif
+
+ // Then copy the right part of crackimage to baseimage
+
+ crackimage->copyToWithAlpha(baseimage, v2s32(0,0),
core::rect<s32>(pos_other, dim),
video::SColor(255,255,255,255),
NULL);
- otherimage->drop();
+ crackimage->drop();
+
+ // Create texture from resulting image
video::ITexture *newtexture = driver->addTexture(newname, baseimage);
\r
TODO: When player dies, throw items on map\r
\r
+TODO: Optimize day/night mesh updating somehow\r
+ - create copies of all textures for all lighting values and only\r
+ change texture for material?\r
+ - Umm... the collecting of the faces is the slow part\r
+ -> what about just changing the color values of the existing\r
+ meshbuffers? It should go quite fast.\r
+\r
TODO: Map generator version 2\r
\r
Doing now:\r
bool first_loop_after_window_activation = true;\r
\r
// Time is in milliseconds\r
- // NOTE: getRealTime() without run()s causes strange problems in wine\r
- // NOTE: Have to call run() between calls of this to update the timer\r
+ // NOTE: getRealTime() causes strange problems in wine (imprecision?)\r
+ // NOTE: So we have to use getTime() and call run()s between them\r
u32 lasttime = device->getTimer()->getTime();\r
\r
while(device->run())\r
v3f camera_direction = v3f(0,0,1);\r
camera_direction.rotateYZBy(camera_pitch);\r
camera_direction.rotateXZBy(camera_yaw);\r
-\r
+ \r
+ // This is at the height of the eyes of the current figure\r
v3f camera_position =\r
player_position + v3f(0, BS+BS/2, 0);\r
+ // This is more like in minecraft\r
+ /*v3f camera_position =\r
+ player_position + v3f(0, BS+BS*0.65, 0);*/\r
\r
camera->setPosition(camera_position);\r
// *100.0 helps in large map coordinates\r