Page 1 of 1

[Help] Modding drawtype nodebox

PostPosted: Mon Apr 07, 2014 14:52
by Mitroman
Hi. Can somebody explain me the drawtype nodebox? Thanks. =)

PostPosted: Mon Apr 07, 2014 14:56
by hoodedice
I am not so experienced in this line of work, but people swear by this program: https://forum.minetest.net/viewtopic.php?id=2840

PostPosted: Mon Apr 07, 2014 14:56
by rubenwardy
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 :)

PostPosted: Mon Apr 07, 2014 15:10
by Topywo
Here's another link I think will be helpful for understnading nodeboxes:

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

PostPosted: Thu Apr 10, 2014 10:02
by Mitroman
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...

PostPosted: Thu Apr 10, 2014 11:19
by Krock
Mitroman wrote:Thanks but NBE does not work...

Why? Information please!

Image

PostPosted: Thu Apr 10, 2014 13:22
by rubenwardy
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

Re:

PostPosted: Wed Jun 11, 2014 20:30
by Mitroman
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... .

Re: [Help] Modding drawtype nodebox

PostPosted: Wed Jun 11, 2014 22:25
by Wuzzy
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. :)

Re: Re:

PostPosted: Thu Jun 12, 2014 07:36
by rubenwardy
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

Re: [Help] Modding drawtype nodebox

PostPosted: Sat Jun 14, 2014 10:12
by spootonium
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.