voxel / voxel-land

a terrain generator with grass, dirt, stone, and trees (addon for voxel-engine)
6 stars 2 forks source link

Tall land features #5

Open greenlion opened 10 years ago

greenlion commented 10 years ago

voxel-land only considers chunks with y=0 to be "sea level" y>0 is air and y<0 is stone (at least until issue #2 is closed).

Should tall features such as mountains taller than 32 chunks or valleys deeper than 32 chunks be supported?

A few things need to change to make this work:

  1. The constructor object needs to be modified to take min/max chunks in which to generate voxels.
  2. The if statement needs to be modified to check min/max
  3. The y value may need to be adjusted in chunks above/below "sea level" because the height map may be > 32

I have these changes made in a fork, but my height map comes from a XHR request, instead of being generated by noise.

deathcap commented 10 years ago

Switching from 2D to 3D noise (for caves, GH-3) could help with larger mountains/valleys (since chunks from the mountains would be generated independently instead of from a height map only at sea level), but yeah having these changes would be useful for large structures in general. Currently any generated structure which crosses loaded chunks during generation is clipped (since setBlock doesn't load chunks)

greenlion commented 10 years ago

Yes, having an infinite world in all directions (within limits) does add a lot of interesting possibilities. It would technically be possible, for example, to model the world as a spheroid and let the player "dig all the way to china" as it were, provided they didn't try to dig through the core :)

greenlion commented 10 years ago

Do you think that setBlock should load chunks?

deathcap commented 10 years ago

Do you think that setBlock should load chunks?

Probably not, I'd be worried about easily introducing frequent chunk loading/unloading (thrashing) bugs negatively impacting performance (orphaned chunks) - apparently this is a big problem in modded MC because accessing blocks through most APIs automatically loads chunks (meaning you have to explicitly call blockExists before access to avoid these problems): http://reddit.com/r/feedthebeast/comments/1fc1vp/the_orphan_chunk_promise/

greenlion commented 10 years ago

This should probably be another issue, but...

What about buildings? Do you think they should be represented as a polygon (perhaps with a roof type (flat, steeple, arch, etc) and number of levels), or as some other data structure? If they are stored as a polygon, then the x,z points for the building footprint need to be stored and the y which represents the foundation level. If you want more complexity, then buildings could be generated in slices. This allows buildings to be modular, for example, castles can be built from a set of reusable turrets connected by walls, and the interior could consist of randomly generated rooms with a big central throne room.

I'm thinking about a plugin that generates buildings, one that generates roads and a plugin that generates town maps from buildings and roads.

To give you an idea, I would like to build a game similar to "starflight 1 and 2" where the universe is mostly procedurally generated. If you have played mass effect, think of the exploratory features of the game (searching systems, scanning for resources, landing, driving around, mining ores). Then combat can be added later :) Basically I'm thinking a cross between "trade wars 2002, star flight, and minecraft".

I'd like to make any work I do as reusable as possible. Btw, I really like what you are doing with voxpopuli, very nice work.

On Mon, Feb 3, 2014 at 7:55 PM, deathcap notifications@github.com wrote:

Do you think that setBlock should load chunks?

Probably not, I'd be worried about easily introducing frequent chunk loading/unloading (thrashing) bugs negatively impacting performance (orphaned chunks) - apparently this is a big problem in modded MC because accessing blocks through most APIs automatically loads chunks (meaning you have to explicitly call blockExists before access to avoid these problems): http://reddit.com/r/feedthebeast/comments/1fc1vp/the_orphan_chunk_promise/

Reply to this email directly or view it on GitHubhttps://github.com/deathcap/voxel-land/issues/5#issuecomment-34028579 .

deathcap commented 10 years ago

What about buildings? Do you think they should be represented as a polygon

Hmm, suppose it depends on if you want the buildings to be part of the world grid or independent entities. If they are entities, polygons sound reasonable to me. For voxel-based buildings, two ways I'm aware of to generate them - I think (modded) MC uses both:

1) start generation at a given point (determined by e.g. simplex noise), expand outward, loading and saving all chunks necessary to encompass the structure. This explains the behavior I've heard of in MC where a player is walking around and then suddenly a large building (from a structure-heavy mod like The Twilight Forest) is generated nearby - once the 'origin' chunk is loaded, by coming into the player's loaded-chunk range, the structure is generated outward. Advantage is simplicity of implementation, but for extremely large structures it can cause this unusual behavior and/or performance issues if too many chunks have to be quickly loaded, saved, then unloaded. This technique may also be used by MC's village generation (village well = center), but I'm not 100% sure about that.

2) Procedurally generate each structure part using simplex/perlin noise. I suspect this is how MC's abandoned mineshafts and fortresses are generated, since they can be fairly large and generating them all at once would be problematic. Mineshafts also lend themselves well to this kind of modular generation. Similar idea to your buildings. BTW, I was also looking into the "craftscripts" feature of the Minecraft Bukkit plugin "WorldEdit": https://github.com/sk89q/worldedit/tree/master/contrib/craftscripts - though WorldEdit is written in Java, craftscripts are written in JavaScript and executed using Rhino (a potentially interesting possibility for integration with voxel.js/NodeJS seeing as its natively written JavaScript?), and found this: http://forum.sk89q.com/threads/fab-a-city-fabulous.556/ https://github.com/echurchill/WorldEdit_City - an impressive-looking city generator (at least from the screenshot), might be helpful for your game.

I'd like to make any work I do as reusable as possible. Btw, I really like what you are doing with voxpopuli, very nice work.

Thanks! And likewise. Trying to build everything in line with the 'Unix philosophy' of small modular pieces, I'm sure there's plenty of code we can reuse =)

greenlion commented 10 years ago

For generating building interiors, some sort of 'space filling curve' might be useful to creating interior layouts.