Page 1 of 1

6d Facedir

PostPosted: Sun Feb 17, 2013 10:22
by RealBadAngel
New facedir gives you ability to rotate nodes in every direction.
If you want to check how it works please compile game from sources:
https://github.com/RealBadAngel/minetest
Note: By now rotating regular nodes is done (chests, furnaces etc)
Updated: new screwdriver in tools, more handy.
Added nodebox rotations to git.
(still need to work on nodeboxes bug)

Screwdriver mod to rotate nodes:
http://realbadangel.pl/facedirtools.zip

Facedir now has a different meanin:
Its value now defines direction in which top face of node is pointing and rotation over this direction.
Values = 0 to 23

facedir / 4 gives you direction:
0 -> y+
1 -> z+
2 -> z-
3 -> x+
4 -> x-
5 -> y-

facedir modulo 4 is the rotation

Old facedir is just one case of new one: y+ , so any old code will still work with new facedir.

Comments and suggestion are welcome.

PostPosted: Sun Feb 17, 2013 10:56
by PilzAdam
1st: Is this compatible with the old system? (i.e. you load an old map and everything is rotated correctly)
2nd: Is this applied to paramtype2 = "facedir" or "wallmounted"? The current API uses facedir as horizontal only, and wallmounted also has vertical rotation.

PostPosted: Sun Feb 17, 2013 11:02
by RealBadAngel
PilzAdam wrote:1st: Is this compatible with the old system? (i.e. you load an old map and everything is rotated correctly)
2nd: Is this applied to paramtype2 = "facedir" or "wallmounted"? The current API uses facedir as horizontal only, and wallmounted also has vertical rotation.


1) I already wrote it: old facedir is just one case of new one. So any old code either mod or engine will work as before.
2) its facedir, not wallmounted

PostPosted: Sun Feb 17, 2013 12:54
by RealBadAngel
Ive updated screwdriver, check it out, its way better now :)
Also updated engine to rotate nodeboxes. Try to rotate all calinou's stairs+ nodes now.

PostPosted: Sun Feb 17, 2013 13:20
by socramazibi
Good Mod , works well .

PostPosted: Sun Feb 17, 2013 13:24
by Jordach
socramazibi wrote:Good Mod , works well .
This isnt a mod, but a source code containing a possible update.

PostPosted: Sun Feb 17, 2013 15:00
by 0gb.us
Oh, wow. If I understand this correctly, it is now possible to turn a chest on its side!

I'll have to try this later. I'm too busy to try it right away, but I'm curious to see how it functions in certain situations.

PostPosted: Tue Feb 19, 2013 02:54
by RealBadAngel
Updated screwdriver, now it has four modes. Read in game messages on how to use it.

PostPosted: Tue Feb 19, 2013 08:42
by socramazibi
Jordach wrote:
socramazibi wrote:Good Mod , works well .
This isnt a mod, but a source code containing a possible update.


RealBadAngel wrote:Screwdriver mod to rotate nodes:
http://realbadangel.pl/facedirtools.zip


Image

It seems a Mod.

PostPosted: Wed Feb 20, 2013 04:21
by VanessaE
It's both an engine patch to create the feature, and an Lua mod to enable a player to make use of it.

PostPosted: Fri Mar 01, 2013 01:18
by khonkhortisan
This has been merged.

Facedir 0-3 remains unchanged, but has been extended to 23.

Axes:
0 Y+
1 Z+
2 Z-
3 X+
4 X-
5 Y-
Rotations (clockwise):
0 0
1 90
2 180
3 270
Axis * 4 + Rotation = Facedir
0 0 0
0 1 1
0 2 2
0 3 3
1 0 4
1 1 5
1 2 6
1 3 7
2 0 8
2 1 9
2 2 10
2 3 11
3 0 12
3 1 13
3 2 14
3 3 15
4 0 16
4 1 17
4 2 18
4 3 19
5 0 20
5 1 21
5 2 22
5 3 23

Faces by axis by rotation:
(nodebox above, node below, xyz is rgb, lighter is positive)
Image
Image
Image
Image
Image
Image

How to rotate (clockwise) by axis from any facedir:
(this will be made into a lua function)
-X+
(3,0) (3,1) (3,2) (3,3)
(4,0) (4,3) (4,2) (4,1)

(0,0) (1,0) (5,2) (2,0)
(0,1) (1,1) (5,3) (2,1)
(0,2) (1,2) (5,0) (2,2)
(0,3) (1,3) (5,1) (2,3)

-Y+
(0,0) (0,1) (0,2) (0,3)
(5,0) (5,3) (5,2) (5,1)

(1,0) (3,1) (2,2) (4,3)
(2,0) (4,1) (1,2) (3,3)
(3,0) (2,1) (4,2) (1,3)
(4,0) (1,1) (3,2) (2,3)

-Z+
(1,0) (1,1) (1,2) (1,3)
(2,0) (2,3) (2,2) (2,1)

(0,0) (4,0) (5,0) (3,0)
(0,1) (4,1) (5,1) (3,1)
(0,2) (4,2) (5,2) (3,2)
(0,3) (4,3) (5,3) (3,3)

PostPosted: Wed Mar 27, 2013 17:09
by Likwid H-Craft
Talking about Facedir is there a way do the middle like how mc has it, Cauldron has a hole.

