[Solved] How do i rotate nodeboxes in degrees

Post Reply
User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

[Solved] How do i rotate nodeboxes in degrees

by Jeksta » Post

I know that you can rotate nodeboxes using.

Code: Select all

paramtype2 = "facedir"
But then you can only rotate the node in 90° steps.
So is it possible to do this with numbers between 90° or do i have to create "transition nodeboxes"?
Last edited by Jeksta on Fri Sep 06, 2019 15:52, edited 1 time in total.

User avatar
Andrey01
Member
Posts: 2574
Joined: Wed Oct 19, 2016 15:18
GitHub: Andrey2470T
In-game: Andrey01
Location: Russia, Moscow

Re: How do i rotate nodeboxes in degrees

by Andrey01 » Post

It's impossible to rotate nodeboxes at an oblique angle. Only at the right one.

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

Hm, would be a nice feature to have, like animating a nodebox.

Thanks anyways.

neoh4x0r
Member
Posts: 82
Joined: Wed Aug 29, 2018 20:16
GitHub: neoh4x0r

Re: How do i rotate nodeboxes in degrees

by neoh4x0r » Post

Jeksta wrote:I know that you can rotate nodeboxes using.

Code: Select all

paramtype2 = "facedir"
But then you can only rotate the node in 90° steps.
So is it possible to do this with numbers between 90° or do i have to create "transition nodeboxes"?
I wonder if you rotated the node fast enough -- you might be able to take advantage of persistence of vision and maybe give the illusion of it rotating through smaller angles.

User avatar
duane
Member
Posts: 1715
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: How do i rotate nodeboxes in degrees

by duane » Post

Jeksta wrote:Hm, would be a nice feature to have, like animating a nodebox.

Thanks anyways.
If you turn the node into an entity, you can put it at any angle you want, then turn it back. Of course you'd have to have a situation where the node will be facing a cardinal point at the end of its motion, and there won't be very many in motion at once.
Believe in people and you don't need to believe anything else.

User avatar
AiTechEye
Member
Posts: 1000
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: Sweden

Re: How do i rotate nodeboxes in degrees

by AiTechEye » Post

Code: Select all

minetest.register_node("mod:test", {
	tiles={"default_wood.png","default_wood.png","default_wood.png^default_stick.png",},
	paramtype2 = "facedir",
	groups = {dig_immediate = 3},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		print(node.param2+1)
		minetest.set_node(pos,{name="mod:test",param2=node.param2+1})
	end,
})

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

AiTechEye wrote:

Code: Select all

minetest.register_node("mod:test", {
	tiles={"default_wood.png","default_wood.png","default_wood.png^default_stick.png",},
	paramtype2 = "facedir",
	groups = {dig_immediate = 3},
	on_rightclick = function(pos, node, player, itemstack, pointed_thing)
		print(node.param2+1)
		minetest.set_node(pos,{name="mod:test",param2=node.param2+1})
	end,
})
Thats the solution i currently have too.

Code: Select all

node.param2 = (node.param2 + 1) % 4
minetest.set_node(pos, node)
Basically i'm trying to simulate a crank, but 90° turns look really harsh.
The entity solution would probably work, but my knowledge of entities is kind of non existent.

Atm i'm going for a toggle method between a straight crank and a crooked one, because this seems like a problem i could solve.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: How do i rotate nodeboxes in degrees

by ShadMOrdre » Post

What if you used gears_3d mod?

What if, as an alternative to gears_3d, you used an item_stand like setup, where the node below spawns an entity above, that can be set to rotate yaw. This only works for gears/sprockets that horizontal, as vertically aligned gears aren't possible without pitch rotation for entities.

Shad

User avatar
AiTechEye
Member
Posts: 1000
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: Sweden

Re: How do i rotate nodeboxes in degrees

by AiTechEye » Post

Code: Select all

minetest.register_entity("default:entity",{
	visual = "cube",
	textures={"default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png","default_dirt.png",},
	on_activate=function(self, staticdata)
		--while entity is spawned/loaded
	end,
	on_step=function(self,dtime)
		local r = self.object:get_rotation()
		r.y = r.y + 0.1
		self.object:set_rotation(r)
	end,
})

minetest.add_entity(pos, "default:entity")
https://dev.minetest.net/minetest.register_entity

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: How do i rotate nodeboxes in degrees

by ShadMOrdre » Post

