baseline: working salvaged prototype on Godot 4.7.1 (pre-F1)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
7f0f43b5fb
48 changed files with 2913 additions and 0 deletions
19
Client/README.md
Normal file
19
Client/README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Client Module - IslaApocalypse
|
||||
|
||||
**Phase 2 Status:** Active (Mesh Rendering & Vertex Painting Online)
|
||||
|
||||
## Overview
|
||||
The `Client` directory handles the visual representation of the 3D Voxel Engine. It is strictly responsible for receiving pre-calculated mathematical data from the `Server` and `Core` modules and translating it into Godot-native visual nodes (`MeshInstance3D`). It does not calculate collisions, densities, or terrain generation.
|
||||
|
||||
## Key Architecture & Components
|
||||
|
||||
### 1. The Visualizer (`ChunkRenderer.cs`)
|
||||
A script attached to a `MeshInstance3D` node that physically draws a single 32x32 chunk of the world.
|
||||
* **Mesh Generation:** Calls `MarchingCubes.GenerateMesh()` from the `Core` module, passing in the `Densities` and `BlockIDs` scalar fields.
|
||||
* **Vertex Painting:** Dynamically creates a `StandardMaterial3D` and enables `VertexColorUseAsAlbedo = true`. This tells Godot to ignore standard texture maps and instead color the mesh using the exact RGB values we assigned to the vertices based on their `BlockID` (e.g., Green for Grass, Brown for Wasteland).
|
||||
* **World Positioning:** Multiplies the `ChunkPosition` (e.g., [1, 0]) by `Constants.CHUNK_SIZE` and `Constants.VOXEL_SCALE` (1.0f) to perfectly align the chunk in the global 3D space.
|
||||
* **Backface Rendering:** `CullMode` is explicitly disabled to ensure players don't see through the bottom of the map if they clip inside a mountain.
|
||||
|
||||
## Next Immediate Steps (Phase 2, Step 4)
|
||||
* Currently, the renderer draws the exact topography. Once the `Server` implements **Road Carving**, the `Client` will automatically inherit those flattened vertices and paint them with the `ASPHALT` vertex color without needing any code changes here.
|
||||
* Future implementations will include reading `BlockIDs` to paint different UV maps/textures instead of just raw RGB vertex colors.
|
||||
31
Client/Scripts/ChunkRenderer.cs
Normal file
31
Client/Scripts/ChunkRenderer.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Godot;
|
||||
using IslaApocalypse.Core;
|
||||
|
||||
namespace IslaApocalypse.Client
|
||||
{
|
||||
// Notice this inherits from MeshInstance3D, which is Godot's visual 3D node!
|
||||
public partial class ChunkRenderer : MeshInstance3D
|
||||
{
|
||||
public void RenderChunk(ChunkData data)
|
||||
{
|
||||
// 1. Pass the BlockIDs array to the generator!
|
||||
Mesh = MarchingCubes.GenerateMesh(data.Densities, data.BlockIDs, Constants.ISO_LEVEL, Constants.VOXEL_SCALE);
|
||||
|
||||
|
||||
StandardMaterial3D mat = new StandardMaterial3D();
|
||||
|
||||
// 2. THE FIX: Tell the material to use the colors we paint on the vertices!
|
||||
mat.VertexColorUseAsAlbedo = true;
|
||||
mat.Roughness = 0.8f;
|
||||
mat.CullMode = BaseMaterial3D.CullModeEnum.Disabled;
|
||||
|
||||
MaterialOverride = mat;
|
||||
|
||||
Position = new Vector3(
|
||||
data.ChunkPosition.X * Constants.CHUNK_SIZE_X * Constants.VOXEL_SCALE,
|
||||
0,
|
||||
data.ChunkPosition.Y * Constants.CHUNK_SIZE_Z * Constants.VOXEL_SCALE
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Client/Scripts/ChunkRenderer.cs.uid
Normal file
1
Client/Scripts/ChunkRenderer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://8que4lnxlubg
|
||||
Loading…
Add table
Add a link
Reference in a new issue