[Mod] Structures [git] [minetest_mods_structures]

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Tue Aug 06, 2013 08:45

You could try to make a flat area for the village using code similar to this one (this one is only a proof-of-concept for smoothing the terrain around the flat area, and you will need to run it in a new world because it changes the mapgen to a very simple one).
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
local DMAX = 20
local AREA_SIZE = 80

minetest.register_on_mapgen_init(function(mgparams)
        minetest.set_mapgen_params({mgname="singlenode", flags="nolight", flagmask="nolight"})
end)

local cache = {}


local function get_base_surface_at_point(x, z, noise)
    local index = 65536*x+z
    if cache[index] ~= nil then return cache[index] end
    cache[index] = 20*noise:get2d({x=x, y=z})
    return cache[index]
end

local function surface_at_point(x, z, noise)
    if -AREA_SIZE<x and x<AREA_SIZE and -AREA_SIZE<z and z<AREA_SIZE then
        if flat_height~=nil then return flat_height end
        local s=0
        local n=0
        for x1=-AREA_SIZE, AREA_SIZE do
            n=n+2
            s=s+get_base_surface_at_point(x1, -AREA_SIZE, noise)+get_base_surface_at_point(x1, AREA_SIZE, noise)
        end
        for y1=-AREA_SIZE+1, AREA_SIZE-1 do
            n=n+2
            s=s+get_base_surface_at_point(-AREA_SIZE, y1, noise)+get_base_surface_at_point(AREA_SIZE, y1, noise)
        end
        flat_height = s/n
        return s/n
    end
    return get_base_surface_at_point(x, z, noise)
end

local SMOOTHED = AREA_SIZE+2*DMAX
local HSMOOTHED = AREA_SIZE+DMAX
local INSIDE = AREA_SIZE-DMAX

local function smooth(x, z, noise)
    local s=0
    local w=0
    for xi=-DMAX, DMAX do
    for zi=-DMAX, DMAX do
        local d2=xi*xi+zi*zi
        if d2<DMAX*DMAX then
            local w1 = 1-d2/(DMAX*DMAX)
            local w2 = 15/16*w1*w1
            w = w+w2
            s=s+w2*surface_at_point(x+xi, z+zi, noise)
        end
    end
    end
    return s/w
end

local function smooth_surface(x, z, noise)
    if -SMOOTHED>x or x>SMOOTHED or -SMOOTHED>z or z>SMOOTHED then return surface_at_point(x, z, noise) end
    if -INSIDE<x and x<INSIDE and -INSIDE<z and z<INSIDE then return surface_at_point(x, z, noise) end
    if -HSMOOTHED>x or x>HSMOOTHED or -HSMOOTHED>z or z>HSMOOTHED then
        local s = surface_at_point(x, z, noise)
        local s1 = smooth(x, z, noise)
        local m = math.max(math.abs(x), math.abs(z))
        return ((m-HSMOOTHED)*s+(SMOOTHED-m)*s1)/DMAX
    end
    return smooth(x, z, noise)
end


minetest.register_on_generated(function(minp, maxp, seed)
    local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
        local a = VoxelArea:new{
                MinEdge={x=emin.x, y=emin.y, z=emin.z},
                MaxEdge={x=emax.x, y=emax.y, z=emax.z},
        }
 
        local data = vm:get_data()
 
        local c_grass  = minetest.get_content_id("default:dirt_with_grass")
       
        local noise = minetest.get_perlin(12345, 6, 0.5, 256)
       
        local ni = 1
        for z = minp.z, maxp.z do
        for x = minp.x, maxp.x do
            local y=math.floor(smooth_surface(x, z, noise))
            if y<=maxp.y and y>=minp.y then
                local vi = a:index(x, y, z)
                data[vi] = c_grass
            end
        end
        end
       
        vm:set_data(data)
       
        vm:calc_lighting(
                {x=minp.x-16, y=minp.y, z=minp.z-16},
                {x=maxp.x+16, y=maxp.y, z=maxp.z+16}
        )
 
        vm:write_to_map(data)
end)


