[Help] Modding drawtype nodebox

User avatar
Mitroman
Member
 
Posts: 62
Joined: Thu Apr 03, 2014 19:47
GitHub: Mitroman
In-game: Mitroman15

[Help] Modding drawtype nodebox

by Mitroman » Mon Apr 07, 2014 14:52

Hi. Can somebody explain me the drawtype nodebox? Thanks. =)
Last edited by Mitroman on Mon Apr 07, 2014 14:54, edited 1 time in total.
My mods: Magican, Killer, Clock, Match, Cake.
My Txp: BLoXTxp.
My slogan: EVERYTHING IS AWESOME ;)

If I make any mistakes in english, please tell me so I can correct my mistakes.
 

User avatar
hoodedice
Member
 
Posts: 1372
Joined: Sat Jul 06, 2013 06:33

by hoodedice » Mon Apr 07, 2014 14:56

I am not so experienced in this line of work, but people swear by this program: https://forum.minetest.net/viewtopic.php?id=2840
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Apr 07, 2014 14:56

Node boxes allows you make blocks that are not complete cubes.

For example, stairs are made out of node boxes.

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L353

Or see my editor for this: Node Box Editor

EDIT: hoodedice was inb4 :)
Last edited by rubenwardy on Thu Jun 12, 2014 07:38, edited 2 times in total.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Mon Apr 07, 2014 15:10

Here's another link I think will be helpful for understnading nodeboxes:

https://forum.minetest.net/viewtopic.php?id=2333
 

User avatar
Mitroman
Member
 
Posts: 62
Joined: Thu Apr 03, 2014 19:47
GitHub: Mitroman
In-game: Mitroman15

by Mitroman » Thu Apr 10, 2014 10:02

rubenwardy wrote:Node boxes allows you make blocks that are not complete cubes.

For example, stairs are made out of node boxes.

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L353

Or see my editor for this: Node Box Editor

EDIT: Jordach was inb4 :)


Thanks but NBE does not work...
My mods: Magican, Killer, Clock, Match, Cake.
My Txp: BLoXTxp.
My slogan: EVERYTHING IS AWESOME ;)

If I make any mistakes in english, please tell me so I can correct my mistakes.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

by Krock » Thu Apr 10, 2014 11:19

Mitroman wrote:Thanks but NBE does not work...

Why? Information please!

Image
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Thu Apr 10, 2014 13:22

Mitroman wrote:
rubenwardy wrote:Node boxes allows you make blocks that are not complete cubes.

For example, stairs are made out of node boxes.

https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L353

Or see my editor for this: Node Box Editor

EDIT: Jordach was inb4 :)


Thanks but NBE does not work...


I have just been told about two crucial feature-breaking bugs in the editor, which I am fixing.
Feel free to add to the list :P
Last edited by rubenwardy on Thu Apr 10, 2014 13:29, edited 1 time in total.
 

User avatar
Mitroman
Member
 
Posts: 62
Joined: Thu Apr 03, 2014 19:47
GitHub: Mitroman
In-game: Mitroman15

Re:

by Mitroman » Wed Jun 11, 2014 20:30

Krock wrote:
Mitroman wrote:Thanks but this programm does not work.

Mitroman wrote:Thanks :)

Mitroman wrote:Thanks but NBE does not work...

Why? Information please!

Image


I am a Linux user. If I use the command make on it, it gives an error. I do not know If I had to use the cmake command but... yeah... .
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Help] Modding drawtype nodebox

by Wuzzy » Wed Jun 11, 2014 22:25

Hey, people. What about actually explaining nodeboxes instead of pointing to 3rd party tools right from the beginning? ;-)

Okay, I explain nodeboxes (hopefully I do it right!):

The drawtype nodebox is an experimental (=may change in future!) drawtype for nodes.

To use nodeboxes for your node, set drawtype to “nodebox”.

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
drawtype = "nodebox"


Then, to actually use a nodebox, you also have to set the parameter “node_box”. This parameter must have a table. The format of the table is a bit tricky.

First, this table has a “type” key. Possible types of nodeboxes are: regular, fixed and leveled and wallmounted.

A regular nodebox is defined as this:
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
node_box = { type = "regular" }


The node will be drawn as a simple 1×1×1 cube, nothing exiting. This is all to say for regular nodeboxes.

