OK, pictures on the floor and ceiling aren't really useful, but it helps to illustrate my problem. ;-) After upgrading to Minetest 5 my mod looks like this:
I use the following code to register the nodes for the pictures:
- Code: Select all
for n=1, N do
local groups = {choppy=2, dig_immediate=3, picture=1, not_in_creative_inventory=1}
if n == 1 then
groups = {choppy=2, dig_immediate=3, picture=1}
end
-- Texture for the frame
local frame_texture = "metal_1.png"
-- Pixel size of the resulting texture for the node. Higher resolutions for more details.
local resulttexture_pix = 800
-- Frame border width in percent
local frame_widthpercent = 2.5
-- Scaling of the picture
local pic_scale = 2.5
-- Get the width and height of the picture from the file in pixel
local pic_pixwidth,pic_pixheight=get_pngwidthheight(n)
-- Get the max side lenght of the picture in pixel
local pic_pixmax = math.max(pic_pixwidth,pic_pixheight)
-- Frame border width in pixel
local frame_widthpixel = math.ceil(frame_widthpercent * pic_pixmax / 100.0)
-- Distance beetween the frame and the picture in pixel
local border_pix = 4
-- Pixel size of the combined square texture of the picture with frame and border
local pictexture_pix = pic_pixmax + (frame_widthpixel * 2) + (border_pix * 2)
-- X and Y position oft the picture in the combined square texture of the picture with frame and border
local pic_xoffset = ((pic_pixmax - pic_pixwidth) / 2) + frame_widthpixel + border_pix
local pic_yoffset = ((pic_pixmax - pic_pixheight) / 2) + frame_widthpixel + border_pix
-- Frame border width of the node
local frame_widthnode = 1.0 / pictexture_pix * frame_widthpixel
-- Frame border thickness of the node
local frame_thickness = 0.1
-- Picture width of the node (whole picture including frame)
local pic_width = 1.0
-- Picture height of the node (whole picture including frame)
local pic_height = 1.0
-- Picture thickness of the node
local pic_thickness = 0.05
if pic_pixwidth > pic_pixheight then
-- Landscape picture. Set the Picture height of the node (whole picture including frame) accordingly to the original picture aspect ratio
pic_height = (pic_width / pictexture_pix) * (pic_pixheight + 2 * (frame_widthpixel + border_pix))
else
-- Potrait picture Set the Picture width of the node (whole picture including frame) accordingly to the original picture aspect ratio
pic_width = (pic_height / pictexture_pix) * (pic_pixwidth + 2 * (frame_widthpixel + border_pix))
end
-- node
minetest.register_node("gallery:node_"..n.."", {
description = "Picture #"..n.."",
drawtype = "nodebox",
-- Tile definition in the follwing order: +Y, -Y, +X, -X, +Z, -Z.
tiles = {
{name="("..frame_texture.."^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")^([combine:"..pictexture_pix.."x"..pictexture_pix..":"..pic_xoffset..","..pic_yoffset.."=picture_"..n..".png^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")"},
{name=frame_texture}
},
visual_scale = pic_scale,
inventory_image = "gallery_inventory.png",
wield_image = "gallery_inventory.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
node_box = {
type = "fixed",
-- Box definition in following order: {x1, y1, z1, x2, y2, z2}
fixed = {
-- Picture
{-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - pic_thickness) / pic_scale, pic_height/2.0},
-- Left frame border
{-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, -pic_width/2.0+frame_widthnode, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
-- Right frame border
{pic_width/2.0-frame_widthnode, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
-- Bottom frame border
{-pic_width/2.0, -0.5/pic_scale, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, -pic_height/2.0+frame_widthnode},
-- Top frame border
{-pic_width/2.0, -0.5/pic_scale, pic_height/2.0-frame_widthnode, pic_width/2.0, -(0.5 - frame_thickness) / pic_scale, pic_height/2.0},
},
},
Now I see two problems after upgrading to Minetest 5:
1) The nodes are rotated to the walls like with Minetest 0.4.17. But the texture isn't rotated in Minetest 5 anymore. Bug or feature?
2) The node definition and the texture isn't scaled by the parameter visual_scale anymore. OK I read in the documentation that visual_scale is for the wielded image. So this may be a bug in Minetest 0.4.17 and is corrected now?
I found a solution to scale the node, with the following code:
- Code: Select all
for n=1, N do
local groups = {choppy=2, dig_immediate=3, picture=1, not_in_creative_inventory=1}
if n == 1 then
groups = {choppy=2, dig_immediate=3, picture=1}
end
-- Texture for the frame
local frame_texture = "metal_1.png"
-- Pixel size of the resulting texture for the node. Higher resolutions for more details.
local resulttexture_pix = 800
-- Frame border width in percent
local frame_widthpercent = 2.5
-- Scaling of the picture
local pic_scale = 2.5
-- Get the width and height of the picture from the file in pixel
local pic_pixwidth,pic_pixheight=get_pngwidthheight(n)
-- Get the max side lenght of the picture in pixel
local pic_pixmax = math.max(pic_pixwidth,pic_pixheight)
-- Frame border width in pixel
local frame_widthpixel = math.ceil(frame_widthpercent * pic_pixmax / 100.0)
-- Distance beetween the frame and the picture in pixel
local border_pix = 4
-- Pixel size of the combined square texture of the picture with frame and border
local pictexture_pix = pic_pixmax + (frame_widthpixel * 2) + (border_pix * 2)
-- X and Y position oft the picture in the combined square texture of the picture with frame and border
local pic_xoffset = ((pic_pixmax - pic_pixwidth) / 2) + frame_widthpixel + border_pix
local pic_yoffset = ((pic_pixmax - pic_pixheight) / 2) + frame_widthpixel + border_pix
-- Frame border width of the node
local frame_widthnode = 1.0 / pictexture_pix * frame_widthpixel
-- Frame border thickness of the node
local frame_thickness = 0.1
-- Picture width of the node (whole picture including frame)
local pic_width = 1.0
-- Picture height of the node (whole picture including frame)
local pic_height = 1.0
-- Picture thickness of the node
local pic_thickness = 0.05
pic_width = pic_width * pic_scale
pic_height = pic_height * pic_scale
if pic_pixwidth > pic_pixheight then
-- Landscape picture. Set the Picture height of the node (whole picture including frame) accordingly to the original picture aspect ratio
pic_height = (pic_width / pictexture_pix) * (pic_pixheight + 2 * (frame_widthpixel + border_pix))
else
-- Potrait picture Set the Picture width of the node (whole picture including frame) accordingly to the original picture aspect ratio
pic_width = (pic_height / pictexture_pix) * (pic_pixwidth + 2 * (frame_widthpixel + border_pix))
end
-- node
minetest.register_node("gallery:node_"..n.."", {
description = "Picture #"..n.."",
drawtype = "nodebox",
-- Tile definition in the follwing order: +Y, -Y, +X, -X, +Z, -Z.
tiles = {
{name="("..frame_texture.."^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")^([combine:"..pictexture_pix.."x"..pictexture_pix..":"..pic_xoffset..","..pic_yoffset.."=picture_"..n..".png^[resize:"..resulttexture_pix.."x"..resulttexture_pix..")"},
{name=frame_texture}
},
visual_scale = pic_scale,
inventory_image = "gallery_inventory.png",
wield_image = "gallery_inventory.png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
node_box = {
type = "fixed",
-- Box definition in following order: {x1, y1, z1, x2, y2, z2}
fixed = {
-- Picture
{-pic_width/2.0, -0.5, -pic_height/2.0, pic_width/2.0, -(0.5 - pic_thickness) , pic_height/2.0},
-- Left frame border
{-pic_width/2.0, -0.5, -pic_height/2.0, -pic_width/2.0+frame_widthnode, -(0.5 - frame_thickness) , pic_height/2.0},
-- Right frame border
{pic_width/2.0-frame_widthnode, -0.5, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) , pic_height/2.0},
-- Bottom frame border
{-pic_width/2.0, -0.5, -pic_height/2.0, pic_width/2.0, -(0.5 - frame_thickness) , -pic_height/2.0+frame_widthnode},
-- Top frame border
{-pic_width/2.0, -0.5, pic_height/2.0-frame_widthnode, pic_width/2.0, -(0.5 - frame_thickness) , pic_height/2.0},
},
},
selection_box = {
type = "wallmounted",
},
groups = groups,
Than it looks like this in Minetest 5:
But I have no idea how to scale the texture over more than one node?
And why isn't the texture rotated with the node?
Maybe someone have an idea and can help.