License of the code: WTFPL
 

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

by Sokomine » Tue Aug 06, 2013 15:15

Nore wrote:You could try to make a flat area for the village using code similar to this one (this one is only a proof-of-concept for smoothing the terrain around the flat area, and you will need to run it in a new world because it changes the mapgen to a very simple one).

I'm using a flat terrain for the villages mod I'm working on. Skipping height issues and concentrating on village planning in 2d is a great step forward towards realistic-looking villages with roads. I can only recommend it! Since the villages are later on supposed to "work" on a normal map, I'll have to flatten the land manually. This will most likely be a job for voxelmanip.
A list of my mods can be found here.
 

Nore
Member
 
Posts: 468
Joined: Wed Nov 28, 2012 11:35
GitHub: Ekdohibs

by Nore » Tue Aug 06, 2013 15:20

So on a normal map, you will need to flatten the land in the area the village will be. The code I posted should help you to smooth around to avoid edge effects.
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

by Inocudom » Mon Aug 19, 2013 03:26

https://forum.minetest.net/viewtopic.php?pid=106250#p106250
The above link leads to a new mod that could be of great assistance.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Fri Oct 25, 2013 14:17

I am happy to announce the next version of the Structures mod, with some of the biggest changes since its creation. After nearly two weeks of intensive coding, many components were entirely reformed and a load of new features was added. This is the primary change log:

- Road support is here! Roads use a point branching formula, which starts with one point that randomly branches into other points and so on. Roads are defined as sets of 5 schematics (P, I, L, T, X) which are segment and intersection types. All segments must be square and have the same size horizontally.

- Support for floors. When enabled, buildings are composed of 3 schematics (start, middle, end). Start is placed at floor level, middle is looped upward as the "floors" option specifies, end is placed at the top. This allows the creation of tall apartments, skyscrapers, etc.

- Terrain roughness check and floor creation are now group actions rather than structure actions. The area towns take up is now flattened, and all buildings and roads are aligned to the same height.

- Metadata is now a group option rather than global, allowing each town to define its own metadata settings for any node.

- Completely new sorting and alignment pattern for buildings, which uses space more efficiently via bounding box detection.

- Numeric properties of buildings and roads in mapgen.txt accept a space separated list, allowing artists to specify a minimum and maximum value that will be randomized. This means that for each instance, structures can have a random count, height offset, and number of floors. It's also possible to specify multiple trigger nodes and floor nodes for groups.

- Heavy remake of the default town. Several new structures were added, all old ones were replaced or remade. Houses now have gardens as well as basements. Roads have street lights, as well as underground sewer systems which players can navigate and explore. The town floor is randomly composed of either dirt with grass, or cobble for a paved area. The new town feels much more colorful and complete now.

[spoiler=screenshots]Image

Image

Image

Image

Image

Image

Image

Image[/spoiler]

Unfortunately, the mod is not ready to spawn large cities yet. Its architecture still requires the area to have been explored, building the group afterward. Structures are also placed all at once, making the server lag a LOT at spawn time. For this reason, it's not ready for stable use yet. I need to integrate a flatten mod or Lua mapgen, then have structures spawn progressively with on_generate. Till then, feel free to test and let me know what you think.
 

User avatar
webdesigner97
Member
 
Posts: 1307
Joined: Mon Jul 30, 2012 19:16
GitHub: webD97
IRC: webdesigner97
In-game: webdesigner97

by webdesigner97 » Fri Oct 25, 2013 15:55

Wow, I need to try this out on the weekend!
 

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

by paramat » Fri Oct 25, 2013 22:10

Very cool, is that a sewer level below the roads in the last screenshot?
I rely on donations to help provide an income https://forum.minetest.net/viewtopic.php?f=3&t=14935
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Sat Oct 26, 2013 00:45

paramat wrote:Very cool, is that a sewer level below the roads in the last screenshot?


Yes. The bury option exists for both buildings and roads, so with it one can create tunnels under roads like sewers. The new town's road segments all have a sewer system, manholes available at the ends of roads.
 

