Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2abd3f3
chore: plan outlining and save point for implementation
ViTeXFTW Feb 21, 2026
1a55851
chore: rebase onto latest dev
ViTeXFTW Feb 21, 2026
9f204f6
chore: import main branch of bigxtractor
ViTeXFTW Feb 21, 2026
5f9c169
feat: update foundation for terrain rendering feature
ViTeXFTW Feb 21, 2026
83627d8
feat: updated code to use memory allocator
ViTeXFTW Feb 21, 2026
31e0eb6
ci: fix tests failing because of vulkan dependencies
ViTeXFTW Feb 21, 2026
a0da191
chore: adress review comment regarding unused fields
ViTeXFTW Feb 21, 2026
954fc53
perf: implemented dynamic buffer using vma
ViTeXFTW Feb 21, 2026
e518154
feat: mipmap levels for tga textures in preperation of terrain rendering
ViTeXFTW Feb 21, 2026
629a65f
feat: texture array support for terrain rendering
ViTeXFTW Feb 21, 2026
42c269b
refactor: update pipeline in preperation to terrain rendering
ViTeXFTW Feb 21, 2026
1574bdf
feat: new camera type for RTS feel
ViTeXFTW Feb 21, 2026
878718b
feat: add initial map reading structure
ViTeXFTW Feb 21, 2026
b535e3e
feat: heightmap parsing logic
ViTeXFTW Feb 22, 2026
1497992
feat: blend tile parsing and added to heightmap data
ViTeXFTW Feb 22, 2026
bbbc61d
feat: objectlist parser implementation with tests
ViTeXFTW Feb 22, 2026
06f0cab
feat: trigger parser implementation with tests
ViTeXFTW Feb 22, 2026
5ee4b61
feat: global ligtning parser
ViTeXFTW Feb 22, 2026
55cde4b
feat: worldinfo parser and sidelists parser
ViTeXFTW Feb 22, 2026
82d9698
feat: map loader and parser with tests
ViTeXFTW Feb 22, 2026
115b171
feat: added ini parser with focus on terrain rendering
ViTeXFTW Feb 22, 2026
94baa9a
chore: update claude plan
ViTeXFTW Feb 22, 2026
16d81b1
feat: terrain rendering implementation - missing 3.2 and 3.8
ViTeXFTW Feb 23, 2026
1d52596
feat: complete terrain rendering phase 3 (atlas, blend, cliff UVs)
claude Feb 23, 2026
ba2c57e
refactor: Apply clang-format to PR files [skip ci]
github-actions[bot] Feb 23, 2026
ecd019f
feat: implement Phase 4 water rendering (mesh generation, shaders, pi…
claude Feb 23, 2026
806161d
refactor: Apply clang-format to PR files [skip ci]
github-actions[bot] Feb 23, 2026
aab1dc2
feat: implement Phase 5 scene graph and object placement
claude Feb 23, 2026
d741f30
refactor: Apply clang-format to PR files [skip ci]
github-actions[bot] Feb 23, 2026
7791b7b
Merge pull request #93 from ViTeXFTW/claude/terrain-rendering-phase-3…
ViTeXFTW Feb 23, 2026
6d91e7a
feat: add water surface rendering with mesh generation and shaders (#…
ViTeXFTW Feb 23, 2026
f20af65
fix: address Greptile review - quadtree depth tracking bug and should…
claude Feb 23, 2026
4390c87
Merge pull request #96 from ViTeXFTW/claude/phase-5-scene-graph-BUg31
ViTeXFTW Feb 23, 2026
f6bc03f
feat: implement Phase 6 lighting & polish (6.1–6.4)
claude Feb 23, 2026
02d8047
refactor: Apply clang-format to PR files [skip ci]
github-actions[bot] Feb 23, 2026
291c939
chore: address review comments
ViTeXFTW Feb 23, 2026
2a31996
Merge pull request #99 from ViTeXFTW/claude/phase-6-lighting-polish-V…
ViTeXFTW Feb 23, 2026
840bfa4
build: relax warnings for test builds
ViTeXFTW Feb 23, 2026
625d1f1
feat: map loader ui
ViTeXFTW Feb 26, 2026
5df4121
feat: decompression
ViTeXFTW Feb 26, 2026
2fd1026
fix: SideList parse errors
ViTeXFTW Feb 28, 2026
b3c1d25
fix: camera viewpoint and pan speed
ViTeXFTW Feb 28, 2026
b8c494a
chore: terrain rendering plan
ViTeXFTW Feb 28, 2026
718ad21
feat: texture loading from .big files
ViTeXFTW Feb 28, 2026
b77fec1
feat: tga extraction pipeline
ViTeXFTW Mar 1, 2026
57395b5
feat: cell blend data
ViTeXFTW Mar 1, 2026
b439646
feat: terrain shaders
ViTeXFTW Mar 1, 2026
5ee5d09
feat: texture edge cases
ViTeXFTW Mar 1, 2026
ee7259d
fix: function destroying blend data
ViTeXFTW Mar 1, 2026
0e96300
fix: atlas test that was broken in ee7259d
ViTeXFTW Mar 2, 2026
ce323fa
fix: blend tiles not being calculated correctly
ViTeXFTW Mar 2, 2026
1e69441
fix: tests not passing and incorrect for diagonals
ViTeXFTW Mar 13, 2026
905bc7c
fix: tests again
ViTeXFTW Mar 13, 2026
bde8f48
build: removed compiler specific configurations and moved to user pre…
ViTeXFTW Mar 23, 2026
cdc38b9
fix: increased max zoom of terrain rendering
ViTeXFTW Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.compiler }} cmake ninja-build
sudo apt-get install -y ${{ matrix.compiler }} cmake ninja-build \
libwayland-dev libxkbcommon-dev xorg-dev