PostPosted: Sun Mar 31, 2013 22:34
by khonkhortisan
Likwid H-Craft wrote:Talking about Facedir is there a way do the middle like how mc has it, Cauldron has a hole.

That doesn't have to do with facedir (whole-node rotations) but with nodeboxes, where you can have a single node being made out of multiple rectangular prisms.

PostPosted: Sun Aug 04, 2013 17:41
by LionsDen
The command minetest.dir_to_facedir() needs to be updated. It only gives the x and z directions. It can't handle the y direction. I am using the latest PilzAdam, sfan5 and BlockMen builds on Windows XP and was trying to set up a mod that uses this function but couldn't get any y direction. I had to use the pitch and sort of override the facedir for any pitch greater than a certain amount. By the way, I was getting the players facedir if that makes any difference.

PostPosted: Sun Aug 04, 2013 18:02
by hoodedice
LionsDen wrote:... I am using the latest PilzAdam, sfan5 and BlockMen builds on Windows XP....

PostPosted: Sun Aug 04, 2013 23:17
by LionsDen
hoodedice wrote:
LionsDen wrote:... I am using the latest PilzAdam, sfan5 and BlockMen builds on Windows XP....


I have been playing with all three. Just to see if I notice any differences like I did with an earlier BlockMen build.

PostPosted: Mon Aug 05, 2013 00:10
by hdastwb
LionsDen wrote:The command minetest.dir_to_facedir() needs to be updated. It only gives the x and z directions. It can't handle the y direction. I am using the latest PilzAdam, sfan5 and BlockMen builds on Windows XP and was trying to set up a mod that uses this function but couldn't get any y direction. I had to use the pitch and sort of override the facedir for any pitch greater than a certain amount. By the way, I was getting the players facedir if that makes any difference.


I fixed that recently (https://github.com/minetest/minetest/pull/834), but in order to use the 6d version you'll have to pass the optional parameter at the end to enable it (it's disabled by default because it would break an awful lot of placing code). See https://github.com/VanessaE/pipeworks/blob/master/node_breaker.lua#L184 for a usage example.

PostPosted: Mon Aug 05, 2013 15:52
by LionsDen
hdastwb wrote:I fixed that recently (https://github.com/minetest/minetest/pull/834), but in order to use the 6d version you'll have to pass the optional parameter at the end to enable it (it's disabled by default because it would break an awful lot of placing code). See https://github.com/VanessaE/pipeworks/blob/master/node_breaker.lua#L184 for a usage example.


I just tried this with the following code snippet:

Code: Select all
minetest.dir_to_facedir(user:get_look_dir(), true)


and still only got x and z coordinates. As far as I can tell from the pipeworks example you showed, I have the usage right.

EDIT: Just tried it without the minetest. in front and it crashed so that wasn't my problem.

PostPosted: Mon Aug 05, 2013 21:53
by hdastwb
LionsDen wrote:I just tried this with the following code snippet:

Code: Select all
minetest.dir_to_facedir(user:get_look_dir(), true)


and still only got x and z coordinates. As far as I can tell from the pipeworks example you showed, I have the usage right.

EDIT: Just tried it without the minetest. in front and it crashed so that wasn't my problem.


Assuming that your minetest version is from after about two weeks ago, if you call minetest.dir_to_facedir(dir, true) and the absolute value of dir's y component is greater than both the x and z components' absolute values, then your result should be some number > 3.

dir_to_facedir is implemented in Lua, so one easy way to check if your version is new enough would be to open up builtin/item.lua and scan down to around line 37; if you don't see the is6d parameter in the definition of dir_to_facedir, then your build doesn't support it yet. That said, though, since it's Lua you can change the definitions of those functions without having to rebuild. Another option would be to do what I did in pipeworks and define those functions as local functions at the top of every file that uses them, and then eventually switch to the standardized versions when 0.4.8 comes out.

PostPosted: Tue Aug 06, 2013 01:49
by LionsDen
hdastwb wrote:Assuming that your minetest version is from after about two weeks ago, if you call minetest.dir_to_facedir(dir, true) and the absolute value of dir's y component is greater than both the x and z components' absolute values, then your result should be some number > 3.

dir_to_facedir is implemented in Lua, so one easy way to check if your version is new enough would be to open up builtin/item.lua and scan down to around line 37; if you don't see the is6d parameter in the definition of dir_to_facedir, then your build doesn't support it yet. That said, though, since it's Lua you can change the definitions of those functions without having to rebuild. Another option would be to do what I did in pipeworks and define those functions as local functions at the top of every file that uses them, and then eventually switch to the standardized versions when 0.4.8 comes out.



Yeah, didn't know about the 2 week limit for it. I was using the 07/24/2013 version of PilzAdam's build to test it. I just looked and it doesn't have the new facedir. I do also have BlockMen's and sfan5's version which is around 1 day old or so and both have the new facedir. I'll try to run the test again using the newer versions. It'll probably have to wait until tomorrow as I wasn't home today and don't have time to play tonight with it. Thanks for the info and I just might use your idea to code my own version based on what the new item.lua's have in them. It depends on if I will be releasing that mod before or after v0.4.8 comes out.