Azuna
Member
 
Posts: 89
Joined: Fri Sep 27, 2013 22:50

by Azuna » Thu Jan 09, 2014 22:27

i wil try it for ya and write what i see :D i need small village for my game
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Sun Jun 14, 2015 00:00

It's been quite a while since I've last updated this mod, or this thread has been active. I'm pushing forward to begin creating my game, and one of the things it will absolutely need are large towns and villages. I've looked into various methods of implementing such, but nothing so far seems to fit what I need by far as much as this mod. I want to get back into working on it.

As it's probably been said last time, most of the basics are ready. There's only one major problem: The entire area the city goes in must be loaded and active, so the ground can be scanned. After that, a huge zone is virtually deleted and hundreds of schematics are placed at once. Needless to say, this makes it impossible to create large cities, and also freezes the Minetest server for quite a few seconds during the process.

My plan is to use virtual boxes representing a city's area, each box becoming activated and planning the city the moment it's "touched" by the first on_generate function in that area. That way, a list of buildings can be persisted instead, and each individual schematic will be placed by the first on_generate function that touches it. It will be tricky, but I think I'll find some way of pulling it off.

For now, the mod is still working perfectly with latest Minetest GIT, and usable as is for medium sized towns. If you like its idea and want to suggest more changes, feel free to try it out and let me know what you think! Looking back at the Lua code I wrote those two years ago, I'm certainly happy with what I managed to do and how it's worked until now.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Sun Jun 14, 2015 23:16

The magic has happened today! Or at least the main part of it. I've almost entirely rewritten the basic mapgen system, going for a completely new and different approach, aimed at allowing colossally large cities to be created.

Cities are generated based on a grid representing virtual cubes, currently defaulted to 500 nodes horizontally and 100 vertically. There can only be one city per cube, and cities may not be larger than cubes. Each cube is activated when the first mapblock inside it is generated. When the cube initialized, a structure group is randomly chosen. If successful, the city is planned and a list of all the group's structures is generated for that cube. Each on_generate function will only spawn those buildings within its area, no more spawning everything in one go. To reduce server stress, a random delay is applied to each schematic after on_generate has executed, currently ranging from 5 to 10 seconds.

Of course, there are upsides and downsides. The upside is that cities of virtually any size can be generated, for the same lag level as the previous mechanism. The downside is that all buildings are planned before any area in the cube loads, meaning you can no longer measure any nodes before the city is created. For this reason, cities are currently generated either floating or buried underground, without a proper way to build a floor or cut the surrounding area... I do not know how I will find a proper solution to this.

Here's a screenshot of an enormous town, planned in one go but spawned across multiple mapblocks (on_generate events). It's somewhat less than 500 x 500 nodes... my ultimate aim is a town of 1000 x 1000 nodes (one kilometer). The experimental code can be found in this Github branch, where it will stay until I can get it working decently enough for master.

Image
 

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

Re: [Mod] Structure I/O & mapgen mod

by Sokomine » Mon Jun 15, 2015 03:10

MirceaKitsune wrote:Cities are generated based on a grid representing virtual cubes, currently defaulted to 500 nodes horizontally and 100 vertically. There can only be one city per cube, and cities may not be larger than cubes. Each cube is activated when the first mapblock inside it is generated.

Nores mapgen works with noise for the villages. That does have a number of advantages later on - in particular when adjusting the sourrounding terrain. It also helps in other situations.

MirceaKitsune wrote:When the cube initialized, a structure group is randomly chosen. If successful, the city is planned and a list of all the group's structures is generated for that cube. Each on_generate function will only spawn those buildings within its area, no more spawning everything in one go. To reduce server stress, a random delay is applied to each schematic after on_generate has executed, currently ranging from 5 to 10 seconds.

There's no need for that delay. The "list of all group's structures" is very intresting of course. In effect, that's what a village from mg_villages consists of as well.