- name: Configure CMake (Linux)
if: runner.os == 'Linux'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ logs/

# CMake generated
CMakeCache.txt
CMakeUserPresets.json
CMakeFiles/
cmake_install.cmake
compile_commands.json
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "lib/BigXtractor"]
path = lib/BigXtractor
url = https://github.com/ViTeXFTW/BigXtractor.git
[submodule "lib/VulkanMemoryAllocator"]
path = lib/VulkanMemoryAllocator
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
122 changes: 121 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AGENTS.md - VulkanW3DViewer

This file guides AI coding agents working on this Vulkan-based W3D renderer.
This file guides AI coding agents working on this Vulkan-based W3D renderer and map scene viewer for C&C Generals: Zero Hour.

## Build Commands

Expand Down Expand Up @@ -135,3 +135,123 @@ Example:
### Comments
- **No comments** in code unless specifically requested
- Exception: Critical file format notes in W3D parser headers

## Map File Format (.map)

Map files use the **DataChunk** binary format (distinct from W3D chunks). The framing is:

### DataChunk Container
- **Magic**: `CkMp` (bytes `0x43 0x6B 0x4D 0x70`)
- **TOC**: `int32 count`, then `count` entries of `{uint8 nameLen, char[nameLen] name, uint32 id}`
- **Chunk header**: `uint32 chunkID` (from TOC) + `uint16 version` + `int32 dataSize` = 10 bytes
- Chunks can be **nested** (parent `dataSize` includes child headers + payloads)
- Primitives: `readInt()` = LE int32, `readReal()` = LE float32, `readByte()` = int8, `readAsciiString()` = uint16 len + chars, `readDict()` = key-value pairs

### Top-Level Chunks (in file order)
| Chunk Name | Latest Version | Description |
|---|---|---|
| `"HeightMapData"` | 4 | Raw `uint8` heightmap grid (10.0 world units/cell, 0.625 height scale) |
| `"BlendTileData"` | 8 (ZH) | Tile textures, blend info, cliff UV overrides, passability |
| `"WorldInfo"` | 1 | World Dict (weather, etc.) |
| `"SidesList"` | 3 | Players, teams, build lists, nested `"PlayerScriptsList"` |
| `"ObjectsList"` | 3 | Nested `"Object"` sub-chunks: position, rotation, template name, property Dict |
| `"PolygonTriggers"` | 4 (ZH) | Water areas, rivers, trigger polygons |
| `"GlobalLighting"` | 3 | 4 time-of-day lighting sets (ambient/diffuse/direction, 3 lights each) |

