Compare commits

...

11 Commits

Author SHA1 Message Date
bb1981c5f6 Why. 2026-01-17 10:03:46 -05:00
d6fe969ce8 More things. So many things. 2026-01-03 11:05:21 -05:00
010bde50f5 Update README.md 2025-12-20 16:00:51 +00:00
0b444ef812 Added image. 2025-12-20 10:59:48 -05:00
c9e1eda4d3 Colors. Lines. 2025-12-20 10:58:38 -05:00
3bf2a7b429 Added bounds checking for triangles. 2025-12-20 10:33:12 -05:00
cffc64f3e9 Added geom. 2025-12-20 09:10:07 -05:00
903820d635 New geometry data structures. 2025-12-13 11:13:20 -05:00
4d372ff3d1 Plate generation. 2025-12-06 19:44:27 -05:00
d52e19740e Basic rendering of asthenosphere and lithosphere. 2025-12-06 11:47:35 -05:00
d412349d9b Return to 2D. 2025-12-06 00:56:30 -05:00
20 changed files with 402 additions and 427 deletions

View File

@@ -1,5 +1,7 @@
# Terrin
![](terrin.png)
Geologically-based terrain generator.
v1.0 goals:

140
src/gen.c
View File

@@ -1,28 +1,134 @@
#include "include/gen.h"
#include "include/col.h"
#include "include/vol.h"
#include "include/geom.h"
#include <stdio.h>
#include <raylib.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
void gen(void) {
srand((unsigned int)time(NULL));
Vec2 asth[WORLD_SZ][WORLD_SZ];
for (int x = 0; x < VOL_WIDTH; x++) {
for (int y = 0; y < VOL_HEIGHT; y++) {
for (int z = 0; z < VOL_DEPTH; z++) {
int r = rand() % 4;
switch (r) {
case 0: vol_set_pt(x, y, z, COL_WHT); break;
case 1: vol_set_pt(x, y, z, COL_GRY); break;
case 2: vol_set_pt(x, y, z, COL_GRN); break;
case 3: vol_set_pt(x, y, z, COL_BLU); break;
default: vol_set_pt(x, y, z, COL_MAG);
}
Plate lith[NPLATES];
// Find the point for an index to the edge of the world.
Pt world_edge_idx_to_pt(int idx) {
if (0 <= idx && idx < WORLD_SZ) {
return (Pt){idx, 0};
} else if (WORLD_SZ <= idx && idx < 2 * WORLD_SZ) {
return (Pt){WORLD_SZ - 1, idx - WORLD_SZ};
} else if (2 * WORLD_SZ <= idx && idx < 3 * WORLD_SZ) {
return (Pt){idx - 2 * WORLD_SZ, 0};
} else if (3 * WORLD_SZ <= idx && idx < 4 * WORLD_SZ) {
return (Pt){WORLD_SZ - 1, idx - 3 * WORLD_SZ};
} else {
exit(122);
}
}
void gen_asth() {
srand(time(NULL));
for (int i = 0; i < WORLD_SZ; i++) {
for (int j = 0; j < WORLD_SZ; j++) {
asth[i][j] = (Vec2){rand() % 7 - 3, rand() % 7 - 3};
}
}
}
size_t* min_idx(int* a, size_t n, size_t* out_n) {
if (!a || n == 0) return NULL;
int min_val = a[0];
for (size_t i = 1; i < n; i++) {
if (a[i] < min_val) min_val = a[i];
}
size_t o = 0;
for (size_t i = 0; i < n; i++) {
if (a[i] == min_val) o++;
}
size_t* idxs = malloc(o * sizeof(size_t));
if (!idxs) {
*out_n = 0;
return NULL;
}
size_t k = 0;
for (size_t i = 0; i < n; i++) {
if (a[i] == min_val) idxs[k++] = i;
}
*out_n = o;
return idxs;
}
void gen_lith() {
srand(time(NULL));
Pt centers[NPLATES]; // The centers of each plate to be generated.
// Generate random plate centers.
for (int i = 0; i < NPLATES; i++) {
Pt p = (Pt){rand() % WORLD_SZ, rand() % WORLD_SZ};
centers[i] = p;
}
Pt* plareas[NPLATES];
int plareas_count[NPLATES];
for (int i = 0; i < NPLATES; i++) {
plareas[i] = (Pt*)malloc(
WORLD_SZ * WORLD_SZ * sizeof(Pt)
); // Points in the plate area.
plareas_count[i] = 0; // Number of points added to the plate area.
}
for (int y = 0; y < WORLD_SZ; y++) {
for (int x = 0; x < WORLD_SZ; x++) {
Pt pt = (Pt){x, y};
int distances[NPLATES]; // Distances from each plate to the current
// point.
for (int i = 0; i < NPLATES; i++) {
distances[i] = pt_cmp(&pt, &centers[i]);
}
size_t n;
size_t* idxs = min_idx(
distances, NPLATES, &n
); // The index(es) of the closest plate(s) in the centers array.
for (int i = 0; i < n; i++) {
plareas[idxs[i]][plareas_count[idxs[i]]++] = pt;
}
}
}
printf("Volume initialized.\n");
Pt* plhulls[NPLATES]; // The convex hulls of each plate.
size_t plhulls_count[NPLATES]; // The number of points in each hull.
for (int i = 0; i < NPLATES; i++) { // Generate convex hulls.
size_t count;
plhulls[i] = cvx_hull(plareas[i], plareas_count[i], &count);
plhulls_count[i] = count;
}
Plate pls[NPLATES]; // The plates.
for (int i = 0; i < NPLATES;
i++) { // Generate plate triangle lists from convex hulls.
Tri* tris = malloc(plhulls_count[i] / 3 + 2);
tris[0] = (Tri){plhulls[i][0], plhulls[i][1], plhulls[i][2]};
for (int j = 2; j < plhulls_count[i] - 2; j++) {
tris[j] =
(Tri){plhulls[i][0], plhulls[i][j + 1], plhulls[i][j + 2]};
}
pls[i] = (Plate){.ntris = 1,
.tris = tris,
.col = ColorFromHSV(((float)rand()) / 100, 1, 1)};
}
lith[0] = pls[0];
lith[1] = pls[1];
}

94
src/geom.c Normal file
View File

@@ -0,0 +1,94 @@
#include "include/geom.h"
#include <stdio.h>
#include <stdlib.h>
Tri* alltris[512];
size_t allsize = 0;
Tri* tri_init(Pt a, Pt b, Pt c) {
Tri* tri = malloc(sizeof(Tri));
*(alltris + allsize) = tri;
allsize++;
*tri = (Tri){a, b, c};
return tri;
}
bool tri_within(Pt pt, Tri* tri) {
double denom =
((tri->b.y - tri->c.y) * (tri->a.x - tri->c.x) +
(tri->c.x - tri->b.x) * (tri->a.y - tri->c.y));
double a = ((tri->b.y - tri->c.y) * (pt.x - tri->c.x) +
(tri->c.x - tri->b.x) * (pt.y - tri->c.y)) /
denom;
double b = ((tri->c.y - tri->a.y) * (pt.x - tri->c.x) +
(tri->a.x - tri->c.x) * (pt.y - tri->c.y)) /
denom;
double c = 1 - a - b;
return 0 <= a && a <= 1 && 0 <= b && b <= 1 && 0 <= c && c <= 1;
}
Pt tri_center(Tri* tri) {
return (Pt){(tri->a.x + tri->b.x + tri->c.x) / 3.0,
(tri->a.y + tri->b.y + tri->c.y) / 3.0};
}
int pt_cmp(const void* a, const void* b) {
const Pt* p = (const Pt*)a;
const Pt* q = (const Pt*)b;
if (p->x != q->x) return p->x - q->x;
return p->y - q->y;
}
static int pt_cross(const Pt a, const Pt b, const Pt c) {
return ((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x));
}
Pt* cvx_hull(Pt* area, size_t n, size_t* out_n) {
if (!area || n <= 0) return NULL;
if (n == 1) {
Pt* out = malloc(2 * sizeof(Pt));
if (n == 1) out[0] = area[0];
*out_n = 1;
printf("bad things are happening... %s\n", __FUNCTION__);
return out;
}
Pt* pts = malloc(n * sizeof(Pt));
for (size_t i = 0; i < n; i++) pts[i] = area[i];
// Sort the points.
qsort(pts, n, sizeof(Pt), pt_cmp);
// Max hull size is 2 * n.
Pt* hull = malloc(2 * n * sizeof(Pt));
size_t k = 0;
// Lower hull.
for (size_t i = 0; i < n; i++) {
while (k >= 2 && pt_cross(hull[k - 2], hull[k - 1], pts[i]) <= 0) k--;
hull[k++] = pts[i];
}
// Upper hull.
for (size_t i = n - 1, t = k + 1; i > 0; i--) {
while (k >= t && pt_cross(hull[k - 2], hull[k - 1], pts[i - 1]) <= 0)
k--;
hull[k++] = pts[i - 1];
}
// Remove duplicated end/start point.
k--;
Pt* out = malloc(k * sizeof(Pt));
for (size_t i = 0; i < k; i++) { out[i] = hull[i]; }
*out_n = k;
free(pts);
free(hull);
return out;
}

View File

@@ -5,15 +5,15 @@
// An RGB color.
typedef struct {
uint8_t r, g, b;
uint8_t r, g, b, a;
} Col;
#define COL_WHT (Col) {255, 255, 255}
#define COL_GRY (Col) {127, 127, 127}
#define COL_BLK (Col) {0, 0, 0}
#define COL_RED (Col) {255, 0, 0}
#define COL_GRN (Col) {0, 255, 0}
#define COL_BLU (Col) {0, 0, 255}
#define COL_MAG (Col) {255, 127, 255}
#define COL_WHT (Col) {255, 255, 255, 255}
#define COL_GRY (Col) {127, 127, 127, 255}
#define COL_BLK (Col) {0, 0, 0, 255}
#define COL_RED (Col) {255, 0, 0, 255}
#define COL_GRN (Col) {0, 255, 0, 255}
#define COL_BLU (Col) {0, 0, 255, 255}
#define COL_MAG (Col) {255, 127, 255, 255}
#endif

View File

@@ -1,6 +1,23 @@
#ifndef GEN_H
#define GEN_H
void gen(void);
#include "geom.h"
#include <stdint.h>
#define WORLD_SZ 12
#define NPLATES 2
// The asthenosphere; contains a grid of force vectors.
extern Vec2 asth[WORLD_SZ][WORLD_SZ];
// The lithosphere; contians a list of plates.
extern Plate lith[NPLATES];
// Generate the motion vectors of the asthenosphere.
void gen_asth(void);
// Generate the plates of the lithosphere.
void gen_lith(void);
#endif

57
src/include/geom.h Normal file
View File

@@ -0,0 +1,57 @@
#ifndef GEOM_H
#define GEOM_H
#include <raylib.h>
#include <stdbool.h>
#include <stdlib.h>
// The maximum number of Tris in a Plate.
#define NTRI 4
// A two dimensional vector.
typedef struct {
int x;
int y;
} Vec2;
typedef struct {
int x, y;
} Pt;
typedef struct {
Pt* a;
Pt* b;
} Edge;
typedef struct {
Pt a;
Pt b;
Pt c;
} Tri;
extern Tri* alltris[512];
extern size_t allsize;
Tri* tri_init(Pt a, Pt b, Pt c);
void tri_destroy(Tri* tri);
// Check if a point is within the triangle. Uses barycentric coordinate system.
bool tri_within(Pt pt, Tri* tri);
// Get the center point of a Tri.
Pt tri_center(Tri* tri);
// Compare two points.
int pt_cmp(const void* a, const void* b);
// Get the convex hull around the area. Given the points in the area and their
// number.
Pt* cvx_hull(Pt* area, size_t n, size_t* out_n);
typedef struct {
Color col;
size_t ntris;
Tri* tris;
} Plate;
#endif

View File

@@ -1,21 +0,0 @@
#ifndef MC_H
#define MC_H
// Marching cubes.
#include "col.h"
#include <stdint.h>
#include <raylib.h>
// A cube configuration to be marched upon.
typedef Col Cube[8];
extern Mesh mesh;
// Calculate the index in the lookup table for a `Cube`.
int mc_cubeidx(Cube* c);
// Convert volume to mesh.
void mc_march(int idx);
#endif

View File

@@ -1,267 +0,0 @@
#ifndef MC_TRI_H
#define MC_TRI_H
#define MC_TRI_EDGES 16
// Lookup table for triangle positions. From
// [https://paulbourke.net/geometry/polygonise].
int mc_tri[256][16] = {
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
#endif

View File

@@ -1,6 +0,0 @@
#ifndef MESH_H
#define MESH_H
#endif

View File

@@ -1,13 +0,0 @@
#ifndef PT_H
#define PT_H
#include "col.h"
#include <stdint.h>
// A point.
typedef struct {
Col col;
} Pt;
#endif

View File

@@ -1,8 +1,11 @@
#ifndef RENDER_H
#define RENDER_H
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 600
#include "gen.h"
#define SCREEN_WIDTH (100 * WORLD_SZ)
#define SCREEN_HEIGHT (100 * WORLD_SZ)
#define CELL_SZ (SCREEN_WIDTH / WORLD_SZ)
void render(void);

8
src/include/tect.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef TECT_H
#define TECT_H
#include "gen.h"
Vec2* tect_asth_vals(Plate p);
#endif

9
src/include/util.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef UTIL_H
#define UTIL_H
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MAX3(a, b, c) (MAX((a), MAX((b), (c))))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MIN3(a, b, c) (MIN((a), MIN((b), (c))))
#endif

View File

@@ -1,17 +0,0 @@
#ifndef VOL_H
#define VOL_H
#include "pt.h"
#include "col.h"
#define VOL_SZ 8
#define VOL_WIDTH VOL_SZ
#define VOL_HEIGHT VOL_SZ
#define VOL_DEPTH VOL_SZ
// The volume in which our points may be found.
extern Pt volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
void vol_set_pt(int x, int y, int z, Col col);
#endif

View File

@@ -1,16 +1,28 @@
#include "include/main.h"
#include "include/gen.h"
#include "include/geom.h"
#include "include/render.h"
#include <raylib.h>
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello, world.\n");
gen_asth();
gen_lith();
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Terrin");
SetTargetFPS(110);
gen();
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(BLACK);
render();
render();
EndDrawing();
}
CloseWindow();
return 0;
}

View File

@@ -1,20 +0,0 @@
#include "include/mc.h"
#include "include/mc_tri.h"
Mesh mesh;
int mc_cubeidx(Cube* c) {
int index = 0;
for (int i = 0; i < 8; i++) {
if ((*c)[i].r) { index |= 1 << i; }
}
return index;
}
// TODO.
void mc_march(int idx) {
int* tri = mc_tri[idx];
for (int i = 0; i < 16; i++) {}
}

View File

@@ -1,51 +1,65 @@
#include "include/render.h"
#include "include/vol.h"
#include "include/gen.h"
#include "include/geom.h"
#include "include/util.h"
#include <raylib.h>
void render(void) {
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Terrin");
Vector2 PointToVector2(Pt p) {
Vector2 v;
v.x = (float)(p.x * 100) + 50.;
v.y = (float)(p.y * 100) + 50.;
return v;
}
Camera3D cam = {0};
cam.position =
(Vector3){VOL_WIDTH / 2.f, VOL_HEIGHT * .75f, VOL_DEPTH / 2.f};
cam.target = (Vector3){0, 0, 0};
cam.up = (Vector3){0.0f, 1.0f, 0.0f};
cam.fovy = 70.f;
cam.projection = CAMERA_PERSPECTIVE;
Vector2 PointpToVector2(Pt* p) {
Vector2 v;
v.x = (float)(p->x * 100) + 50;
v.y = (float)(p->y * 100) + 50;
return v;
}
SetTargetFPS(110);
void draw_tri(Tri* tri) {
DrawTriangleLines(
PointToVector2(tri->a), PointToVector2(tri->b), PointToVector2(tri->c),
RED
);
}
while (!WindowShouldClose()) {
UpdateCamera(&cam, CAMERA_FREE);
BeginDrawing();
ClearBackground((Color){0, 0, 0, 0});
BeginMode3D(cam);
for (int x = 0; x < VOL_WIDTH; x++) {
for (int y = 0; y < VOL_HEIGHT; y++) {
for (int z = 0; z < VOL_DEPTH; z++) {
Pt v = volume[x][y][z];
DrawSphere(
(Vector3){(float)x, (float)y, (float)z}, 0.2f,
(Color){v.col.r, v.col.g, v.col.b, 255}
);
}
void draw_tri_inside(Tri* tri, Color col) {
int maxx = MAX3(tri->a.x, tri->b.x, tri->c.x);
int maxy = MAX3(tri->a.y, tri->b.y, tri->c.y);
int minx = MIN3(tri->a.x, tri->b.x, tri->c.x);
int miny = MIN3(tri->a.y, tri->b.y, tri->c.y);
for (int x = minx; x <= maxx; x++) {
for (int y = miny; y <= maxy; y++) {
if (tri_within((Pt){x, y}, tri)) {
// DrawCircleV(PointToVector2((Pt){x, y}), 4.f, col);
DrawLineV(
PointToVector2((Pt){x, y}), PointToVector2(tri_center(tri)),
col
);
}
}
EndMode3D();
DrawFPS(10, 10);
EndDrawing();
}
CloseWindow();
}
void render() {
for (int x = 0; x < WORLD_SZ; x++) {
for (int y = 0; y < WORLD_SZ; y++) {
Vector2 v = PointToVector2((Pt){x, y});
DrawCircleV(v, 4.f, WHITE);
DrawLineV(
v,
(Vector2){v.x + asth[x][y].x * WORLD_SZ,
v.y + asth[x][y].y * WORLD_SZ},
WHITE
);
}
}
for (int i = 0; i < NPLATES; i++) {
Plate plate = lith[i];
draw_tri(plate.tris);
draw_tri_inside(plate.tris, plate.col);
}
}

9
src/tect.c Normal file
View File

@@ -0,0 +1,9 @@
#include "include/tect.h"
#include "include/gen.h"
#include "include/geom.h"
Vec2* tect_asth_vals(Plate p) {
Vec2* buf = malloc(WORLD_SZ * WORLD_SZ);
for (int i = 0; i < p.ntris; i++) {}
return buf;
}

View File

@@ -1,12 +0,0 @@
#include "include/vol.h"
#include <stdlib.h>
Pt volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
void vol_set_pt(int x, int y, int z, Col col) {
if (x >= 0 && x < VOL_WIDTH && y >= 0 && y < VOL_HEIGHT && z >= 0 &&
z < VOL_DEPTH)
volume[x][y][z].col = col;
else exit(1);
}

BIN
terrin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB