How to make Trees?

User avatar
firefox
Member
 
Posts: 1185
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox

How to make Trees?

by firefox » Fri Mar 04, 2016 08:27

i need to know how to make trees for my subgame.
i know that sokomine's trees_lib can register new tree types, but it can only use existing tree models, not make new ones. also it does not support tree spawning at mapgen time, so the custom trees added by it can only be spawned as saplings.

so what i want to know is the following:

- how are the default tree models made?
i can't read the files in any way.

- how can i make new tree models?
i heard about lua tables, but i don't understand at all how they are written and how to add random elements to the tree growth, like higher or lower trunks, more or less leaves and/or fruits.
 

User avatar
everamzah
Member
 
Posts: 490
Joined: Thu Jan 29, 2015 00:47
GitHub: everamzah
IRC: everamzah
In-game: everamzah

Re: How to make Trees?

by everamzah » Fri Mar 04, 2016 08:45

Here's some info from game_api.txt in minetest_game: https://github.com/minetest/minetest_ga ... i.txt#L406

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
default.grow_tree(pos, is_apple_tree)
^ Grows a mgv6 tree or apple tree at pos

default.grow_jungle_tree(pos)
^ Grows a mgv6 jungletree at pos

default.grow_pine_tree(pos)
^ Grows a mgv6 pinetree at pos

default.grow_new_apple_tree(pos)
^ Grows a new design apple tree at pos

default.grow_new_jungle_tree(pos)
^ Grows a new design jungle tree at pos

default.grow_new_pine_tree(pos)
^ Grows a new design pine tree at pos

default.grow_new_acacia_tree(pos)
^ Grows a new design acacia tree at pos


I don't think this is the only way. Hope this helps.
 

User avatar
firefox
Member
 
Posts: 1185
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox

Re: How to make Trees?

by firefox » Fri Mar 04, 2016 09:54

everamzah wrote:Here's some info from game_api.txt in minetest_game: https://github.com/minetest/minetest_ga ... i.txt#L406

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
default.grow_tree(pos, is_apple_tree)
^ Grows a mgv6 tree or apple tree at pos

default.grow_jungle_tree(pos)
^ Grows a mgv6 jungletree at pos

default.grow_pine_tree(pos)
^ Grows a mgv6 pinetree at pos

default.grow_new_apple_tree(pos)
^ Grows a new design apple tree at pos

default.grow_new_jungle_tree(pos)
^ Grows a new design jungle tree at pos

default.grow_new_pine_tree(pos)
^ Grows a new design pine tree at pos

default.grow_new_acacia_tree(pos)
^ Grows a new design acacia tree at pos


I don't think this is the only way. Hope this helps.

not really ...
i can use the default trees by copying their decoration-registrations from the default mapgen.
what i want to do is to add new trees with new models.
trees_lib can do this, but it can only use existing models and exchange the trunk and leaf nodes with customs ones.

i want to create a new model.
i have seen that other tree mods use lua tables to define trees, but there is now explanation how it works.
this is the banana tree from ethereal:
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
-- Banana Tree (built column by column, bottom to top)

local i = "air"
local t = "ethereal:banana_trunk"
local l = "ethereal:bananaleaves"
local b = "ethereal:banana"

ethereal.bananatree = {
   size = {x=7, y=8, z=7},
   data = {

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=180}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=b, param1=070}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=b, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=b, param1=070}, {name=t, param1=255}, {name=b, param1=070}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=b, param1=255}, {name=l, param1=255}, {name=b, param1=255}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=l, param1=255}, {name=l, param1=255}, {name=l, param1=255}, {name=l, param1=255}, {name=l, param1=255}, {name=i, param1=000},
{name=l, param1=255}, {name=l, param1=180}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=l, param1=180}, {name=l, param1=255},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=t, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=t, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=t, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=t, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=b, param1=070}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=b, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=180}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=l, param1=255}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},
{name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000}, {name=i, param1=000},

   },
   yslice_prob = {
      {ypos=1, prob=127},
   },
}

i understand how this like a 3D coordinate system, defining each node type at each position, but i don't understand the param and yslice stuff.
also i heard that the default trees were made like this too, but are now converted to .mts files and allow random variations in shape.
i want to know how to do that.
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: How to make Trees?

by TenPlus1 » Fri Mar 04, 2016 10:03

in the last example param1 is generally used for placement chance... 255 is definitely place, 070 is hardly place (for bottom fruits), so the lower the number the less likely that block is to be placed... It's used for random tree generation... The ysplice is used as a chance to offset the tree placement, in this case ypos = 1 (vary the height level) with a probability or 127.
 

User avatar
firefox
Member
 
Posts: 1185
Joined: Wed Jan 14, 2015 07:34
In-game: Red_Fox

Re: How to make Trees?

by firefox » Fri Mar 04, 2016 19:01

oh... so with a chance of 127 (out of 255?) the tree will be 1 node taller?
 

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

Re: How to make Trees?

by Wuzzy » Thu Mar 10, 2016 17:18

AFAIK there are two common ways to make trees:
Schematic and L-system trees.
A schematic is just a predefined set of blocks you can place, it will look exactly the same each time you place it, but you can also define every single block. Of course, it takes some time to create a good schematic.
AFAIK the Ethereal mod uses schematics for the trees.

