1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-23 07:10:19 +01:00

Stairs: Set world-aligned textures for all stairs and slabs

Fix 'stair_images' code to avoid 'stair_images' being empty in some
situations.
Change stairs back to nodeboxes to make world-aligned textures work.
This commit is contained in:
paramat 2017-11-02 04:30:19 +00:00 committed by paramat
parent dbfe435abf
commit 9d9e9b6709
6 changed files with 59 additions and 505 deletions

View File

@ -7,12 +7,3 @@ Authors of source code
Originally by Kahrl <kahrl@gmx.net> (LGPL 2.1) and
celeron55, Perttu Ahola <celeron55@gmail.com> (LGPL 2.1)
Various Minetest developers and contributors (LGPL 2.1)
Authors of media (models)
-------------------------
Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com> (CC BY-SA 3.0):
stairs_stair.obj
GreenXenith (CC BY-SA 3.0)
stairs_stair_inner.obj stairs_stair_outer.obj

View File

@ -46,41 +46,40 @@ end
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_" .. subname, {
description = description,
drawtype = "mesh",
mesh = "stairs_stair.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_box = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)
@ -144,11 +143,26 @@ local slab_trans_dir = {[0] = 8, 0, 2, 1, 3, 4}
-- Node will be called stairs:slab_<subname>
function stairs.register_slab(subname, recipeitem, groups, images, description, sounds)
-- Set world-aligned textures
local slab_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
slab_images[i] = {
name = image,
align_style = "world",
}
else
slab_images[i] = table.copy(image)
if image.align_style == nil then
slab_images[i].align_style = "world"
end
end
end
groups.slab = 1
minetest.register_node(":stairs:slab_" .. subname, {
description = description,
drawtype = "nodebox",
tiles = images,
tiles = slab_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
@ -280,43 +294,41 @@ end
-- Node will be called stairs:stair_inner_<subname>
function stairs.register_stair_inner(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_inner_" .. subname, {
description = description .. " Inner",
drawtype = "mesh",
mesh = "stairs_stair_inner.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_box = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
{-0.5, 0, -0.5, 0, 0.5, 0},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
{-0.5, 0, -0.5, 0, 0.5, 0},
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.5, 0.5, 0.5},
{-0.5, 0.0, -0.5, 0.0, 0.5, 0.0},
},
},
on_place = function(itemstack, placer, pointed_thing)
@ -358,41 +370,40 @@ end
-- Node will be called stairs:stair_outer_<subname>
function stairs.register_stair_outer(subname, recipeitem, groups, images, description, sounds)
-- Set backface culling and world-aligned textures
local stair_images = {}
for i, image in ipairs(images) do
if type(image) == "string" then
stair_images[i] = {
name = image,
backface_culling = true,
align_style = "world",
}
elseif image.backface_culling == nil then -- override using any other value
else
stair_images[i] = table.copy(image)
stair_images[i].backface_culling = true
if stair_images[i].backface_culling == nil then
stair_images[i].backface_culling = true
end
if stair_images[i].align_style == nil then
stair_images[i].align_style = "world"
end
end
end
groups.stair = 1
minetest.register_node(":stairs:stair_outer_" .. subname, {
description = description .. " Outer",
drawtype = "mesh",
mesh = "stairs_stair_outer.obj",
drawtype = "nodebox",
tiles = stair_images,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = groups,
sounds = sounds,
selection_box = {
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0, 0.5, 0.5},
{-0.5, -0.5, -0.5, 0.5, 0.0, 0.5},
{-0.5, 0.0, 0.0, 0.0, 0.5, 0.5},
},
},
on_place = function(itemstack, placer, pointed_thing)

View File

@ -2,9 +2,9 @@ License of source code
----------------------
GNU Lesser General Public License, version 2.1
Copyright (C) 2011-2016 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2016 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2012-2016 Various Minetest developers and contributors
Copyright (C) 2011-2017 Kahrl <kahrl@gmx.net>
Copyright (C) 2011-2017 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2012-2017 Various Minetest developers and contributors
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU Lesser General Public License as published by the Free Software Foundation;
@ -14,39 +14,3 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details:
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
Licenses of media (models)
--------------------------
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2015-2016 Jean-Patrick G. (kilbith) <jeanpatrick.guerrero@gmail.com>
Copyright (C) 2017 GreenXenith
You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and
indicate if changes were made. You may do so in any reasonable manner, but not in any way
that suggests the licensor endorses you or your use.
ShareAlike — If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public
domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.
For more details:
http://creativecommons.org/licenses/by-sa/3.0/

View File