MirceaKitsune wrote:Of course, there are upsides and downsides. The upside is that cities of virtually any size can be generated, for the same lag level as the previous mechanism. The downside is that all buildings are planned before any area in the cube loads, meaning you can no longer measure any nodes before the city is created. For this reason, cities are currently generated either floating or buried underground, without a proper way to build a floor or cut the surrounding area... I do not know how I will find a proper solution to this.

It's best to pretend the area your city spawned in had always been at that height and just make it look convincing. There needs to be a mechanism for smoothening the borders - where the city intersects with the rest of the terrain.

MirceaKitsune wrote:Here's a screenshot of an enormous town, planned in one go but spawned across multiple mapblocks (on_generate events). It's somewhat less than 500 x 500 nodes... my ultimate aim is a town of 1000 x 1000 nodes (one kilometer). The experimental code can be found in this Github branch, where it will stay until I can get it working decently enough for master.

That size is bigger than what can currently be done with mg_villages, but that has other reasons. The search range for any nearby villages is limited. If a village size (or, in your case, a town) exceeds this range, those parts that are too far away will not be generated.

It's understandable if you want to do it your own way and in the process learn more about mapgen. But you'll run into the same problems I've encountered and arrive - in most cases - at a similar solution. Therefore, it would be nice if you could do that part that is really diffrent from the villages and leave the rest (at least for now) to an existing mod that can handle it. You're creating a town - not a village. The buildings will be diffrent (closer together - even multiple-story, if I remember your plans correctly), the streets will be diffrent (schematics instead of gravel paths). You might even wish for each building to be diffrent.

Your current town generator may already be sufficiently similar to the village generator. The later one can be found in villages.lua in the function mg_villages.generate_village. Said function generates the entire village - including name, replacements etc. The function generate_bpos( village, pseudo_random_generator, village_noise, space_between_buildings) has the job of deciding which building will be placed where, and how it will be rotated. generate_bpos needs to return a table (as a list) containing all structures that are to be placed. Each entry in the table returned needs to have the following internal structure:
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
{x=pos.x, y=pos.y, z=pos.z, btype=btype, bsizex=bsizex, bsizez=bsizez, brotate = rotation, o=orient1, mirror=mirror }

...for building "btype" to be placed at (absolute) position pos. "btype" is the id of the schematic. A list of suitable ids can be obtained through mg_villages.village_type_data[ village_type ][ 'building_list'] . bsizex and bsizez show how far the building extends in each direction. Both depend on the schematic size and rotation and are included for convenience. brotate is the rotation of the building, and o the orientation of the plot of land the house is built on - which is relevant for the plotmarker that later on allows to buy the house. mirror can be set to true in order to get the house mirrored. Mirroring does not work perfect with nodebox-like nodes. Further information about a building (size, possible rotations) can be obtained through mg_villages.BUILDINGS[btype], which contains entries like sizex, sizez, ysize and orients (indicating which orientation is acceptable for that building). Those building-specific values are read from the schematic file when the building is registered. The village_gambit mod shows how a new village type can be regisered, complete with its own buildings.
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Mon Jun 15, 2015 12:22

Sokomine wrote:


Your villages mod sounds very interesting too! Sorry I didn't get to try it out and look more into how it works. Some things are probably better in its case, as this mod has its fair share of bottlenecks. A combination between the two might be interesting as well... for now however, I want to finish this mod the way I intended it and see where I get.

In any case, this mod was designed to be very flexible; The functions that generate the road and building lists are separated into their own files, and can easily be called to get a list of schematics. This is basically the bit of code responsible for fetching the structure list:

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
   -- get the the buildings and roads lists
   local schemes_roads, rectangles_roads = mapgen_roads_get(pos, scale.h, group)
   local schemes_buildings = mapgen_buildings_get(pos, scale.h, rectangles_roads, group)
   -- add everything to one scheme
   -- buildings should be first, so they're represented most accurately by metadata numbers
   local schemes = schemes_buildings
   for w, road in ipairs(schemes_roads) do
      table.insert(schemes, road)
   end