Another way to make really cool trees even with some randomness involved is by using L-system trees. Look it up in lua_api.txt and the dev wiki, it is a really cool feature in Minetest.
Writing L-system trees can be a bit tedious when you do it from a text editor only, so I have written the L-System Utility. The mod has some documentation which you can access directly in the game and the thread also links to pages to help you get started.
If you have questions about L-system trees, feel free to ask.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: How to make Trees?

by Sokomine » Sat Mar 12, 2016 20:53

firefox wrote:i know that sokomine's trees_lib can register new tree types, but it can only use existing tree models, not make new ones. also it does not support tree spawning at mapgen time, so the custom trees added by it can only be spawned as saplings.

The tree model has to come from somewhere, yes. trees_lib supports several ways of telling the game how your tree is supposed to look like.

firefox wrote:- how are the default tree models made?
i can't read the files in any way.

If you're saying "files", then you're most likely refering to trees defined in schematics. Those files usually have the extension .mts (MineTest schematic). Those files are not intended for beeing read by human beeings. They're a way to save a tiny part of a MineTest map, i.e. a house (or, in this case, a tree) and place it elsewhere (i.e. when the sapling grows). The schematics can also be used to spawn those "decorations" they contain (i.e. trees) at mapgen time. Ethereal makes heavy use of that. Some trees from the default minetest game also come as schematics. You can find them at https://github.com/minetest/minetest_game/tree/master/mods/default/schematics.

firefox wrote:- how can i make new tree models?

If you want to take the schematic approch, you just fire up your Minetest world and start "building" the sample tree somewhere in the game - just like when you're building anything else. Once you're satisfied with your tree, you can save it as a schematic. For that, either use the /mtschemcreate command from WorldEdit, or place two build chests from my handle_schematics mod.

firefox wrote:i heard about lua tables, but i don't understand at all how they are written and how to add random elements to the tree growth, like higher or lower trunks, more or less leaves and/or fruits.

The schematics are not overly flexible in that regard. They do allow for some randomness, but most of it is just placing the model. Although that may sound boring, it does create intresting landscapes. After all the trees intersect and are placed at diffrent heights. That's usually already quite sufficient for a good look.

firefox wrote:what i want to do is to add new trees with new models.
trees_lib can do this, but it can only use existing models and exchange the trunk and leaf nodes with customs ones.

trees_lib can do that as well :-) It was built for such a job. You just have to supply the art - the textures and the model :-)

firefox wrote:i have seen that other tree mods use lua tables to define trees, but there is now explanation how it works.
this is the banana tree from ethereal:

Ah :-) That is just another way of defining schematics. The best way to learn more about them (and how to spawn them at mapgen time) might be a look at doc/lua_api.txt. Read all about schematics and decorations (in particular the section "Schematic specifier"), as that's what you are looking for.

Wuzzy wrote:A schematic is just a predefined set of blocks you can place, it will look exactly the same each time you place it, but you can also define every single block. Of course, it takes some time to create a good schematic.

Not exactly true, although most schematics are used that way and most of us don't care about the random factors that can be applied. Hmmm was a bit upset when learning that his schematics where used for storing houses and the like instead of the decorations he intended the file format and decorations mechanism to be used for :-)

I didn't have much time the last months and didn't pay sufficient attention to development. Has a good editor for schematics come up in the meantime? Static schematics are easy enough to handle - just build, save and use them - but those factors of randomness (y-slice probability and probability of single nodes) are not exactly intuitive. Using the lua table format is a way to handle that, but it's a lot easier to actually build the decoration in the game instead of creating the table manually.
A list of my mods can be found here.
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: How to make Trees?

by burli » Sat Aug 13, 2016 07:34

Sokomine wrote:Not exactly true, although most schematics are used that way and most of us don't care about the random factors that can be applied.

Most of us don't know that is is possible or how it works. Didn't see any doc about this yet
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: How to make Trees?

by Sokomine » Sat Aug 13, 2016 15:24

burli wrote:
Sokomine wrote:Not exactly true, although most schematics are used that way and most of us don't care about the random factors that can be applied.

Most of us don't know that is is possible or how it works. Didn't see any doc about this yet

It is described in doc/lua_api.txt under "Schematic specifier". There are two ways:

doc/lua_api.txt wrote:* The `yslice_prob` field is a table of {ypos, prob} which sets the `ypos`th vertical slice
of the schematic to have a `prob / 256 * 100` chance of occuring. (default: 255)

With that option, you can make entire horizontal layers of your schematic disappear at random. It is useful for making trees of diffrent height.

lua_api.txt wrote: * `prob` (alias `param1`): the probability of this node being placed (default: 255)

That value can be set for each node in the schematic. There's just no good way to provide that information (how could the user enter it?) when saving the schematic from a decoration built inside the game. I think that's why paramat is mostly using tables to store his trees.
A list of my mods can be found here.
 

paramat
Member
 
Posts: 2662
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat

Re: How to make Trees?

by paramat » Mon Aug 15, 2016 13:58

Yeah for control over per-node probability and per-node 'force-place' use lua tables, they are quite fast to work with and you can copy-paste vertical slices to create the other half of the tree.
This mod is used by devs to create all mapgen schematics https://github.com/minetest-mods/saveschems
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 61 guests

cron