@ -1,115 +0,0 @@
# Blender v2.72 (sub 0) OBJ File: ''
# www.blender.org
mtllib stairs.mtl
o stairs_top
v -0.500000 0.000000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 1.000000 0.000000
g stairs_top
usemtl None
s off
f 4/1/1 1/2/1 2/3/1 3/4/1
f 7/5/1 8/6/1 6/4/1 5/3/1
o stairs_bottom
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -1.000000 -0.000000
g stairs_bottom
usemtl None
s off
f 11/7/2 9/8/2 10/9/2 12/10/2
o stairs_right
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v -0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 0.500000 0.500000
vt 1.000000 1.000000
vt 0.500000 1.000000
vt 1.000000 0.000000
vn -1.000000 0.000000 0.000000
g stairs_right
usemtl None
s off
f 13/11/3 14/12/3 15/13/3
f 15/13/3 18/14/3 17/15/3
f 14/12/3 16/16/3 15/13/3
f 16/16/3 18/14/3 15/13/3
o stairs_left
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 0.500000
vt 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.500000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 1.000000 0.000000 0.000000
g stairs_left
usemtl None
s off
f 19/17/4 20/18/4 21/19/4
f 19/17/4 23/20/4 24/21/4
f 20/18/4 19/17/4 22/22/4
f 19/17/4 24/21/4 22/22/4
o stairs_back
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vn 0.000000 -0.000000 1.000000
g stairs_back
usemtl None
s off
f 26/23/5 28/24/5 27/25/5 25/26/5
o stairs_front
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v -0.500000 0.500000 0.000000
v 0.500000 0.500000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.500000
vt 0.000000 0.500000
vt 0.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
g stairs_front
usemtl None
s off
f 30/27/6 29/28/6 34/29/6 33/30/6
f 31/28/6 35/31/6 36/32/6 32/29/6

View File

@ -1,161 +0,0 @@
# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
mtllib stairs_inner_stair.mtl
o stairs_back_right_stairs_back.001
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 0.500000
v -0.500000 -0.500000 0.500000
vt 1.0000 0.0000
vt 1.0000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vn 0.0000 -0.0000 1.0000
usemtl None.001
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
o stairs_front_right_stairs_back.003
v 0.000000 0.000000 -0.500000
v 0.000000 0.000000 0.000000
v 0.000000 0.500000 0.000000
v 0.000000 0.500000 -0.500000
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 0.000000
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 0.000000
v -0.500000 -0.500000 0.500000
vt 0.0000 0.5000
vt 0.5000 0.5000
vt 0.5000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.5000
vt 0.0000 0.0000
vt 0.5000 0.5000
vt 1.0000 1.0000
vt 0.5000 1.0000
vt 1.0000 0.0000
vn -1.0000 0.0000 0.0000
usemtl None
s 1
f 5/5/2 6/6/2 7/7/2 8/8/2
f 9/9/2 10/10/2 11/11/2
f 11/11/2 12/12/2 13/13/2
f 10/10/2 14/14/2 11/11/2
f 14/14/2 12/12/2 11/11/2
o stairs_bottom
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 0.500000
vt 1.0000 0.0000
vt 1.0000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vn 0.0000 -1.0000 -0.0000
usemtl None
s 1
f 15/15/3 16/16/3 17/17/3 18/18/3
o stairs_front_left_stairs_front.002
v -0.500000 0.000000 0.000000
v -0.500000 0.500000 0.000000
v 0.000000 0.500000 0.000000
v 0.000000 0.000000 0.000000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.000000 0.000000 -0.500000
v 0.000000 0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v 0.500000 0.000000 -0.500000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.0000 0.5000
vt 0.0000 0.0000
vt 0.5000 0.5000
vt 0.5000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.5000
vn 0.0000 0.0000 -1.0000
usemtl None
s 1
f 19/19/4 20/20/4 21/21/4 22/22/4
f 23/23/4 24/24/4 25/25/4 26/26/4
f 27/27/4 28/28/4 29/29/4 30/30/4
o stairs_top_stairs_top.001
v 0.000000 0.000000 -0.500000
v -0.500000 0.000000 -0.500000
v -0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.500000 0.500000 -0.500000
v 0.000000 0.500000 -0.500000
v 0.000000 0.500000 0.000000
v 0.500000 0.500000 0.000000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
v 0.500000 0.500000 0.000000
v -0.500000 0.500000 0.000000
vt 0.5000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.5000
vt 0.5000 0.5000
vt 1.0000 1.0000
vt 0.5000 1.0000
vt 0.5000 0.5000
vt 1.0000 0.5000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.0000 0.5000
vn 0.0000 1.0000 0.0000
usemtl None
s 1
f 31/31/5 32/32/5 33/33/5 34/34/5
f 35/35/5 36/36/5 37/37/5 38/38/5
f 39/39/5 40/40/5 41/41/5 42/42/5
o stairs_back_left_stairs_back.005
v 0.500000 0.000000 -0.500000
v 0.500000 0.500000 -0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 0.500000
v 0.500000 -0.000000 0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.000000
v 0.500000 -0.500000 -0.000000
v 0.500000 0.000000 0.000000
v 0.500000 -0.000000 0.500000
v 0.500000 -0.500000 0.500000
vt 0.5000 0.5000
vt 0.5000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.5000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.5000 0.5000
vt 0.5000 0.0000
vt 0.5000 0.0000
vt 0.5000 0.5000
vt 0.0000 0.5000
vt 0.0000 0.0000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 1.0000
vt 0.5000 0.5000
vn 1.0000 0.0000 0.0000
usemtl None
s 1
f 47/43/6 48/44/6 49/45/6 50/46/6
f 51/47/6 52/48/6 53/49/6 54/50/6
f 55/51/6 56/52/6 57/53/6 58/54/6
usemtl None.002
f 43/55/6 44/56/6 45/57/6 46/58/6

