Skip to content

Commit 49f6574

Browse files
committed
Setup Noise Function
1 parent 6919764 commit 49f6574

File tree

12 files changed

+123
-65
lines changed

12 files changed

+123
-65
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ compile_commands.json
5252
# VSCode
5353
.vscode/*
5454
!.vscode/extensions.json
55+
!.vscode/c_cpp_properties.json
5556
.DS_Store
5657

5758
# Jetbrains
5859
.idea/
60+
61+
#Assets
62+
/demo/TerrainTiles/*
2.31 KB
Binary file not shown.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ Godot Terrain Generator for 3D Tiled Maps
44

55
Godot 4.4 is currently used Version
66

7+
# Overview
8+
9+
1. Pre-Computed Tile Set's
10+
1. Each tile is an index id
11+
1. This is because we use a bitset to store the valid neighbors of a tile
12+
1. 0 is reserved for empty tiles
13+
1. Give the Terrain Generator a set of tiles by index with pre-computed adjacencies for each of the size sides
14+
1. Weights can also be supplied to factor in more successful tiles
15+
1. Pre-Defined Chunk Injection
16+
1. Give the Terrain Generator a set of pre-defined tile chunks, grid sections, chunks per section
17+
1. Take in a set of Relative Coordinate Chunks
18+
1. Take in Grid Sections
19+
1. Take in Chunks per Grid Section
20+
1. Randomly place chunks into each section
21+
1. Height Manipulation
22+
1. Using [Simplex-Fractal-Noise](https://github.com/SRombauts/SimplexNoise?tab=readme-ov-file#readme)
23+
1. Height limitations are applied when collapsing the Wave Function
24+
1. Collapse the Wave
25+
1. Using Wave Function Collapse determine a final grid with Tiles
26+
1. Output a final 3 dimensional array with a tile index at each location
27+
1. Use the generated 3d grid to generate a visual representation by iterating through the 3d array and instantiating the tiles in the game world
28+
29+
# Setup
30+
31+
## Windows
32+
33+
1. Setup a C++ Environment
34+
1. Possible Setup for VS Code : https://code.visualstudio.com/docs/cpp/config-mingw
35+
36+
Ensure that C++ can run :
37+
38+
```bash
39+
gcc --version
40+
g++ --version
41+
gdb --version
42+
```
43+
44+
# Godot
45+
746
## Godot GDExtension
847

948
[This repository uses the Godot quickstart template for GDExtension development with Godot 4.0+.](https://github.com/godotengine/godot-cpp-template)

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs})
4040

4141
env.Append(CPPPATH=["src/"])
4242
# TODO Add Nested Folders as a new Glob
43-
sources = [Glob("src/*.cpp"), Glob("src/Example/*.cpp")]
43+
sources = [Glob("src/*.cpp"), Glob("src/TerrainGen/*.cpp")]
4444

4545
if env["target"] in ["editor", "template_debug"]:
4646
try:

demo/TerrainTiles

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:/Users/River/OneDrive/Aveyrin/Game/SkyRoseGame/assets/Environment/TerrainTiles

demo/Test.tscn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
[gd_scene load_steps=2 format=3 uid="uid://cs6xj3i70yh0f"]
1+
[gd_scene load_steps=3 format=3 uid="uid://cs6xj3i70yh0f"]
22

33
[ext_resource type="Script" uid="uid://ba0phkf16vg6l" path="res://hello_world_gdextention_function.gd" id="1_myinc"]
4+
[ext_resource type="MeshLibrary" uid="uid://cwusqwtpjkoaa" path="res://TerrainTiles/3D_Terrain_Tiles.tres" id="2_njov2"]
45

56
[node name="Test" type="Node3D"]
67

78
[node name="HelloWorld" type="HelloWorld" parent="."]
89
script = ExtResource("1_myinc")
10+
11+
[node name="GridMap" type="GridMap" parent="."]
12+
mesh_library = ExtResource("2_njov2")
13+
cell_size = Vector3(1, 0.25, 1)
14+
data = {
15+
"cells": PackedInt32Array(65535, 2, 1, 65535, 3, 0, 0, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1, 2, 0, 3, 1048577, 2, 0, 1441796, 3, 1, 1441794, 3, 0, 1441794, 1, 0, 1441794, 3, 2, 655362, 65540, 2, 1, 65540, 3, 1, 65540, 65535, 1, 65541, 65535, 2, 65541, 0, 2, 65541, 1, 2, 65541, 2, 2, 65541, 3, 2, 65540, 1, 5, 65540, 0, 5, 3, 3, 2, 2, 3, 2, 1, 3, 2, 3, 65535, 2, 3, 4, 2, 65540, 4, 0, 65541, 4, 1048577, 65542, 4, 1048577, 65543, 4, 1048577, 65544, 4, 1048577, 2, 4, 1048578, 2, 5, 1048578, 3, 5, 1048578, 4, 5, 1048578, 5, 5, 1048578, 6, 5, 1048578, 7, 5, 1048578, 8, 5, 1048578, 9, 5, 1048578, 65542, 65535, 1048578, 65542, 0, 1048578, 65542, 1, 1048578, 65542, 2, 1048578, 65542, 3, 1048578, 65543, 3, 1048578, 65544, 3, 1048578, 65544, 2, 1048578, 65544, 1, 1048578, 65544, 0, 1048578, 65544, 65535, 1048578, 65543, 65535, 1048578, 65543, 0, 1048578, 65543, 1, 1048578, 65543, 2, 1048578)
16+
}
17+
metadata/_editor_floor_ = Vector3(0, 1, 0)

demo/project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config_version=5
1111
[application]
1212

1313
config/name="Gaia Green"
14+
config/tags=PackedStringArray("gaia_green", "open_source", "template")
1415
run/main_scene="uid://cs6xj3i70yh0f"
1516
config/features=PackedStringArray("4.4", "Forward Plus")
1617
config/icon="uid://cxh6hwgj7obw2"
17-
config/tags=PackedStringArray("gaia_green", "open_source", "template")

src/Example/Hello_World.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Example/Hello_World.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/TerrainGen/Terrain_Gen.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "Terrain_Gen.h"
2+
3+
using namespace godot;
4+
5+
TerrainGen::TerrainGen() {
6+
noise.instantiate();
7+
noise->set_noise_type(FastNoiseLite::NoiseType::TYPE_SIMPLEX);
8+
noise->set_fractal_type(FastNoiseLite::FractalType::FRACTAL_FBM);
9+
noise->set_fractal_octaves(2); // Number of layers
10+
noise->set_fractal_lacunarity(2.0); // Frequency multiplier per octave
11+
noise->set_fractal_gain(0.5); // Amplitude multiplier per octave
12+
noise->set_frequency(0.01);
13+
}
14+
15+
TerrainGen::~TerrainGen() {
16+
}
17+
18+
float TerrainGen::get_noise_value(float x, float y) {
19+
return noise->get_noise_2d(x, y);
20+
}
21+
22+
void TerrainGen::generate() {
23+
UtilityFunctions::print("Begin Terrain Generation!");
24+
}
25+
26+
void TerrainGen::_bind_methods() {
27+
ClassDB::bind_method(D_METHOD("generate"), &TerrainGen::generate);
28+
}

0 commit comments

Comments
 (0)