Schematics - Importing at angles doesn't also rotate 'facedir'

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Schematics - Importing at angles doesn't also rotate 'facedir'

by MirceaKitsune » Wed Jul 03, 2013 09:55

This report is for hmmm. He recently added support for importing schematics at various angles and I updated my Structures mod to use it. When importing at 90* / 180* / 270*, the nodes are positioned properly, but the facedir of nodes (such as doors and torches) isn't reversed accordingly.

This is an issue I ran into as well when I added angles to structures, and I have the facedir flipping formula. It should be possible to adapt it to C++ and use it for minetest.place_schematic. Here is the fragment of my Lua script that handles rotations:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
            if (angle == 90) or (angle == -270) then

                -- if param2 is facedir, rotate it accordingly
                -- 0 = y+ ; 1 = z+ ; 2 = z- ; 3 = x+ ; 4 = x- ; 5 = y-
                if (node_paramtype2 == "facedir") then
                    if (node_param2 == "0") then node_param2 = "3"
                    elseif (node_param2 == "1") then node_param2 = "0"
                    elseif (node_param2 == "2") then node_param2 = "1"
                    elseif (node_param2 == "3") then node_param2 = "2" end
                end
                -- if param2 is wallmounted, rotate it accordingly
                if (node_paramtype2 == "wallmounted") then
                    if (node_param2 == "2") then node_param2 = "4"
                    elseif (node_param2 == "3") then node_param2 = "5"
                    elseif (node_param2 == "4") then node_param2 = "3"
                    elseif (node_param2 == "5") then node_param2 = "2" end
                end
            elseif (angle == 180) then

                -- if param2 is facedir, rotate it accordingly
                -- 0 = y+ ; 1 = z+ ; 2 = z- ; 3 = x+ ; 4 = x- ; 5 = y-
                if (node_paramtype2 == "facedir") then
                    if (node_param2 == "0") then node_param2 = "2"
                    elseif (node_param2 == "1") then node_param2 = "3"
                    elseif (node_param2 == "2") then node_param2 = "0"
                    elseif (node_param2 == "3") then node_param2 = "1" end
                end
                -- if param2 is wallmounted, rotate it accordingly
                if (node_paramtype2 == "wallmounted") then
                    if (node_param2 == "2") then node_param2 = "3"
                    elseif (node_param2 == "3") then node_param2 = "2"
                    elseif (node_param2 == "4") then node_param2 = "5"
                    elseif (node_param2 == "5") then node_param2 = "4" end
                end
            elseif (angle == 270) or (angle == -90) then

                -- if param2 is facedir, rotate it accordingly
                -- 0 = y+ ; 1 = z+ ; 2 = z- ; 3 = x+ ; 4 = x- ; 5 = y-
                if (node_paramtype2 == "facedir") then
                    if (node_param2 == "0") then node_param2 = "1"
                    elseif (node_param2 == "1") then node_param2 = "2"
                    elseif (node_param2 == "2") then node_param2 = "3"
                    elseif (node_param2 == "3") then node_param2 = "0" end
                end
                -- if param2 is wallmounted, rotate it accordingly
                if (node_paramtype2 == "wallmounted") then
                    if (node_param2 == "2") then node_param2 = "5"
                    elseif (node_param2 == "3") then node_param2 = "4"
                    elseif (node_param2 == "4") then node_param2 = "2"
                    elseif (node_param2 == "5") then node_param2 = "3" end
                end
            else -- 0 degrees

            end


Screenshots of the bug below. See the doors, torches and stairs. First image is at 90*, second at 180*:

Image

Image
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Wed Jul 03, 2013 10:32

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
<celeron55> there are also fun things like facedirs that go with it that hmmmm will hate to even think about 8)
 

User avatar
mauvebic
Member
 
Posts: 1550
Joined: Fri Jan 27, 2012 11:32

by mauvebic » Wed Jul 03, 2013 15:37

Shouldn't be too tough, these problems were solved a long time ago.

though, i used a simple 3-liner for rotation (never adapted to wallmounted or 6d)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
facedirs = {90=1,180=2,270=3}
param2 = blueprint.param2 + facedirs[rotation]
if param2 > 3 then param2 = param2 -4
"Fuck the hat." - Paulie Gualtieri
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Jul 03, 2013 18:56

Spoke to hmmm about this. Unfortunately, he considers me pointing this out as "giving a man a finger and having him take your whole hand", and that it's not a bug at all but a feature request (although the created objects have a broken appearance). Although I understand if he doesn't want to fix it or planned a fix in another way, I'm unable to understand his vision on that.

Either way, he said this shouldn't be fixed in C++ because schematics containing a facedir are an extremely rare circumstance (another thing I don't agree with). There will however be a Lua wrapper in builtin to call the create_schematic function through, which will also solve this issue with the help of the voxel manipulator after creation.

Personally, I find that as parching a hole in a piece of fabric rather than not having a hole at all. Which is why I consider it would be correct to fix it in C++ so the function will do its thing properly. But if it will be fixed in Lua instead I'm not complaining... I just think it's less correct.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Sat Jul 06, 2013 01:12

Oh :-( I was glad that rotation was added and intended to use it for my random_buildings in the near future. If setting of param2 is not done accordingly, that's not so good...

I'd also like to supply a replacement list for the nodes in the schematic. I have no idea how we otherwise would get "ignore" (not to be placed) nodes into the schematic. Apart from creating it as a complete lua table, that is. Houses look more intresting if you replace one material through another occasionally. Ideally, all houses in a specific region/town would have the same materials. Mauvebics mtcities introduced this technique. It could also be intresting for Structure I/O. random_buildings uses it to place a wooden hut for the wood trader with planks and trunks of the same wood type as the trader sells.

The .mts file format seems to be a good, compact format for exchanging structures (without metadata). If we could access the data stored therein through a convenient lua interface and pass that data on to place_schematic, it could help a lot. A function that reads the schematic, e.g.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local data = minetest.read_scheme( "house.mts")

...and which then would supply a table in the format
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
{ size_x = 123, size_y = 10, size_z = 456,
  node_name_list = { "default:dirt","default:stone","default:cobble","ignore","air",...},
  nodes = {3,3,3,3,1,3,3,2,1,3,3,4,4,4,5,4,4,4,...},
  probability= {1,1,1,1,1,...},
  param2={0,0,0,...}}

would be helpful if we could modify this table and supply it to place_schematic. In theory, that could already be done by reading the .mts file, working on it, writing a new .mts file, and placing that schematic. Which is a lot of surplus disk-i/o.

I hope hmmm can understand what we'd like to have. He does a good job, and as nobody is paying for it, there's no other way than to ask nicely if a feature can be added. It's not as if nobody's intrested...he rather has the problem of too many people eagerly awaiting this new feature. If the interface is not improved, it will however be only of limited use, and all application will be very hacky.
A list of my mods can be found here.
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 20 guests

cron