That's the spirit AITechEye!

User avatar
Jeksta
Member
Posts: 11
Joined: Fri Aug 23, 2019 18:47
GitHub: Jeksta
Location: Germany

Re: How do i rotate nodeboxes in degrees

by Jeksta » Post

Ok, for people who might have the same problem. This is the solution i came up with (including solutions from this post):

The node spawns an attached entity above itself, (on_consturct)
then the entity saves its handle and the node position in the table local attached_entity = {} (on_activation)
If the node is destroyed, it deletes the entity handle and entry in the attached_entity table. (on_destruct)

Code: Select all

local attached_entity = {}

minetest.register_entity(
   "mod:attached_entity",
   {
    on_activate = function(self, staticdata, dtime_s)
       local entity_pos = self.object:get_pos()
       local node_pos = {
          x = math.floor(entity_pos.x),
          y = math.floor(entity_pos.y) - 1,
          z = math.floor(entity_pos.z)
       }
       local ser_pos = minetest.serialize(node_pos)

       attached_entity[ser_pos] = self.object
    end,
})

minetest.register_node(
   "mod:node",
   {
   on_construct = function(pos)
      local ser_pos = minetest.serialize(pos)
      minetest.add_entity({x = pos.x, y = pos.y + 1, z = pos.z}, "mod:attached_entity")
   end,

   on_destruct = function(pos)
   local ser_pos = minetest.serialize(pos)
      if attached_entity[ser_pos] then
         attached_entity[ser_pos]:remove()
         attached_entity[ser_pos] = nil
      end
   end
})
Not sure whether it's an elegant solution, but that's what i'm going with for now.

ZAAo
Member
Posts: 47
Joined: Tue Jul 27, 2021 16:15

Re: [Solved] How do i rotate nodeboxes in degrees

by ZAAo » Post

Hi. Does anyone know if it is perhaps possible to get connecting "nodebox" nodes to go up and down slopes? Similar to how regular "raillike" nodes do?

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: [Solved] How do i rotate nodeboxes in degrees

by Blockhead » Post

I would seriously consider moving to meshes and using degrotate if you need smaller than 90° increments, as long as you only need rotation in the X-Z plane. I put together a small example mod today to demonstrate this: Rotatable Monkey.
ZAAo wrote:
Mon May 16, 2022 17:53
Hi. Does anyone know if it is perhaps possible to get connecting "nodebox" nodes to go up and down slopes? Similar to how regular "raillike" nodes do?
You should post a separate thread for that, it's not really related to the original post.

Edit: For those playing along at home, ZAAo's follow up question is at this thread.
Last edited by Blockhead on Thu Jun 16, 2022 08:41, edited 1 time in total.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

ZAAo
Member
Posts: 47
Joined: Tue Jul 27, 2021 16:15

Re: [Solved] How do i rotate nodeboxes in degrees

by ZAAo » Post

Blockhead wrote:
Tue May 17, 2022 05:58
I would seriously consider moving to meshes and using degrotate if you need smaller than 90° increments, as long as you only need rotation in the X-Z plane. I put together a small example mod today to demonstrate this: Rotatable Monkey.
ZAAo wrote:
Mon May 16, 2022 17:53
Hi. Does anyone know if it is perhaps possible to get connecting "nodebox" nodes to go up and down slopes? Similar to how regular "raillike" nodes do?
You should post a separate thread for that, it's not really related to the original post.
Thanks! What I am experimenting with is creating a sort of mini-railroad - like a backyard / playground "toy" and using nodeboxes, because that allows using a simple single node for building the entire "track" and making it look more real / 3D. How would using mesh models impact the game performance and resource usage (RAM and CPU) if used instead of simple nodeboxes?

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Solved] How do i rotate nodeboxes in degrees

by sorcerykid » Post

Also worth noting that b3d models support animations. So if you setup a tween for the crank in Blender, then it can rotate automagically without the need for continual on_step calls to rotate the entity itself

ZAAo
Member
Posts: 47
Joined: Tue Jul 27, 2021 16:15

Re: [Solved] How do i rotate nodeboxes in degrees

by ZAAo » Post

sorcerykid wrote:
Thu Jun 16, 2022 07:11
Also worth noting that b3d models support animations. So if you setup a tween for the crank in Blender, then it can rotate automagically without the need for continual on_step calls to rotate the entity itself
Thanks for the feedback. I will look at that...

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests