Page 1 of 1

Texture orientation using on_place = minetest.rotate_node

Posted: Sun Nov 02, 2014 11:46
by dvere
I'm not sure if this is expected behaviour or if I am doing something wrong.

I have made a simple mod to add Scrabble-like nodebox tiles for my son to play with.

Rotation when placed on the ground is correct but when placed on a vertical surface the texture is always rotated 90 degrees clockwise from the placer's perspective.


Image

I expected the texture when placed on vertical surfaces would, by default, be "upright".

The texture for the tile in the screenshot (tile_bottom.png and tile_sides.png are the same square background without the letter) and a simplified version of the node definition below.

I couldn't see an obvious (to me) reason for why this happens in builtin/common/misc_helpers.lua but I most likley don't know what I'm looking for.

Image

Code: Select all

minetest.register_node('tile:tile_A', {
	description = ("tile A" ),
	drawtype = "nodebox",
	node_box = {
		type = "fixed",
		fixed = { -0.48, -0.5, -0.48, 0.48, -0.28, 0.48 }
	},
	tiles = {
		'tile_A.png',
		'tile_bottom.png',
		'tile_sides.png',
		'tile_sides.png',
		'tile_sides.png',
		'tile_sides.png'
	},
	sunlight_propagates = true,
	paramtype = "light",
	paramtype2 = "facedir",
	walkable = true,
	groups = { snappy = 3 },
	sounds = default.node_sound_wood_defaults(),
	on_place = minetest.rotate_node
})

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Sun Nov 02, 2014 20:50
by Don
I am not sure what is wrong but I do hope you add the mod to the forum once it is fixed.

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Thu Nov 06, 2014 23:14
by dvere
The below changes to dirs1 and dirs2 in builtin/common/misc_helpers.lua (lines 323 &324) fixes both this and the texture orientation being off by 180 degrees when placing "on the ceiling".

Code: Select all

    local dirs1 = {8, 17, 6, 15}
    local dirs2 = {22, 21, 20, 23}

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Thu Nov 06, 2014 23:55
by Casimir
That seems to be a bigger problem. With signlike/wallmounted it is even more distorted that with nodebox.
Without your fix:
http://screenshot.ru/upload/images/2014 ... 4d8148.png
With your fix it gets better:
http://screenshot.ru/upload/images/2014 ... 5e7f71.png

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Fri Nov 07, 2014 00:14
by Don
You could do an on_place replace node and create another node with the rotated image. It would work as a temporary solution til you get a better answer. Not a good solution but better then nothing.

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Fri Nov 07, 2014 02:18
by dvere
Casimir wrote:That seems to be a bigger problem. With signlike/wallmounted it is even more distorted that with nodebox.
Without your fix:
http://screenshot.ru/upload/images/2014 ... 4d8148.png
With your fix it gets better:
http://screenshot.ru/upload/images/2014 ... 5e7f71.png
Using minetest.rotate_node is appropriate for nodes that have "paramtype2 = facedir" but not "drawtype = signlike" or "paramtype2 = wallmounted" as those would be placed facing the player as opposed to being placed facing in the direction the player is looking.
Don wrote:You could do an on_place replace node and create another node with the rotated image. It would work as a temporary solution til you get a better answer. Not a good solution but better then nothing.
I'm happy with the above fix as it is working how I think it was intended, means that the node definition is simple and doesn't seem to have broken anything else!

Though it's really nothing much I've put the mod on github. https://github.com/dvere/scrabble

They respond to a poke with a screwdriver even without the fix :-D

Re: Texture orientation using on_place = minetest.rotate_nod

Posted: Tue Mar 24, 2015 15:07
by Don
I wanted to use this mod but I see that the rotate thing isn't fixed yet. I added ^[transformR90 to the letter png. This rotates the letter to work on the wall but means when placing on the ground you has to place from the side. Just think this might be a better solution.