View File

@ -1,136 +0,0 @@
# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
mtllib stairs_outer_stair.mtl
o stairs_bottom
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 0.500000
vt 1.0000 0.0000
vt 1.0000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vn 0.0000 -1.0000 -0.0000
usemtl None
s 1
f 1/1/1 2/2/1 3/3/1 4/4/1
o stairs_back_left_stairs_left
v 0.500000 0.000000 0.000000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.500000 0.500000
v 0.500000 -0.500000 0.500000
vt 0.5000 0.5000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.5000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.0000
vn 1.0000 0.0000 0.0000
usemtl None
s 1
f 5/5/2 6/6/2 7/7/2
f 5/5/2 8/8/2 9/9/2
f 6/6/2 5/5/2 10/10/2
f 5/5/2 9/9/2 10/10/2
o stairs_back_right_stairs_back
v 0.000000 -0.500000 0.500000
v 0.000000 -0.000000 0.500000
v -0.500000 -0.000000 0.500000
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 -0.000000 0.500000
v 0.500000 0.500000 0.500000
v 0.000000 0.500000 0.500000
vt 0.5000 0.0000
vt 0.5000 0.5000
vt 0.0000 0.5000
vt 0.0000 0.0000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 1.0000 1.0000
vt 0.5000 1.0000
vn 0.0000 -0.0000 1.0000
usemtl None
s 1
f 11/11/3 12/12/3 13/13/3 14/14/3
f 15/15/3 16/16/3 12/12/3 11/11/3
f 16/16/3 17/17/3 18/18/3 12/12/3
o stairs_top_stairs_top.001
v 0.000000 0.500000 0.500000
v 0.501689 0.500000 0.500000
v 0.501689 0.500000 0.000000
v 0.000000 0.500000 0.000000
v -0.500000 -0.000000 0.500000
v 0.001689 -0.000000 0.500000
v 0.001689 0.000000 0.000000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 -0.500000
v -0.500000 0.000000 -0.500000
v -0.500000 0.000000 0.000000
v 0.500000 0.000000 0.000000
vt 0.5000 0.0000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt 0.5000 0.5000
vt 0.0000 0.0000
vt 0.5000 0.0000
vt 0.5000 0.5000
vt 0.0000 0.5000
vt 1.0000 1.0000
vt 0.0000 1.0000
vt 0.0000 0.5000
vt 1.0000 0.5000
vn 0.0000 1.0000 0.0000
usemtl None
s 1
f 19/19/4 20/20/4 21/21/4 22/22/4
usemtl None.004
f 23/23/4 24/24/4 25/25/4 26/26/4
f 27/27/4 28/28/4 29/29/4 30/30/4
o stairs_front_left_stairs_front.000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 0.000000
v 0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.000000 0.500000 0.000000
vt 1.0000 0.0000
vt 1.0000 0.5000
vt -0.0000 0.5000
vt -0.0000 0.0000
vt 0.5000 0.5000
vt 0.5000 1.0000
vt -0.0000 1.0000
vt -0.0000 0.5000
vn 0.0000 0.0000 -1.0000
usemtl None.001
s 1
f 31/31/5 32/32/5 33/33/5 34/34/5
usemtl None.003
f 37/35/5 38/36/5 35/37/5 36/38/5
o stairs_front_right_stairs_right.001_stairs_front_left_stairs_front.002
v -0.500000 -0.500000 0.500000
v -0.500000 0.000000 0.500000
v -0.500000 0.000000 -0.500000
v -0.500000 -0.500000 -0.500000
v 0.000000 0.000000 0.500000
v 0.000000 0.500000 0.500000
v 0.000000 0.500000 -0.000000
v -0.000000 0.000000 0.000000
vt 1.0000 0.0000
vt 1.0000 0.5021
vt -0.0000 0.5021
vt -0.0000 0.0000
vt 1.0000 0.5021
vt 1.0000 1.0000
vt 0.5000 1.0000
vt 0.5000 0.5021
vn -1.0000 0.0000 0.0000
usemtl None.002
s 1
f 39/39/6 40/40/6 41/41/6 42/42/6
f 43/43/6 44/44/6 45/45/6 46/46/6