Skip to main content

VIVIA โ€” Architecture

Source Layoutโ€‹

Core/Src/
โ”œโ”€โ”€ main.rs # Application loop, input, commands
โ”œโ”€โ”€ gameplay.rs # Clock, stats, enemies, animals, quests, crafting
โ”œโ”€โ”€ inventory.rs # Hotbar, inventory slots, stacking
โ”œโ”€โ”€ crafting.rs # NVCrafter recipe system
โ”œโ”€โ”€ quests.rs # Quest chain progression
โ”œโ”€โ”€ commands.rs # Chat commands (/tp, /spawn, /time, etc.)
โ”œโ”€โ”€ settings.rs # SharedSettings (render radius, etc.)
โ”œโ”€โ”€ assets.rs # Asset loading
โ”œโ”€โ”€ input.rs # Keyboard/mouse state
โ”œโ”€โ”€ audio.rs # Procedural sound engine
โ”œโ”€โ”€ spatial_audio.rs # 3D spatial audio (Source 2 pattern)
โ”œโ”€โ”€ physics.rs # Collision, gravity
โ”œโ”€โ”€ pathfinding.rs # A* pathfinding for mobs
โ”œโ”€โ”€ memory_pool.rs # Allocation-free hot path
โ”œโ”€โ”€ job_system.rs # Background task scheduler
โ”œโ”€โ”€ npcs.rs # NPC dialogue system
โ”œโ”€โ”€ egs.rs # Epic Online Services bridge
โ”œโ”€โ”€ network/
โ”‚ โ”œโ”€โ”€ mod.rs # Packet send/recv
โ”‚ โ”œโ”€โ”€ protocol.rs # Packet definitions, validation
โ”‚ โ”œโ”€โ”€ server.rs # Authoritative server
โ”‚ โ””โ”€โ”€ client.rs # Client with interpolation
โ”œโ”€โ”€ renderer/
โ”‚ โ”œโ”€โ”€ mod.rs # GPU pipeline, draw calls
โ”‚ โ”œโ”€โ”€ camera.rs # First-person camera
โ”‚ โ”œโ”€โ”€ texture_atlas.rs # Block texture atlas
โ”‚ โ”œโ”€โ”€ geometry.rs # Procedural 3D primitives
โ”‚ โ”œโ”€โ”€ glb.rs # GLB model loader (decimation, UV bake)
โ”‚ โ”œโ”€โ”€ skeleton.rs # Joint hierarchy, inverse bind
โ”‚ โ”œโ”€โ”€ skin.rs # glTF 2.0 animation engine
โ”‚ โ”œโ”€โ”€ anim.rs # Procedural walk/idle animations
โ”‚ โ”œโ”€โ”€ text.rs # Text rendering
โ”‚ โ”œโ”€โ”€ instance.rs # Instance buffer management
โ”‚ โ””โ”€โ”€ *.wgsl # GPU shaders (sky, weather, animals, models)
โ””โ”€โ”€ world/
โ”œโ”€โ”€ mod.rs # World state, block access
โ”œโ”€โ”€ block.rs # BlockType registry (147+ types)
โ”œโ”€โ”€ chunk.rs # 16ร—512ร—16 chunk storage
โ”œโ”€โ”€ generator.rs # OpenSimplex2 terrain generation
โ”œโ”€โ”€ biomes.rs # 9 climate-driven biomes
โ”œโ”€โ”€ vegetation.rs # Tree/plant placement
โ”œโ”€โ”€ decorations.rs # Decorative elements
โ”œโ”€โ”€ ai_generator.rs # MeMLP neural network
โ”œโ”€โ”€ ai_feedback.rs # Player preference learning
โ”œโ”€โ”€ memplp.rs # Modular MLP architecture
โ”œโ”€โ”€ online_trainer.rs # Open-Meteo API training data
โ”œโ”€โ”€ meteo.rs # Embedded NASA climate data
โ”œโ”€โ”€ dungeon.rs # Procedural dungeon generation
โ”œโ”€โ”€ liquid.rs # Water/lava simulation
โ”œโ”€โ”€ palette.rs # Block color palettes
โ”œโ”€โ”€ storage.rs # Block storage optimization
โ”œโ”€โ”€ raycast.rs # Block raycasting
โ””โ”€โ”€ worldgen.rs # World generation orchestrator

Data Flowโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ OpenSimplex โ”‚โ”€โ”€โ–บโ”‚ Chunk Gen โ”‚โ”€โ”€โ–บโ”‚ GPU Upload โ”‚
โ”‚ (heightmap) โ”‚ โ”‚ (rayon) โ”‚ โ”‚ (wgpu) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MeMLP AI โ”‚
โ”‚ (online) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Chunk Lifecycleโ€‹

  1. Request โ€” player position triggers chunk generation requests
  2. Generate โ€” OpenSimplex2 heightmap + cave/ore placement + vegetation
  3. Decorate โ€” AI-driven vegetation, decorations, dungeon chests
  4. Upload โ€” vertex/index buffers to GPU
  5. Render โ€” instanced draw call per chunk
  6. Unload โ€” chunks beyond render distance are evicted

Block Registryโ€‹

147+ block types, each with:

  • Hardness (mining time)
  • Tool tier (wood โ†’ stone โ†’ iron โ†’ diamond)
  • Texture (16ร—16 PNG or procedural fallback)
  • Model (13 block models: stairs, slabs, logs, etc.)
  • Drops (what the player gets when mining)
  • Fluid properties (water/lava propagation)