Simply use the schemes table and that's it. Of course there is a lot more going on to get there, such as translating the structures text file into a table.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Mon Jun 15, 2015 22:52

Today's changes represent a great step toward readying the new mapgen system. Changes include:

First of all, towns are no longer defined in a text file under a poor and confusing format, but directly in Lua as tables (a similar format to my Creatures mod). This is both faster, easier to maintain (add or remove properties) and will allow implementing custom functions which can run at generation time.

Next, town height is now determined by a 2D perlin map. You can also define the biomes that a town will spawn in (only works with mgv5 or mgv7). The issue of floating / buried towns can now be somewhat fixed, by synchronizing this with the perlin map of the biome the town spawns in, which should cause the town to be placed at the highest spot. However this must be done manually, as there is no way to know the perlin map of each terrain automatically.

Other improvements and cleanups were made. Town sizes are now calculated when the server starts, not every time a virtual cube is activated and we plan a town, which was a great waste of performance.

Also, since we now know the size of each town straight away, the scale of the virtual cube is automatically determined, and is basically the scale of the largest town. Additional multipliers are in place, which can be used to allow the largest town to have more room to randomly appear in (especially important for height).
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Tue Jun 16, 2015 23:06

Today has been a blast for this mod! I've done a great amount of improvements and fixes, as well as adding crucial new features. The new system is now stable and very close to being ready. A list of everything that has been changed today:

- Perlin noise no longer determines a global height for the group. Individual structures now have their own height, determined by the perlin noise at their exact position! Yes... this means that there are now bumpy roads (deviated by 1 node by default) and each building should be possible to align with the terrain (as long as you're using the exact same perlin noise parameters at the biome the structure is spawning on). You can optionally specify how centered each structure should be, between the minimum and maximum values determined by the noise.

- Layers have been at last implemented! Each structure can be assigned to a layer (number) or to none so it affects all layers. Structures will only check for collisions against other structures on the same layer, and will cut through structures on a different layer. This means that you can now create underground tunnels or suspended highways, which will not avoid the roads and buildings at ground level... you can also make some roads cut through other roads.

- Custom spawn functions are here, three in total: The first runs after the group is chosen and before the town is planned, and can return false to abort creating that town. The second and third run with each structure that is being spawned, one before the schematic is placed and one afterward... the first can also return false to abort creating that structure. The old metadata system (used to put addresses on signs) was removed with this, and address mechanics are now set by the town definition.

- Fix the structure spawning delay, heavily reducing lag. It was delaying chunks instead of individual schematics... now each schematic will be placed after (delay x number) seconds, where delay is a configurable value (by default 0.1) and number is the position of the structure in the table. This means that if the delay is 0.1 and a town has 1000 structures, the town will finish spawning in 100 seconds... granted all of it was generated on a single chunk.

- The virtual cubes are now persisted after server shutdown, in a text file in the world directory. This allows towns to be remembered after you restart the server, and let buildings who weren't spawned (because their chunk wasn't explored yet) resume spawning.

- A new property was added for roads, which lets you specify the minimum number of segments after which it branches. Can be used to specify how often that type of road can steer.

Here are a few new screenshots. The first four show bumpy roads and offset buildings, which were enabled for the default town. The last is me testing a suspended road system using the new layers.

+ Spoiler
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Wed Jun 17, 2015 21:30

I believe today was the final important day for this mod. I went through the new code and made the final fixes and adjustments that were needed. The new mapgen was merged into master and is now default, so simply checkout the mod from Github to get it. I've also separated the structure system and the default town into two mods, simply enable the modpack to get both working. Lastly, I documented the town definition and scripting API, making it easier for people to build their own towns now... note that there might still be changes and rewrites to the functions.

Testing would be welcome at this stage... feel free to grab the mod and try it yourself! Report any bugs you find here or on IRC (to Taoki). Please note however that floating or buried buildings are not bugs! The perlin map of each town must be synced with the perlin map of the biome it spawns in, and this mod should really be used with custom biomes for this exact purpose.

