aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Masterserver updateproller2013-10-18
|
* Fix object duplication bug (at least in the most reproducible UFO case)Perttu Ahola2013-10-17
|
* Add support for parameter 'visual_scale' for drawtypes 'signlike' and ↵Sokomine2013-10-14
| | | | 'torchlike' like used for drawtype 'plantlike'
* FIx wrong error message on invalid use of the formspec element image_buttonRealBadAngel2013-10-07
|
* Remove mapgen_air alias (#935)0gb.us2013-10-05
|
* Pass VERSION_EXTRA to GenerateVersion.cmakeKahrl2013-09-29
|
* Add set_name(), set_count(), set_wear() and set_metadata() to Lua ItemStackPilzAdam2013-09-28
|
* Add --version optionKahrl2013-09-28
|
* Show git hash in version string at top left corner of windowKahrl2013-09-28
|
* Lower the default max_users from 100 to 15ShadowNinja2013-09-28
|
* Add curl, freetype and luaJIT to CMAKE_BUILD_INFOPilzAdam2013-09-28
|
* Re-fix hud_change stat argument retrievalkwolekr2013-09-26
| | | | | Conflicts: src/script/lua_api/l_object.cpp
* Fix compiling issue of MSVCBlockMen2013-09-23
|
* Add option to scale image to percentage valuesBlockMen2013-09-20
|
* Fix null dereference in weather update functionsproller2013-09-18
|
* Fix some warnings and other minor detailskwolekr2013-09-16
|
* Weather: Clean up getHeat/getHumidity somewhatkwolekr2013-09-16
|
* Use cached "weather" settingproller2013-09-17
|
* Fog depend on humidityproller2013-09-17
|
* Add configurable PRAGMA synchronous =proller2013-09-17
|
* Always use builtin JThread librarykwolekr2013-09-15
|
* Change mainmenu texture handling + small misc changesKahrl2013-09-11
| | | | | | | | | | | | | | Texture names must now be escaped in formspec elements image[], background[], image_button[], image_button_exit[]. Instead of special-case handling of texture loading (and unloading which was missing) in guiFormSpecMenu.cpp, use the newly created ISimpleTextureSource interface which is a minimal subset of ITextureSource. There is an implementation of this interface used by GUIEngine (MenuTextureSource). Fix an off-by-one bug in unescape_string; it caused requests for a texture called "\0".
* Fix hotbar padding at bottomBlockMen2013-09-10
|
* Add offset to automatic_face_movement_dirPilzAdam2013-09-10
|
* Allow non-string arguments for minetest.is_yes()PilzAdam2013-09-10
|
* Add Settings interface for LuaPilzAdam2013-09-10
|
* Handle --migrate even when compiled without leveldb supportKahrl2013-09-10
|
* Remove assert warning in leveldb wonderlandKahrl2013-09-10
|
* Fix loading leveldb worldsKahrl2013-09-10
|
* Fix broken build due to missing mapsector.h includeKahrl2013-09-10
|
* Add license headers and remove useless includesKahrl2013-09-10
|
* Use system-wide LevelDB instead of bundled oneSfan52013-09-09
|
* Make --migrate update world.mt tooSfan52013-09-09
|
* Add note about --migrate only working with minetestserver or --serverSfan52013-09-09
|
* Fix 'Unknown map backend' error when using Configure menu right after ↵Sfan52013-09-09
| | | | creating world
* Use STL containers instead of irr::core::listSfan52013-09-09
|
* Add message that LevelDB is not supported on WindowsSfan52013-09-09
|
* Make it compileSfan52013-09-09
|
* Add dummy and LevelDB database backendsIlya Zhuravlev2013-09-09
|
* Add fallback font support for some languages.Ilya Zhuravlev2013-09-08
|
* Add minetest.get_gametime() API function, that returns the number of seconds ↵Novatux2013-09-08
| | | | since the world was created.
* Standardized method of getting node info in dungeon mapgen.0gb.us2013-09-06
|
* Fix selectionbox not honoring anaglyph mode 3d distortionsapier2013-09-05
|
* Fix crash on lua exceptionsapier2013-09-05
|
* Use player:set_hotbar_image() instead of hardcoded hotbar.pngPilzAdam2013-09-05
|
* Fix remnants of s32 enable_shadersKahrl2013-09-04
|
* Fix enable_fog = false not having any effect when shaders are enabledKahrl2013-09-03
|
* Server::ProcessData(): call getBanName once instead of twice (#639)Ilya2013-09-03
|
* Add minetest.parse_json, engine.parse_jsonKahrl2013-09-02
|
* Use wstring for vertlabelsPilzAdam2013-08-31
|
/span>::S3DVertex(+0.5,-0.5,+0.5, 1,0,0, c, 1,1), // Left video::S3DVertex(-0.5,-0.5,-0.5, -1,0,0, c, 1,1), video::S3DVertex(-0.5,-0.5,+0.5, -1,0,0, c, 0,1), video::S3DVertex(-0.5,+0.5,+0.5, -1,0,0, c, 0,0), video::S3DVertex(-0.5,+0.5,-0.5, -1,0,0, c, 1,0), // Back video::S3DVertex(-0.5,-0.5,+0.5, 0,0,1, c, 1,1), video::S3DVertex(+0.5,-0.5,+0.5, 0,0,1, c, 0,1), video::S3DVertex(+0.5,+0.5,+0.5, 0,0,1, c, 0,0), video::S3DVertex(-0.5,+0.5,+0.5, 0,0,1, c, 1,0), // Front video::S3DVertex(-0.5,-0.5,-0.5, 0,0,-1, c, 0,1), video::S3DVertex(-0.5,+0.5,-0.5, 0,0,-1, c, 0,0), video::S3DVertex(+0.5,+0.5,-0.5, 0,0,-1, c, 1,0), video::S3DVertex(+0.5,-0.5,-0.5, 0,0,-1, c, 1,1), }; u16 indices[6] = {0,1,2,2,3,0}; scene::SMesh *mesh = new scene::SMesh(); for (u32 i=0; i<6; ++i) { scene::IMeshBuffer *buf = new scene::SMeshBuffer(); buf->append(vertices + 4 * i, 4, indices, 6); // Set default material buf->getMaterial().setFlag(video::EMF_LIGHTING, false); buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; // Add mesh buffer to mesh mesh->addMeshBuffer(buf); buf->drop(); } scene::SAnimatedMesh *anim_mesh = new scene::SAnimatedMesh(mesh); mesh->drop(); scaleMesh(anim_mesh, scale); // also recalculates bounding box return anim_mesh; } static scene::IAnimatedMesh* extrudeARGB(u32 twidth, u32 theight, u8 *data) { const s32 argb_wstep = 4 * twidth; const s32 alpha_threshold = 1; scene::IMeshBuffer *buf = new scene::SMeshBuffer(); video::SColor c(255,255,255,255); // Front and back { video::S3DVertex vertices[8] = { video::S3DVertex(-0.5,-0.5,-0.5, 0,0,-1, c, 0,1), video::S3DVertex(-0.5,+0.5,-0.5, 0,0,-1, c, 0,0), video::S3DVertex(+0.5,+0.5,-0.5, 0,0,-1, c, 1,0), video::S3DVertex(+0.5,-0.5,-0.5, 0,0,-1, c, 1,1), video::S3DVertex(+0.5,-0.5,+0.5, 0,0,+1, c, 1,1), video::S3DVertex(+0.5,+0.5,+0.5, 0,0,+1, c, 1,0), video::S3DVertex(-0.5,+0.5,+0.5, 0,0,+1, c, 0,0), video::S3DVertex(-0.5,-0.5,+0.5, 0,0,+1, c, 0,1), }; u16 indices[12] = {0,1,2,2,3,0,4,5,6,6,7,4}; buf->append(vertices, 8, indices, 12); } // "Interior" // (add faces where a solid pixel is next to a transparent one) u8 *solidity = new u8[(twidth+2) * (theight+2)]; u32 wstep = twidth + 2; for (u32 y = 0; y < theight + 2; ++y) { u8 *scanline = solidity + y * wstep; if (y == 0 || y == theight + 1) { for (u32 x = 0; x < twidth + 2; ++x) scanline[x] = 0; } else { scanline[0] = 0; u8 *argb_scanline = data + (y - 1) * argb_wstep; for (u32 x = 0; x < twidth; ++x) scanline[x+1] = (argb_scanline[x*4+3] >= alpha_threshold); scanline[twidth + 1] = 0; } } // without this, there would be occasional "holes" in the mesh f32 eps = 0.01; for (u32 y = 0; y <= theight; ++y) { u8 *scanline = solidity + y * wstep + 1; for (u32 x = 0; x <= twidth; ++x) { if (scanline[x] && !scanline[x + wstep]) { u32 xx = x + 1; while (scanline[xx] && !scanline[xx + wstep]) ++xx; f32 vx1 = (x - eps) / (f32) twidth - 0.5; f32 vx2 = (xx + eps) / (f32) twidth - 0.5; f32 vy = 0.5 - (y - eps) / (f32) theight; f32 tx1 = x / (f32) twidth; f32 tx2 = xx / (f32) twidth; f32 ty = (y - 0.5) / (f32) theight; video::S3DVertex vertices[8] = { video::S3DVertex(vx1,vy,-0.5, 0,-1,0, c, tx1,ty), video::S3DVertex(vx2,vy,-0.5, 0,-1,0, c, tx2,ty), video::S3DVertex(vx2,vy,+0.5, 0,-1,0, c, tx2,ty), video::S3DVertex(vx1,vy,+0.5, 0,-1,0, c, tx1,ty), }; u16 indices[6] = {0,1,2,2,3,0}; buf->append(vertices, 4, indices, 6); x = xx - 1; } if (!scanline[x] && scanline[x + wstep]) { u32 xx = x + 1; while (!scanline[xx] && scanline[xx + wstep]) ++xx; f32 vx1 = (x - eps) / (f32) twidth - 0.5; f32 vx2 = (xx + eps) / (f32) twidth - 0.5; f32 vy = 0.5 - (y + eps) / (f32) theight; f32 tx1 = x / (f32) twidth; f32 tx2 = xx / (f32) twidth; f32 ty = (y + 0.5) / (f32) theight; video::S3DVertex vertices[8] = { video::S3DVertex(vx1,vy,-0.5, 0,1,0, c, tx1,ty), video::S3DVertex(vx1,vy,+0.5, 0,1,0, c, tx1,ty), video::S3DVertex(vx2,vy,+0.5, 0,1,0, c, tx2,ty), video::S3DVertex(vx2,vy,-0.5, 0,1,0, c, tx2,ty), }; u16 indices[6] = {0,1,2,2,3,0}; buf->append(vertices, 4, indices, 6); x = xx - 1; } } } for (u32 x = 0; x <= twidth; ++x) { u8 *scancol = solidity + x + wstep; for (u32 y = 0; y <= theight; ++y) { if (scancol[y * wstep] && !scancol[y * wstep + 1]) { u32 yy = y + 1; while (scancol[yy * wstep] && !scancol[yy * wstep + 1]) ++yy; f32 vx = (x - eps) / (f32) twidth - 0.5; f32 vy1 = 0.5 - (y - eps) / (f32) theight; f32 vy2 = 0.5 - (yy + eps) / (f32) theight; f32 tx = (x - 0.5) / (f32) twidth; f32 ty1 = y / (f32) theight; f32 ty2 = yy / (f32) theight; video::S3DVertex vertices[8] = { video::S3DVertex(vx,vy1,-0.5, 1,0,0, c, tx,ty1), video::S3DVertex(vx,vy1,+0.5, 1,0,0, c, tx,ty1), video::S3DVertex(vx,vy2,+0.5, 1,0,0, c, tx,ty2), video::S3DVertex(vx,vy2,-0.5, 1,0,0, c, tx,ty2), }; u16 indices[6] = {0,1,2,2,3,0}; buf->append(vertices, 4, indices, 6); y = yy - 1; } if (!scancol[y * wstep] && scancol[y * wstep + 1]) { u32 yy = y + 1; while (!scancol[yy * wstep] && scancol[yy * wstep + 1]) ++yy; f32 vx = (x + eps) / (f32) twidth - 0.5; f32 vy1 = 0.5 - (y - eps) / (f32) theight; f32 vy2 = 0.5 - (yy + eps) / (f32) theight; f32 tx = (x + 0.5) / (f32) twidth; f32 ty1 = y / (f32) theight; f32 ty2 = yy / (f32) theight; video::S3DVertex vertices[8] = { video::S3DVertex(vx,vy1,-0.5, -1,0,0, c, tx,ty1), video::S3DVertex(vx,vy2,-0.5, -1,0,0, c, tx,ty2), video::S3DVertex(vx,vy2,+0.5, -1,0,0, c, tx,ty2), video::S3DVertex(vx,vy1,+0.5, -1,0,0, c, tx,ty1), }; u16 indices[6] = {0,1,2,2,3,0}; buf->append(vertices, 4, indices, 6); y = yy - 1; } } } delete[] solidity; // Add to mesh scene::SMesh *mesh = new scene::SMesh(); mesh->addMeshBuffer(buf); buf->drop(); scene::SAnimatedMesh *anim_mesh = new scene::SAnimatedMesh(mesh); mesh->drop(); return anim_mesh; } scene::IAnimatedMesh* createExtrudedMesh(video::ITexture *texture, video::IVideoDriver *driver, v3f scale) { scene::IAnimatedMesh *mesh = NULL; core::dimension2d<u32> size = texture->getSize(); video::ECOLOR_FORMAT format = texture->getColorFormat(); if (format == video::ECF_A8R8G8B8) { // Texture is in the correct color format, we can pass it // to extrudeARGB right away. void *data = texture->lock(MY_ETLM_READ_ONLY); if (data == NULL) return NULL; mesh = extrudeARGB(size.Width, size.Height, (u8*) data); texture->unlock(); } else { video::IImage *img1 = driver->createImageFromData(format, size, texture->lock(MY_ETLM_READ_ONLY)); if (img1 == NULL) return NULL; // img1 is in the texture's color format, convert to 8-bit ARGB video::IImage *img2 = driver->createImage(video::ECF_A8R8G8B8, size); if (img2 == NULL) { img1->drop(); return NULL; } img1->copyTo(img2); img1->drop(); mesh = extrudeARGB(size.Width, size.Height, (u8*) img2->lock()); img2->unlock(); img2->drop(); } // Set default material mesh->getMeshBuffer(0)->getMaterial().setTexture(0, texture); mesh->getMeshBuffer(0)->getMaterial().setFlag(video::EMF_LIGHTING, false); mesh->getMeshBuffer(0)->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); mesh->getMeshBuffer(0)->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; scaleMesh(mesh, scale); // also recalculates bounding box return mesh; } void scaleMesh(scene::IMesh *mesh, v3f scale) { if(mesh == NULL) return; core::aabbox3d<f32> bbox; bbox.reset(0,0,0); u16 mc = mesh->getMeshBufferCount(); for(u16 j=0; j<mc; j++) { scene::IMeshBuffer *buf = mesh->getMeshBuffer(j); video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); u16 vc = buf->getVertexCount(); for(u16 i=0; i<vc; i++) { vertices[i].Pos *= scale; } buf->recalculateBoundingBox(); // calculate total bounding box if(j == 0) bbox = buf->getBoundingBox(); else bbox.addInternalBox(buf->getBoundingBox()); } mesh->setBoundingBox(bbox); } void translateMesh(scene::IMesh *mesh, v3f vec) { if(mesh == NULL) return; core::aabbox3d<f32> bbox; bbox.reset(0,0,0); u16 mc = mesh->getMeshBufferCount(); for(u16 j=0; j<mc; j++) { scene::IMeshBuffer *buf = mesh->getMeshBuffer(j); video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); u16 vc = buf->getVertexCount(); for(u16 i=0; i<vc; i++) { vertices[i].Pos += vec; } buf->recalculateBoundingBox(); // calculate total bounding box if(j == 0) bbox = buf->getBoundingBox(); else bbox.addInternalBox(buf->getBoundingBox()); } mesh->setBoundingBox(bbox); } void setMeshColor(scene::IMesh *mesh, const video::SColor &color) { if(mesh == NULL) return; u16 mc = mesh->getMeshBufferCount(); for(u16 j=0; j<mc; j++) { scene::IMeshBuffer *buf = mesh->getMeshBuffer(j); video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); u16 vc = buf->getVertexCount(); for(u16 i=0; i<vc; i++) { vertices[i].Color = color; } } } void setMeshColorByNormalXYZ(scene::IMesh *mesh, const video::SColor &colorX, const video::SColor &colorY, const video::SColor &colorZ) { if(mesh == NULL) return; u16 mc = mesh->getMeshBufferCount(); for(u16 j=0; j<mc; j++) { scene::IMeshBuffer *buf = mesh->getMeshBuffer(j); video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); u16 vc = buf->getVertexCount(); for(u16 i=0; i<vc; i++) { f32 x = fabs(vertices[i].Normal.X); f32 y = fabs(vertices[i].Normal.Y); f32 z = fabs(vertices[i].Normal.Z); if(x >= y && x >= z) vertices[i].Color = colorX; else if(y >= z) vertices[i].Color = colorY; else vertices[i].Color = colorZ; } } }