Experimental 2d version of terraman
Go to file
2021-11-22 23:51:16 +01:00
areas Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
data Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
doc_classes Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
level_generator Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
library Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
meshers Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
nodes Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
thirdparty/lz4 Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
world Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
.gitignore Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
config.py Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
defines.h Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
LICENSE Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
README.md Initial commit. (Just added terraman). 2021-11-22 22:00:45 +01:00
register_types.cpp Postfix everything with 2d. 2021-11-22 23:51:16 +01:00
register_types.h Fix compile. 2021-11-22 22:10:41 +01:00
SCsub Postfix everything with 2d. 2021-11-22 23:51:16 +01:00

Terraman

experimental terrain and building engine for godot, based on voxelman.

Voxelman's readme: (will update later)

  • The word "Voxelman" got mass replaced to "Terraman". -

A voxel engine module for godot, focusing more on editor integration, gameplay-related features, and extendability (even from gdscript), without sacrificing too much speed.

This is an engine module! Which means that you will need to compile it into Godot! See the compiling section here.

You can find a demonstration project here: https://github.com/Relintai/the_tower

It supports both godot 3.2 and 4.0 (master last tested commit). Note that since 4.0 is still in very early stages I only check whether it works from time to time.

Optional Dependencies

https://github.com/Relintai/thread_pool: Threaded chunk generation. Without this Terraman is single threaded!
https://github.com/Relintai/texture_packer: You get access to TerramanLibraryMerger.
https://github.com/Relintai/mesh_data_resource: You get access to a bunch of properties, and methods that can manipulate meshes.
https://github.com/Relintai/props: You get access to a bunch of properties, and methods that can manipulate, and use props.
https://github.com/Relintai/mesh_utils: Lets you use lod levels higher than 4 by default.

Pre-built binaries

You can grab a pre-built editor binary from the Broken Seals repo. From 0.3.4 and onwards it contain this module instead of voxelman.

Usage

First create a scene, and add a TerraWorldBlocky node into it. Create a TerramanLibrary, and assign it to the Library property. Also, add a TerraSurface into your library.

(TerraWorldBlocky is the only one that works properly for now, this will soon be fixed!)

Tick the editable property, deselect, then select the world again, and click the insert button at the top toolbar, or press B to insert a voxel at the inspector's camera's location.

Select the add button, and now you can just add voxels with the mouse, by clicking on the newly added voxel.

TerramanLibrary

This class stores the materials, and the TerraSurfaces.

Note: If you want lods, assign equal (or more) materials than your maximum lod level. If you only want one material just assign it multiple times. If you don't then your meshes won't have materials (They will be white).

TerramanLibrarySimple

The simplest library, just assign a material with a texture, and using the atlas_rows and atlas_culomns properties to tell the system how the UVs should be divided.

TerramanLibraryMerger

You will only have this if your godot also contains https://github.com/Relintai/texture_packer

You can assign any texture to your surfaces with this, and it will merge them together.

Worlds

The 2 base classes:

TerraWorld: Basic world, does not do anything until you implemnent the required virtual methods!
TerraWorldDefault: This adds threading, and LoD storage support to TerraWorld. Will not create meshes for you!

TerraWorldBlocky

The most basic world. It is the Minecraft-style world.

TerraWorldMarchingCubes

A marching cubes based Terra World. Actually it uses a modified version of the Transvoxel tables. It is UV mapped.

TerraWorldCubic

This is my own meshing algorithm, it's basicly a Minecraft style mesher that can take isolevel into account.

Level generation

Assign a TerraManLevelGenerator to the World's Level Generator property.

You can write your own algorithm by implementing the void _generate_chunk(chunk: TerraChunk) virtual method.

TerraManLevelGeneratorFlat is also available, it will generate a floor for you, if you use it.

TerraJobs

Producing just a terrarin mesh for a chunk is not that hard by itself. However when you start adding layers/features like lod generation, collision meshes (especially since manipulating the physics server is not threadsafe), vertex volumetric lights, props, snapping props, props with vertex lights, etc chunk mesh generation can quicly become a serious mess.

TerraJobs are meant to solve the issue with this complexity.

They also provide a way to easily modularize mesh generation.

TerraJob

Base class for jobs.

If the (thread pool)[https://github.com/Relintai/thread_pool] module is present, this is inherited from ThreadPoolJob, else it implements the same api as ThreadPoolJob, but it's not going to use threading.

A job has a reference to it's owner chunk.

If you implement your own jobs, when your job finishes call next_job().

TerraLightJob

This is the job that will generate vertex light based ao, random ao, and will bake your TerraLights.

TerraTerrarinJob

This will generate your terrarin collider and mesh (with lods) for you, using the meshers that you add into it.

TerraPropJob

This will generate your prop meshes (with lods).

Internal workings

TerraWorld

Whenever you want to spawn a chunk your World will create it using the TerraChunk _create_chunk(x: int, y: int, z: int, chunk: TerraChunk) virtual method.

Since properly initializing a chunk usually takes quite a few steps that you probably don't want to repeat everywhere the chunk parameter was added. This means you can just call the super _create_chunk methods, and you won't need to worry about your chunk getting overridden. Like:

Note that _create_chunk is also responsible for initializing chunks if you have them stored inside a scene. This is done by setup_chunk(shunk) in TerraWorld.

    func _create_chunk(x : int, y : int, z : int, chunk : TerraChunk) -> TerraChunk:
        if !chunk:
            chunk = MyChunk.new()

        # We need to check whether or not we need to initialize jobs
        if chunk.job_get_count() == 0:
            # Setup a blocky (minecratf like) mesher job
            var tj : TerraTerrarinJob = TerraTerrarinJob.new()

            tj.add_mesher(TerraMesherBlocky.new())
            tj.add_liquid_mesher(TerraMesherLiquidBlocky.new())

            chunk.job_add(tj);

        #setup your chunk here

        return ._create_chunk(x, y, z, chunk)

TerraChunk

Stores terrarin data, prop data. And mesh data (TerraChunkDefault), and the mesh generation jobs.

When it starts building meshes it will start submitting jobs to thread_pool (if present) one by one.

TerraMesher

If you want to implement your own meshing algorithm you can do so by overriding void _add_chunk(chunk: TerraChunk) virtual.

TerraMesher works similarly to SurfaceTool, so first you need to set colors, uvs, etc and then call add_vertex. They won't get reset, so for exaple if you want all your vertices to have a certain color, you can get away with setting it only once.

Compiling

First make sure that you can compile godot. See the official docs: https://docs.godotengine.org/en/3.2/development/compiling/index.html

  1. Clone the engine if you haven't already:

If you want Godot 3.2: git clone -b 3.2 https://github.com/godotengine/godot.git godot

If you want Godot 4.0: git clone https://github.com/godotengine/godot.git godot

  1. go into the modules folder inside the engine's directory:

cd godot
cd modules

  1. clone this repository

git clone https://github.com/Relintai/voxelman.git voxelman

(the folder needs to be named voxelman!)

  1. If you want the optional dependencies run these commands aswell:

git clone https://github.com/Relintai/texture_packer.git texture_packer
git clone https://github.com/Relintai/mesh_data_resource.git mesh_data_resource

  1. Go up one folder

cd ..

  1. Compile godot.

For example:

scons p=x11 t=release_debug tools=yes