Kelsidavis-WoWee/tools/editor/adt_writer.hpp
Kelsi 2980ca83e7 feat(editor): add standalone world editor (rough/WIP)
Standalone wowee_editor tool for creating custom WoW zones.
This is a rough initial implementation — many features work but
M2/WMO rendering still has issues (frame sync, texture layout
transitions) and needs further polish.

Terrain:
- Create new blank terrain with 10 biome types (Grassland, Forest,
  Jungle, Desert, Barrens, Snow, Swamp, Rocky, Beach, Volcanic)
- Load existing ADT tiles from extracted game data
- Sculpt brushes: Raise, Lower, Smooth, Flatten, Level
- Chunk edge stitching prevents seams between tiles
- Undo/redo (100-deep stack, Ctrl+Z/Ctrl+Shift+Z)
- Save to WoW ADT/WDT format

Texture Painting:
- Paint/Erase/Replace Base modes
- Full tileset texture browser (1285 textures from manifest)
- Per-zone directory filtering and search
- Alpha map editing with 4-layer limit (auto-replaces weakest)

Object Placement:
- M2 and WMO model placement with full manifest browser (11k M2s, 2k WMOs)
- M2Renderer + WMORenderer integrated (loads .skin files for WotLK)
- Ghost preview follows cursor before placing
- Ctrl+click selection, right-click context menu
- Transform gizmo (Move/Rotate/Scale with axis constraints)
- Position/rotation/scale editing in properties panel

NPC/Monster System:
- 631 creature presets scanned from manifest, categorized
  (Critters, Beasts, Humanoids, Undead, Demons, etc.)
- Stats editor: level, health, mana, damage, armor, faction
- Behavior: Stationary, Patrol, Wander, Scripted
- Aggro/leash radius, respawn time, flags (hostile/vendor/etc.)
- Save creature spawns to JSON

Water:
- Place water at configurable height per chunk
- Liquid types: Water, Ocean, Magma, Slime
- Rendered as translucent colored quads
- Saved in ADT MH2O format

Infrastructure:
- Free-fly camera (WASD/QE, right-drag look, scroll speed)
- 5-mode toolbar: Sculpt | Paint | Objects | Water | NPCs
- Asset browser indexes full manifest on startup
- Editor water/marker shaders (pos+color vertex format)
- forceNoCull added to M2Renderer for editor use
- AssetManifest::getEntries() and AssetManager::getManifest() exposed

Known issues:
- M2/WMO rendering may not display on first placement (frame index
  sync between update/render was misaligned — now fixed but untested
  end-to-end)
- Validation layer errors on shutdown (resource cleanup ordering)
- Object placement on steep terrain can miss raycast
- No undo for texture painting or object placement yet
2026-05-05 03:47:03 -07:00

38 lines
1.7 KiB
C++

#pragma once
#include "pipeline/adt_loader.hpp"
#include <string>
#include <vector>
#include <cstdint>
namespace wowee {
namespace editor {
class ADTWriter {
public:
static bool write(const pipeline::ADTTerrain& terrain, const std::string& path);
static std::vector<uint8_t> serialize(const pipeline::ADTTerrain& terrain);
// Write a minimal WDT file for a single-tile map
static bool writeWDT(const std::string& mapName, int tileX, int tileY, const std::string& path);
private:
static void writeChunkHeader(std::vector<uint8_t>& buf, uint32_t magic, uint32_t size);
static void writeU32(std::vector<uint8_t>& buf, uint32_t val);
static void writeU16(std::vector<uint8_t>& buf, uint16_t val);
static void writeFloat(std::vector<uint8_t>& buf, float val);
static void writeBytes(std::vector<uint8_t>& buf, const void* data, size_t size);
static void patchSize(std::vector<uint8_t>& buf, size_t headerOffset);
static void writeMVER(std::vector<uint8_t>& buf);
static void writeMHDR(std::vector<uint8_t>& buf, size_t& mhdrOffset);
static void writeMTEX(std::vector<uint8_t>& buf, const pipeline::ADTTerrain& terrain);
static void writeMMDX(std::vector<uint8_t>& buf, const pipeline::ADTTerrain& terrain);
static void writeMWMO(std::vector<uint8_t>& buf, const pipeline::ADTTerrain& terrain);
static void writeMDDF(std::vector<uint8_t>& buf, const pipeline::ADTTerrain& terrain);
static void writeMODF(std::vector<uint8_t>& buf, const pipeline::ADTTerrain& terrain);
static void writeMCNK(std::vector<uint8_t>& buf, const pipeline::MapChunk& chunk, int chunkX, int chunkY);
};
} // namespace editor
} // namespace wowee