From my perspective, the mod is ready and at a usable stage now. I kindly request this topic to be moved from "WIP mods" to "Mod Releases". To end this massive series of updates, here are a two screenshots of a town that spawned in a snow biome... has a pretty Christmasy feel to it :)

Image
Image
 

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

Re: [Mod] Structure I/O & mapgen mod

by Sokomine » Wed Jun 17, 2015 23:36

MirceaKitsune wrote:I believe today was the final important day for this mod. I went through the new code and made the final fixes and adjustments that were needed. The new mapgen was merged into master and is now default, so simply checkout the mod from Github to get it. I've also separated the structure system and the default town into two mods, simply enable the modpack to get both working.

Congratulations! I'm glad you get it to work the way you wanted. It's always good when a mod gets finished.

MirceaKitsune wrote:Lastly, I documented the town definition and scripting API, making it easier for people to build their own towns now... note that there might still be changes and rewrites to the functions.

You don't by any chance want to write the documentation for the API for my mg_villages? :-))))

MirceaKitsune wrote:Please note however that floating or buried buildings are not bugs! The perlin map of each town must be synced with the perlin map of the biome it spawns in, and this mod should really be used with custom biomes for this exact purpose.

What do you recommend then in order to avoid floating/burried buildings? Embedding them into the terrain and making that look natural is a lot of work.

The roads with sewers below and lamps on top are very decorative. Using multiple layers so that a building can be diffrent each time (diffrent amount of floors) is also very intresting, especially for towns. I'm not sure if your buildings are the right ones for something that can be called "town" - but maybe they're just too diffrent from the styles of houses found around where I live. For a town, a higher density of buildings per area would be good. That also helps any towngen as it's easier to place smaller buildings than larger ones. On the other hand, more diffrent types will be needed so that it doesn't look repetitive. I'm thinking of something like Karsthafen.
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structure I/O & mapgen mod

by MirceaKitsune » Thu Jun 18, 2015 11:22

Sokomine wrote:Congratulations! I'm glad you get it to work the way you wanted. It's always good when a mod gets finished.


Thanks! Even more so in this case, since I started the mod about 2 years ago. Back when I was testing out the first mapgen system (didn't even have roads) I was already thinking of what the mod could do when it got to this stage. And yesterday, it finally did! Obviously though, a mod that's still being maintained is never fully ready and there are always new changes, but it has reached the point where I consider it v1.0.

Sokomine wrote:You don't by any chance want to write the documentation for the API for my mg_villages? :-))))


Even if I had the energy to learn the API and do some writing again, one thing I've learned is that it takes a lot of working with a mod and code to fully understand all of its features, bugs, abilities, etc. and document everything properly.

Sokomine wrote:What do you recommend then in order to avoid floating/burried buildings? Embedding them into the terrain and making that look natural is a lot of work.


The group and its buildings use a perlin noise map to determine height now, exactly what mapgens use to generate the base terrain. So you simply need to have the same noise parameters (offset, scale, resolution, etc) as the perlin noise used by the mapgen... more specifically the biome you have your town spawning on. Unfortunately this means there is no way to prevent floating / buried structures in mgv6, but if your world has custom biomes you should be able to make structures sync with the terrain. Like I said, this mod should normally only be used with custom biome definitions for this exact reason.

Sokomine wrote:The roads with sewers below and lamps on top are very decorative. Using multiple layers so that a building can be diffrent each time (diffrent amount of floors) is also very intresting, especially for towns. I'm not sure if your buildings are the right ones for something that can be called "town" - but maybe they're just too diffrent from the styles of houses found around where I live. For a town, a higher density of buildings per area would be good. That also helps any towngen as it's easier to place smaller buildings than larger ones. On the other hand, more diffrent types will be needed so that it doesn't look repetitive. I'm thinking of something like Karsthafen.


The current buildings are pretty much there so there is a default town that looks like a town, has the basic features needed for testing, and is not too horrible looking. I haven't put quite that much work into them... the game I plan to use this mod for shall have much better towns and cities, with many more buildings and road types.
 

metaspy
New member
 
Posts: 7
Joined: Fri Jun 12, 2015 03:17

Re: [Mod] Structures [git] [minetest_mods_structures]

by metaspy » Thu Jun 18, 2015 18:47

This mod looks amazing!
I am going to test it out right now. Thank you for all the hard work you have put into it!!!

and got an error straight away:
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
14:49:01: ERROR[main]: Failed to load and run script from
14:49:01: ERROR[main]: D:\Downloads\minetest-0.4.12-win64-msvc\minetest-0.4.12\bin\..\mods\structures\structures_groups_default\init.lua:
14:49:01: ERROR[main]: ...4.12\bin\..\mods\structures\structures/structures_io.lua:15: attempt to call field 'serialize_schematic' (a nil value)
14:49:01: ERROR[main]: stack traceback:
14:49:01: ERROR[main]:    ...4.12\bin\..\mods\structures\structures/structures_io.lua:15: in function 'io_get_size'
14:49:01: ERROR[main]:    ...\bin\..\mods\structures\structures/structures_mapgen.lua:28: in function 'group_size'
14:49:01: ERROR[main]:    ...\bin\..\mods\structures\structures/structures_mapgen.lua:277: in function 'register_group'
14:49:01: ERROR[main]:    ...in\..\mods\structures\structures_groups_default\init.lua:33: in main chunk
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Thu Jun 18, 2015 23:47

Yesterday I thought I was done with this mod for some time... turns out this was not the case. I asked on IRC how I could obtain the perlin noise used to generate a biome's terrain, and was surprised to hear that terrain isn't based exclusively on perlin noise like I thought it was... in other words you can't. However, there is a mapgen object which returns the heightmap of the last generated area, and it can be used from on_generate. It even works with all mapgens and biomes!

So as you might have expected, this means an unforseen rewrite took place; Building height is no longer based on perlin noise, but on the heightmap exclusively. Indeed, buildings are now always placed at ground level and align with the terrain, for the first time since the new mapgen system was introduced! Obviously a parameter was left in for roads to limit by how much they can deviate per segment... currently this is a little buggy, as intersections are not accounted and roads are still disproportional.

Image

metaspy wrote:This mod looks amazing!
I am going to test it out right now. Thank you for all the hard work you have put into it!!!

and got an error straight away:


That's a weird error, never had it here. I can only assume your version of Minetest doesn't contain minetest.serialize_schematic, which might make sense since I think it was added rather recently (I run MT only from GIT).
 

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

Re: [Mod] Structures [git] [minetest_mods_structures]

by Sokomine » Fri Jun 19, 2015 03:51

MirceaKitsune wrote:The current buildings are pretty much there so there is a default town that looks like a town, has the basic features needed for testing, and is not too horrible looking. I haven't put quite that much work into them... the game I plan to use this mod for shall have much better towns and cities, with many more buildings and road types.

The buildings arn't bad, except for the hotel. The other houses work fine, fit together in style and can be used as single houses or as part of a village. It may be an advantage for quite a lot of players that the houses are not furnished. It's also easier for mobs to move around inside mostly empty buildings. It's just not a very town-like house style, that's all :-). If you ever come up with good buildings using your seperate floor system (like with the hotel), I'd love to use them as well and extend mg_villages accordingly.
A list of my mods can be found here.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Fri Jun 19, 2015 22:29

Today I ironed out the final bugs I could find, marking the mod stable and ready again. Important highlights include:

- The centering system was reworked to use customizable linear interpolation again, and averages to the height of the first structure that spawned. This fixes road intersections deviating from some segments and leaving gaps.

- Ground level is now detected much more aggressively per structure; Instead of checking the center, each point within the structure's radius is scanned and the lowest one is chosen. This drastically reduces the chances of structures still having parts not touching the ground, although they might occasionally get buried more than normally needed.

- Areas (mapgen cubes) are only activated when the chunk is within the height of any structure group, not always. This prevents someone who is exploring at very hight / low heights making a town never spawn in the same horizontal area once it's explored at ground level. It also improves performance, by not trying to generate towns for people at distant heights who will never see them.

As with every update announcement, here are a few more screenshots for you to enjoy. They primarily show the patterns roads generate now that they're free to stretch over great lengths... sometimes they even create bridges over water between distant islands.

+ Spoiler
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Sat Jun 20, 2015 18:36

Since working on this mod made it a pretty straining week, I wanted to do something simpler and more fun today. You all probably know about the Creatures mod, which is the second major mod for Minetest I'm working on. Since communication between mods is something I've wanted to try out, I now added support for the default creatures to the default structures.

More precisely: If you have both the Structures and Creatures mod packs installed and enabled, people (humans and anthros) will be spawned by the structures, both indoor and outdoor. This means that when a new town is generated, there's a chance that you will find people in houses, gardens, on the street, and even in the sewers!

Note however that this causes a few more mobs than usual to spawn and activate, so your sever will use a greater amount of CPU and RAM. With both mods enabled, Minetest reached up to 2 GB of RAM and 25% CPU usage... which probably can't be improved much Lua side. Also mobs are bad at wandering around in towns... they don't know how to open doors (yet) and will also jump off high places (like roofs) and hurt themselves foolishly. In any case, the environment is certainly a lot more lively. Here are some screenshots of towns with mobs:

+ Spoiler
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Sat Jun 27, 2015 22:55

I have a great update to share today, related to the mod's road planning system; Although most users probably never noticed this problem, Structures had a major limitation ever since roads were implemented years ago: Roads would always branch from a single point, which was placed at a random position within the group's area. This meant that you couldn't get disconnected roads appearing in the same town, that roads would be more dense around a specific part of the town, and now that heightmaps were added it also meant the town's entire road system appeared at one height.

This all changed today, after I finished a series of rewrites to the road calculation mechanism. The most important change is that roads have multiple starting points, which are placed randomly inside evenly distributed areas divided across the town's surface. The count and number of branches can be configured per road type, as well as the minimum and maximum branch distance. Additionally, structures can now be part of multiple layers (collision groups) and layers are also accounted when calculating the size of a town or how road starting points are distributed.

The changes you will see in practice are essentially new road patterns: There will be multiple stretches of roads not connected to each other. Further more, every road segment is flattened around the height of the starting point it spawned from, no longer at a global height... meaning each road system in the town will adapt to the height of the terrain it spawned on, and you'll see roads at various heights. This is a huge improvement, and the last important feature that needed to be added to Structures.

Here are some screenshots showing examples of independent road systems, spawned at different locations and heights:

+ Spoiler
 

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

Re: [Mod] Structures [git] [minetest_mods_structures]

by Krock » Sun Jun 28, 2015 08:23

Comparing to the previous road system is this one a great improvement.
Good job!
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
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Sun Jun 28, 2015 12:01

A heads-up: I have re-licensed the code from WTFPL to LGPL. This mod has grown into a pretty large project, and as such I think it needs a clearer and less controverted license. Since LGPL is the license Minetest itself is released under, while I exclusively want all of my code to be free but always remain open-source, I am happy with this move.
 

dannyplaysminetest
Member
 
Posts: 37
Joined: Sun Jun 28, 2015 19:20
In-game: Danny

Re: [Mod] Structures [git] [minetest_mods_structures]

by dannyplaysminetest » Sun Jun 28, 2015 19:28

Thanks for this Mod, installed it yesterday not used it yet, but wil be very useful in future city building projects.. ^_^
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Re: [Mod] Structures [git] [minetest_mods_structures]

by MirceaKitsune » Sun Jun 28, 2015 23:02

dannyplaysminetest wrote:Thanks for this Mod, installed it yesterday not used it yet, but wil be very useful in future city building projects.. ^_^


No problem, and glad that people are liking this mod! Make sure to update to latest GIT master... I found and fixed some minor bugs and crashes soon after implementing and announcing the new features yesterday.
 

Previous

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 2 guests

cron