Page 1 of 1

Project: shed in the forest

PostPosted: Tue Feb 14, 2017 19:53
by burli
My new project is called "shed in the forest". The target of this project is to find a way to place this shed in a forest without damaging the environment and on a flat place, not at a slope.


Image

Re: Project: shed in the forest

PostPosted: Tue Feb 14, 2017 21:49
by D00Med
Interesting...how are you going with it?

Re: Project: shed in the forest

PostPosted: Tue Feb 14, 2017 23:28
by burli
First I want to find a flat spot. This is the difficult but part. I have two ideas. Both use the height map

Then I need to check if there is enough space. Could be difficult too

I will accept a little error tolerance in both cases. If the shed is placed on a slight hill (one node) the door should face downhill. An the area in front of the door should be free

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 00:59
by D00Med
Ok. Seems to be a lot of effort for a shed, but I'm going to assume that it's not really about the shed itself.

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 05:47
by burli
Well, it is about the shed, and of course about other schematics. Think about a villages mod. They currently only work on a plane, but Minetest has no plains

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 06:22
by bell07
Please have a look to the method
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
propose_anchor(pos)
in my schemlib-plan mod. Maybe we have the same goals with the mods: https://github.com/bell07/minetest-schemlib/blob/master/plan.lua#L368
One difference, I do not search for a flat place because I flat the place byself before build the building. So the method checks if a building at a given position is buildable and propose the best "y" value in this case. So your mod needs to check in random places. I am working currently (ok stopped since some weeks) on a builder-npc that runs in the world, check the places and build if possible.

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 06:35
by Sokomine
burli wrote:Well, it is about the shed, and of course about other schematics. Think about a villages mod. They currently only work on a plane, but Minetest has no plains

That's right. And yet - the majority of human players flattens the area before starting a project. Only few manage to adjust their structures to the terrain. And even those usually adjust the terrain in places. Most MT surfaces aren't particulary building-friendly.

bell07 wrote:I do not search for a flat place because I flat the place byself before build the building. So the method checks if a building at a given position is buildable and propose the best "y" value in this case. So your mod needs to check in random places. I am working currently (ok stopped since some weeks) on a builder-npc that runs in the world, check the places and build if possible.

Sounds intresting. And it's not too far from the way mg_villages does it (check for a fitting height and adjust the terrain to that height). I'm not quite satisfied with some aspects yet and considering doing some changes regarding the embedding of the villages into the world. The streets may need ramps in some cases, and the terrain blending area could be larger.

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 07:51
by bell07
Heavy unfinished, but I uploaded my sample mod that utilizes the propose_anchor to github: https://github.com/bell07/minetest-sche ... ilder_npcf
The mod builds node by node, but it is possible to place the plan at once using do_add_chunk() in a loop.

@Sokomine, did you tried already to utilize the minetest.find_path() for streets? Just calculate a path from door to door and replace all nodes bellow to the street-nodes. (untested idea)

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 08:02
by burli
I want to search for flat spots because I don't want to place schematics on places like this. Even flatten and filling wouldn't help there

Image

Image

I'll take a look at your code, but after a quick overview I think I go another way

That's right. And yet - the majority of human players flattens the area before starting a project.


That's right, but I want to generate a map automatically and I don't want to modify the map to much

Most MT surfaces aren't particulary building-friendly.


I want to use mgv7 with slightly modified noise parameters because I think the default settings doesn't look that good

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 11:05
by hajo
burli wrote:search for flat spots because I don't want to place schematics on places like this.
Even flatten and filling wouldn't help there

How about counting spaces with air,water / dirt,sand,stone / trees,leaves,flowers
at the intended place the size of you schematic, as well as at lower height of that.

If air is found at lower height, adjust the intended position downward
--> that should take care of that half-floating hut.

Allow a certain amount of stone,sand etc. to be removed/replaced,
and plants to be replaced completely.

And maybe have the bottom layer of your shed 'optional',
i.e. is allowed to merge with the current terrain --> automatic fill up/levelling.

Also, how about optional blocks of stairs/slabs, that only get placed
when the terrain on the next block is higher/lower ?

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 11:46
by burli
hajo wrote:How about counting spaces with air,water / dirt,sand,stone / trees,leaves,flowers
at the intended place the size of you schematic, as well as at lower height of that.


Something like that. I will try different strategies, e.g. octrees over air and everything that can be replaced (group:flora for example)

hajo wrote:And maybe have the bottom layer of your shed 'optional',
i.e. is allowed to merge with the current terrain --> automatic fill up/levelling.

Also, how about optional blocks of stairs/slabs, that only get placed
when the terrain on the next block is higher/lower ?


The schematic is not carved in stone. That's why I use lua schematics. They can easily be changed

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 15:54
by Sokomine
burli wrote:I want to search for flat spots because I don't want to place schematics on places like this. Even flatten and filling wouldn't help there

It's a combination of flattening and filling up.

burli wrote:That's right, but I want to generate a map automatically and I don't want to modify the map to much

That was my intention as well. Villages inside the mg mapgen work fine as the placement of villages is a direct part of the mapgen. Other mapgens are diffrent and unkown to the villages placement code. I want to be able to place villages and huts in any world, no matter which mapgen was used. It may still fail if the mountains are too high. If you stick to one particular mapgen, life can be a lot easier. It's also easier if you're placing just one small hut and not a big building for which there won't be any sufficiently flat area anywhere in the world. MT mapgens are usually incredibly small-scale with a very rough terrain.

hajo wrote:If air is found at lower height, adjust the intended position downward
--> that should take care of that half-floating hut.

Allow a certain amount of stone,sand etc. to be removed/replaced,
and plants to be replaced completely.

Both is done in some way inside mg_villages. The area the mapgen presents is scanned for its height, an optional height for the village is calculated, and the height of the terrain is adjusted accordingly. There's no guarantee that this will produce a good result. The terrain is really rough. If about half of the sourrounding nodes have a high elevation and belong to a mountain/plateau, while the other half is at sea level, which height will be appropriate? It would take a lot more height information and scanning in order to make a better decision.

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 17:27
by burli
My targets are not only villages. I want to be able to place larger schematics in general. Not only buildings, but any kind of structure or plants or whatever

Re: Project: shed in the forest

PostPosted: Wed Feb 15, 2017 22:10
by Sokomine
Sounds fine. Hope you'll find a good solution! At least there's a chance as long as you stick to a defined mapgen.

Re: Project: shed in the forest

PostPosted: Fri Feb 17, 2017 13:45
by burli
This get's more difficult than I thought. I just loop over a chunk and count the air nodes, but even in pure air I don't get the expected 512000. I have deal with a lot of 'ignore' and I guess that doesn't work

Re: Project: shed in the forest

PostPosted: Fri Feb 17, 2017 16:15
by azekill_DIABLO
What an awesome work for a shed! however, if it gets enough efficient, creating nature-respectful villages should be far more easy!

Re: Project: shed in the forest

PostPosted: Fri Feb 17, 2017 23:46
by Sokomine
burli wrote: I have deal with a lot of 'ignore' and I guess that doesn't work

Those are from neighbouring mapblocks (the outer shell).

Re: Project: shed in the forest

PostPosted: Sat Feb 18, 2017 09:58
by burli
You are right. I had a bug in my code. Now it works fine.

I need to learn everything about trees now (octree, quadtree...)