### Key Constants
| Constant | Value | Usage |
|---|---|---|
| `MAP_XY_FACTOR` | `10.0f` | World units per heightmap cell |
| `MAP_HEIGHT_SCALE` | `0.625f` | `MAP_XY_FACTOR / 16.0` -- height byte to world units |
| `TILE_PIXEL_EXTENT` | `64` | Source tile bitmap size (64x64, BGRA) |
| `FLAG_VAL` | `0x7ADA0000` | Blend tile sentinel/validation marker |
| `INVERTED_MASK` | `0x1` | Blend tile `inverted` field bit 0 |
| `FLIPPED_MASK` | `0x2` | Blend tile `inverted` field bit 1 (triangle flip) |

### Terrain Texture Pipeline
1. `BlendTileData` texture class names (e.g., `"TEDesert1"`) resolve via INI `TerrainType` definitions
2. Each terrain type references a TGA in `Art/Terrain/` within `TerrainZH.big`
3. TGAs are split into 64x64 tiles, arranged into a 2048-wide runtime texture atlas
4. `tileNdxes[cell]`: top 14 bits = source tile index, bottom 2 bits = 32x32 quadrant
5. Blending uses 12 alpha gradient patterns (6 directions x inverted) for smooth terrain transitions
6. Cliff cells (`maxZ - minZ > 9.8`) use custom UV coordinates from `cliffInfo[]`

### Terrain Rendering Passes (original engine)
1. Base terrain texture from atlas
2. Alpha blend overlay (terrain transitions)
3. Extra blend (3-way texture blends)
4. Cloud shadow layer (scrolling animated texture)
5. Macro/noise texture
6. Shoreline alpha blending (water-terrain edge)
7. Scorch marks, roads, trees, props, bridges, shroud

### Water System
- Water surfaces defined by `PolygonTrigger` with `isWaterArea = true`
- Flat plane at polygon Z height, scrolling UV texture, semi-transparent
- Rivers use `isRiver = true` with `riverStart` vertex index for flow direction
- Settings from `Water.ini`: textures, transparency, scroll rates, sky textures
- Original had 4 types: translucent, FB reflection, PV shader, grid mesh (deformable)

## Project Architecture

### Library Extraction (Planned)
The project is being restructured into:
- **`w3d_lib`** -- static library (`src/lib/` + `src/render/`): all parsing, rendering, scene management
- **`VulkanW3DViewer`** -- thin executable (`src/main.cpp` + `src/core/` + `src/ui/`): application shell

### New Directory Structure (Terrain/Map)
```
src/lib/formats/map/ -- Map file parsing (DataChunk format)
data_chunk_reader.hpp/cpp -- DataChunk binary format reader
map_loader.hpp/cpp -- Top-level .map file loader
heightmap_parser.hpp/cpp -- HeightMapData chunk
blend_tile_parser.hpp/cpp -- BlendTileData chunk
objects_parser.hpp/cpp -- ObjectsList/Object chunks
triggers_parser.hpp/cpp -- PolygonTriggers chunk
lighting_parser.hpp/cpp -- GlobalLighting chunk
types.hpp -- MapFile, HeightMap, BlendTileData, MapObject, etc.

src/lib/formats/ini/ -- SAGE INI dialect parsing
ini_parser.hpp/cpp -- Block-based INI parser
terrain_types.hpp/cpp -- TerrainType definitions (name -> TGA)
water_settings.hpp/cpp -- Water rendering configuration

src/render/terrain/ -- Terrain rendering
terrain_mesh.hpp/cpp -- Heightmap -> triangle mesh (32x32 chunks)
terrain_atlas.hpp/cpp -- Texture atlas builder from tile TGAs
terrain_blend.hpp/cpp -- Alpha blend pattern generation
terrain_renderable.hpp/cpp -- IRenderable implementation for terrain

src/render/water/ -- Water rendering
water_mesh.hpp/cpp -- Polygon trigger -> water mesh
water_renderable.hpp/cpp -- IRenderable implementation for water

shaders/
terrain.vert/frag -- Terrain: base tile + blend + lighting
water.vert/frag -- Water: scrolling UV, transparency
```

### Key Infrastructure Requirements
- **VMA**: Vulkan Memory Allocator required for terrain (many small chunk buffers exceed per-device allocation limits)
- **Dynamic buffers**: Terrain mesh needs updateable vertex/index buffers (for future editing support)
- **Texture arrays**: Terrain splatmapping needs `VkImage` with `arrayLayers > 1`
- **Mipmaps**: Required for terrain textures at oblique viewing angles
- **RTS camera**: WASD pan, scroll zoom, Q/E rotation, ~60-degree pitch

## Reference Source Code

The `lib/GeneralsGameCode/` submodule contains the original SAGE engine source as reference:

| File | Contains |
|---|---|
| `Core/.../WorldHeightMap.h/cpp` | Heightmap data class + map file parser (2535 lines) |
| `Core/.../TileData.h/cpp` | Tile bitmap storage (64x64 px per tile) |
| `Core/.../BaseHeightMap.h` | Base terrain render object |
| `Core/.../HeightMap.h/cpp` | Full 3D heightmap renderer |
| `Core/.../TerrainTex.h/cpp` | Runtime texture atlas generation |
| `Core/.../W3DWater.h` + `Water/W3DWater.cpp` | Water rendering (291-line header) |
| `Generals/Code/.../DataChunk.h/cpp` | DataChunk reader/writer implementation |
| `GeneralsMD/Code/.../MapReaderWriterInfo.h` | All chunk version constants |
| `Core/.../MapObject.h` | MapObject struct, `MAP_XY_FACTOR`, `MAP_HEIGHT_SCALE` |
| `Generals/Code/.../PolygonTrigger.h/cpp` | Water area/river polygon parsing |
| `GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp` | Map file writer (saveToFile) |
107 changes: 89 additions & 18 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ ctest --preset test # Run tests

## Project Overview

This is a **W3D format renderer** - a modern Vulkan-based tool for loading and rendering W3D 3D model files from Command & Conquer Generals. The project uses C++20, GLFW for windowing, Vulkan-Hpp for C++ Vulkan bindings, and GLM for math.
This is a **W3D format renderer and map scene viewer** -- a modern Vulkan-based tool for loading and rendering W3D 3D model files and `.map` scene files from Command & Conquer Generals: Zero Hour. The goal is to produce a community rendering pipeline that can faithfully display terrain, water, placed objects, and lighting from the original game's map format, with the architecture designed to support future WorldBuilder-style editing.

**W3D Format:** Westwood 3D format (chunk-based) containing meshes, hierarchies, skeletal animations, and HLod (hierarchical LOD). Reference implementation is in `legacy/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/`.
The project uses C++20, GLFW for windowing, Vulkan-Hpp for C++ Vulkan bindings, and GLM for math.

**W3D Format:** Westwood 3D format (chunk-based) containing meshes, hierarchies, skeletal animations, and HLod (hierarchical LOD). Reference implementation is in `lib/GeneralsGameCode/`.

**Map Format:** DataChunk binary format (`.map` files) containing heightmap terrain, texture blending, placed objects, water areas, polygon triggers, and global lighting. Distinct from W3D chunks -- uses named chunks with a `CkMp` TOC header. See AGENTS.md for full format specification.

### Requirements

Expand All @@ -106,19 +110,36 @@ src/
shader_loader.hpp # Shader loading utilities
settings.hpp/cpp # Application settings
app_paths.hpp/cpp # Application path utilities
lib/ # Reusable library components
formats/w3d/ # W3D format parsing
w3d.hpp # W3D module main header
types.hpp # W3D data structures (Mesh, Hierarchy, Animation, etc.)
chunk_types.hpp # W3D chunk type enumerations
chunk_reader.hpp # Binary chunk parsing utilities
loader.hpp/cpp # W3D file loading interface
model_loader.hpp/cpp # High-level model interface
mesh_parser.hpp/cpp # Mesh chunk parsing
hierarchy_parser.hpp/cpp # Skeleton/bone parsing
animation_parser.hpp/cpp # Animation keyframe parsing
hlod_parser.hpp/cpp # Hierarchical LOD parsing
hlod_model.hpp/cpp # HLod model assembly with LOD switching
lib/ # Reusable library components (future w3d_lib static library)
formats/
w3d/ # W3D binary format parsing
w3d.hpp # W3D module main header
types.hpp # W3D data structures (Mesh, Hierarchy, Animation, etc.)
chunk_types.hpp # W3D chunk type enumerations
chunk_reader.hpp # Binary chunk parsing utilities
loader.hpp/cpp # W3D file loading interface
model_loader.hpp/cpp # High-level model interface
mesh_parser.hpp/cpp # Mesh chunk parsing
hierarchy_parser.hpp/cpp # Skeleton/bone parsing
animation_parser.hpp/cpp # Animation keyframe parsing
hlod_parser.hpp/cpp # Hierarchical LOD parsing
hlod_model.hpp/cpp # HLod model assembly with LOD switching
map/ # Map file parsing (DataChunk format) [PLANNED]
data_chunk_reader.hpp/cpp # DataChunk binary reader (CkMp TOC + named chunks)
map_loader.hpp/cpp # Top-level .map file loader
heightmap_parser.hpp/cpp # HeightMapData chunk (uint8 grid)
blend_tile_parser.hpp/cpp # BlendTileData chunk (textures, blending, cliffs)
objects_parser.hpp/cpp # ObjectsList/Object sub-chunks
triggers_parser.hpp/cpp # PolygonTriggers (water areas, rivers)
lighting_parser.hpp/cpp # GlobalLighting (4 time-of-day sets)
types.hpp # MapFile, HeightMap, BlendTileData, MapObject, etc.
big/ # BIG archive support
big_archive_manager.hpp/cpp # BIG file extraction
asset_registry.hpp/cpp # Asset name indexing
ini/ # SAGE INI dialect parsing [PLANNED]
ini_parser.hpp/cpp # Block-based INI parser
terrain_types.hpp/cpp # TerrainType definitions (name -> TGA)
water_settings.hpp/cpp # Water rendering configuration
gfx/ # Graphics foundation
vulkan_context.hpp/cpp # Device, swapchain, queues, depth buffer
buffer.hpp/cpp # GPU buffer management with staging
Expand All @@ -129,7 +150,7 @@ src/
renderable.hpp # Base renderable interface
scene/ # Scene management
scene.hpp/cpp # Scene container
render/ # Rendering utilities (viewer-specific)
render/ # Rendering utilities
animation_player.hpp/cpp # Animation playback control
bone_buffer.hpp/cpp # GPU buffer for bone transformations
hover_detector.hpp/cpp # Mesh picking via raycast
Expand All @@ -139,6 +160,14 @@ src/
renderable_mesh.hpp/cpp # GPU mesh representation
skeleton.hpp/cpp # Skeleton pose computation
skeleton_renderer.hpp/cpp # Skeleton debug visualization
terrain/ # Terrain rendering [PLANNED]
terrain_mesh.hpp/cpp # Heightmap -> triangle mesh (32x32 chunks)
terrain_atlas.hpp/cpp # Texture atlas builder from tile TGAs
terrain_blend.hpp/cpp # Alpha blend pattern generation
terrain_renderable.hpp/cpp # IRenderable for terrain
water/ # Water rendering [PLANNED]
water_mesh.hpp/cpp # Polygon trigger -> water mesh
water_renderable.hpp/cpp # IRenderable for water
ui/ # User interface
imgui_backend.hpp/cpp # ImGui Vulkan integration
ui_manager.hpp/cpp # UI component lifecycle management
Expand All @@ -147,6 +176,7 @@ src/
ui_panel.hpp # Panel base class
console_window.hpp/cpp # Debug console UI
file_browser.hpp/cpp # File browser for loading W3D files
model_browser.hpp/cpp # BIG archive model browser
viewport_window.hpp/cpp # 3D viewport
settings_window.hpp/cpp # Settings dialog
hover_tooltip.hpp/cpp # Tooltip display
Expand All @@ -161,10 +191,14 @@ shaders/
basic.vert/frag # Shader with texture and material support
skinned.vert # Skeletal animation vertex shader
skeleton.vert/frag # Skeleton visualization
terrain.vert/frag # Terrain: base tile + blend + lighting [PLANNED]
water.vert/frag # Water: scrolling UV, transparency [PLANNED]
```

## Implementation Phases

### W3D Model Viewer (Complete)

| Phase | Status | Description |
|-------|--------|-------------|
| 1 | Done | Vulkan foundation - device, swapchain, pipeline, cube rendering |
Expand All @@ -176,6 +210,21 @@ shaders/
| 7 | Done | Animations - load animation, and apply to bones |
| 8 | Done | Render animations onto meshes |

### Terrain & Map Scene Rendering (In Progress)

Goal: Load `.map` files and render complete C&C Generals: Zero Hour scenes (terrain, water, objects, lighting). Architecture designed for future WorldBuilder-style editing (mutable data structures from day one). Output is a `w3d_lib` static library + the viewer application consuming it.

| Phase | Status | Description |
|-------|--------|-------------|
| 0 | Done | Architecture refactoring -- extract `w3d_lib` static library, integrate VMA, add dynamic buffers, mipmap generation, texture arrays, pipeline refactor, RTS camera |
| 1 | Done | Map file parsing -- DataChunk reader, HeightMapData, BlendTileData, ObjectsList, PolygonTriggers, GlobalLighting, WorldInfo, SidesList |
| 2 | Done | INI parsing -- SAGE INI dialect parser, TerrainType definitions, Water settings |
| 3 | Pending | Terrain rendering -- heightmap mesh (32x32 chunks), texture atlas, blend system, cliff UVs, terrain shaders, frustum culling |
| 4 | Pending | Water rendering -- polygon trigger meshes, scrolling UV shader, shoreline blending |
| 5 | Pending | Object placement & scene graph -- scene nodes with transforms, object template resolution, instanced rendering, roads/bridges |
| 6 | Pending | Lighting & polish -- time-of-day lighting, shadow color, cloud shadows, minimap |
| 7 | Pending | Map viewer UI -- map browser, map info panel, object list, time-of-day selector, layer toggles, mode switching |

## Code Style

- 2-space indentation for C/C++ files
Expand All @@ -191,6 +240,28 @@ shaders/

## Key Reference Files

- **W3D format spec:** `legacy/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/w3d_file.h`
- **Original mesh loading:** `legacy/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp`
### W3D Model Format
- **W3D format spec:** `lib/GeneralsGameCode/` (original SAGE engine source)
- **Vulkan-Hpp samples:** `lib/Vulkan-Hpp/RAII_Samples/`

### Map/Terrain Format (in `lib/GeneralsGameCode/`)
- **DataChunk reader/writer:** `Generals/Code/GameEngine/.../DataChunk.h/cpp` -- binary framing format
- **Heightmap parser:** `Core/GameEngineDevice/.../WorldHeightMap.h/cpp` -- `ParseHeightMapData()`, `ParseBlendTileData()`, `ParseLightingData()` (2535 lines)
- **Tile data:** `Core/GameEngineDevice/.../TileData.h/cpp` -- 64x64 pixel tile storage
- **Terrain renderer:** `Core/GameEngineDevice/.../HeightMap.h/cpp` -- full 3D heightmap rendering
- **Terrain textures:** `Core/GameEngineDevice/.../TerrainTex.h/cpp` -- runtime atlas generation
- **Water rendering:** `Core/GameEngineDevice/.../W3DWater.h` + `Water/W3DWater.cpp`
- **Map objects:** `Core/GameEngine/.../MapObject.h` -- `MAP_XY_FACTOR`, `MAP_HEIGHT_SCALE`
- **Polygon triggers:** `Generals/Code/.../PolygonTrigger.h/cpp` -- water areas, rivers
- **Version constants:** `GeneralsMD/Code/.../MapReaderWriterInfo.h` -- all chunk versions
- **Map writer:** `GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp` -- `saveToFile()`
- **Terrain types:** `GeneralsMD/Code/.../TerrainTypes.h/cpp` -- INI terrain definitions
- **Water INI:** `GeneralsMD/Code/.../INIWater.cpp` -- water settings parsing

### Architecture Notes
- Map files use **DataChunk** format (`CkMp` magic), completely separate from W3D chunk format
- DataChunk uses named chunks (string -> ID via TOC), W3D uses numbered chunks (uint32 type IDs)
- Both formats are binary, little-endian, chunk-based, but share no code
- The DataChunk TOC ID space is shared between chunk names AND Dict key names
- Dict values support 5 types: BOOL (1 byte), INT (4), REAL (4), ASCIISTRING (uint16 len + chars), UNICODESTRING (uint16 charLen + charLen*2 bytes)
- See AGENTS.md for full map format specification and terrain rendering pipeline details
Loading
Loading