Nodeboxes of the “fixed” type are much more interesting. Such a nodebox is defined by one or more little cuboids. You get to define the coordinates of two of the cornes of each cuboid, basically the lower and upper bounds of the cubiod.
The center of the node has the coordinates 0,0,0. And a node has the size of 1×1×1.

So, a regular 1×1×1 cube would have the coordinates from -0.5 to 0.5 for the X, Y and Z axis. The result would be the same as for normal nodes or for regular nodeboxes.

To define the coordinates for a single cuboid, you have to use a “box” table of 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
  {x1, y1, z1, x2, y2, z2}

x1, y1, z1 are the lower coordinates, x2, y2, z2 the higher ones.

The set of all cuboids you want to use has to be in assigned to the “fixed” parameter of the node_box definition.

To assign a nodebox the coordinates of a single cuboid, you have to use this node_box definition:
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
node_box = { type = "fixed",
fixed =   {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5} }

This nodebox is for a simple cube.

Now I give you a more interesting example: slabs. If you think about it, a slab is basically a cube which has been cut. The upper half of it has been removed. So we care about the Y axis.

So we can take the cube definition from about and simple set the upper Y bound to 0, since 0 is where the center is. This is how slabs are defined in minetest_game:
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
node_box = {
   type = "fixed",
   fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
}


Now maybe you want to use more than 1 cubiod. In this case, the “fixed” parameter must be a table of “box” tables.

Now think of stairs. It is impossible to create stairs with just a single cuboid. You need at least two. But think about it: It is not much more complicated than a slab. You can take the slab box and put another slab right above it. And then you just cut the upper slab box in half, along the Z axis.

Minetest_game defines stairs this way:
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
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},
   },
},

Note that the first box is EXACTLY the same as the slab box. The second one is which is interesting here: Look how it starts at Y=0, this is needed to place it on top of the slab. And it starts at Z=0, which is the “cutting it in half”.
Also note the parameter “fixed” here is a table of box tables. If you use more than one box, you have to use this style.


I hope you now got the basic idea. Theoretically, you could put as many boxes into the fixed table as you want but please don’t overdo it, for performance reasons.

Fixed nodeboxes can be much more complex than stairs. There are also fences, tables, stairs, bee hives. All this stuff is made by nodeboxes. You may want to read other people’s code and see how they did it.
But remember, you can only use cuboids. Also keep in mind those cubioids are always aligned to the three axes. You can’t just rotate a box by, let’s say, 30°, for example.


There are also the nodebox types “leveled” and “wallmounted”, but I don’t fully understand those. But I think you now know the most important stuff. :)
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Re:

by rubenwardy » Thu Jun 12, 2014 07:36

Mitroman wrote:I am a Linux user. If I use the command make on it, it gives an error. I do not know If I had to use the cmake command but... yeah... .


You need to use cmake. Follow the building guide in the first post in the project's topic.

If you have any more problems, please tell me. I can't fix problems if I don't know that they exist. :P
 

User avatar
spootonium
Member
 
Posts: 94
Joined: Fri May 02, 2014 01:38

Re: [Help] Modding drawtype nodebox

by spootonium » Sat Jun 14, 2014 10:12

Wuzzy wrote:Hey, people. What about actually explaining nodeboxes instead of pointing to 3rd party tools right from the beginning? ;-) (*snip*)


The only thing that I'd add to this (apart from a link to the wiki) is to mention a few of the limitations of nodeboxes:

  1. Nodeboxes are always orthogonal. They are a group of convex, rectangular blocks in Cartesian space (like much of the rest of the Minetest world). That means no angles other than 90 degrees.
  2. x1 has to be less than x2, otherwise errors occur. Likewise, y1 < y2, and z1 < z2.
  3. If your nodebox has multiple parts, be aware that the texture that you define for (for example) the top, will be tiled on the top of the entire node. Also, if part of a nodebox corresponds to a transparent pixel of a texture, that part is invisible.
  4. Intersecting nodeboxes with transparent textures look wierd. Just sayin'.
  5. type="wallmounted" allows you to define 3 different nodeboxes, depending on which face of a node (top, side, or bottom) it is placed. Think of it like the way default:torch has different orientations. The orientation is stored in param2, like with drawtype="facedir".
  6. type="leveled" means that y2 can change dynamically. Think of it as a water level. The value is stored in param2.
I write code. Sometimes, it even works.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron