mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 11:03:51 +00:00
Three new single-keyframe WOL presets complement the
existing 4-keyframe day/night cycle from --gen-light:
• --gen-light-cave — dim cool ambient (0.05, 0.05, 0.07)
+ heavy short-range fog (15..80)
for cave / mine interiors
• --gen-light-dungeon — warm torchlit ambient (0.18, 0.14,
0.10) + medium fog (25..200) for
dungeon / crypt interiors
• --gen-light-night — cold blue ambient (0.06, 0.07, 0.12)
+ moonlit directional + far fog
(80..500) for always-night zones
Each preset emits a single-keyframe WOL since enclosed /
fixed-time scenes don't vary with time-of-day. All three
share an emitLightPreset helper so adding more presets
(e.g. --gen-light-tundra, --gen-light-volcanic) is one
line of registration + a maker function.
All four WOL outputs validate clean under --validate-wol
(1 or 4 keyframe(s) valid).
82 lines
3.1 KiB
C++
82 lines
3.1 KiB
C++
#pragma once
|
||
|
||
#include <glm/glm.hpp>
|
||
#include <cstdint>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
namespace wowee {
|
||
namespace pipeline {
|
||
|
||
// Wowee Open Light format (.wol) — novel replacement for WoW's
|
||
// Light.dbc / LightParams.dbc / LightIntBand.dbc / LightFloatBand.dbc
|
||
// stack. A WOL file holds a list of time-of-day keyframes for one
|
||
// zone, each capturing the ambient + directional + fog state at that
|
||
// moment. The renderer interpolates between adjacent keyframes by
|
||
// time-of-day.
|
||
//
|
||
// Binary layout (little-endian):
|
||
// magic[4] = "WOLA"
|
||
// version (uint32) = current 1
|
||
// nameLen (uint32)
|
||
// name bytes (nameLen)
|
||
// keyframeCount (uint32)
|
||
// keyframes (each):
|
||
// timeOfDayMin (uint32) -- 0..1439, minutes since midnight
|
||
// ambientColor.rgb (3 × float)
|
||
// directionalColor.rgb (3 × float)
|
||
// directionalDir.xyz (3 × float) -- unit vector pointing FROM
|
||
// the sun TO the surface
|
||
// fogColor.rgb (3 × float)
|
||
// fogStart (float) -- meters
|
||
// fogEnd (float) -- meters
|
||
struct WoweeLight {
|
||
struct Keyframe {
|
||
uint32_t timeOfDayMin = 0;
|
||
glm::vec3 ambientColor{0.20f, 0.20f, 0.25f};
|
||
glm::vec3 directionalColor{0.95f, 0.92f, 0.85f};
|
||
glm::vec3 directionalDir{0.0f, -1.0f, 0.0f};
|
||
glm::vec3 fogColor{0.65f, 0.70f, 0.78f};
|
||
float fogStart = 80.0f;
|
||
float fogEnd = 600.0f;
|
||
};
|
||
|
||
std::string name; // zone or scene name
|
||
std::vector<Keyframe> keyframes; // sorted by timeOfDayMin
|
||
|
||
bool isValid() const { return !keyframes.empty(); }
|
||
};
|
||
|
||
class WoweeLightLoader {
|
||
public:
|
||
static bool save(const WoweeLight& light, const std::string& basePath);
|
||
static WoweeLight load(const std::string& basePath);
|
||
static bool exists(const std::string& basePath);
|
||
|
||
// Convenience: emit a 4-keyframe day/night cycle (dawn 6:00,
|
||
// noon 12:00, dusk 18:00, midnight 0:00) with reasonable
|
||
// outdoor defaults. Used by --gen-light to create a starter
|
||
// file users can edit.
|
||
static WoweeLight makeDefaultDayNight(const std::string& zoneName);
|
||
|
||
// Preset variants for non-outdoor zones — these emit a
|
||
// single-keyframe WOL since the lighting doesn't vary by
|
||
// time-of-day for an enclosed scene.
|
||
//
|
||
// makeCave dim blue ambient + heavy fog
|
||
// makeDungeon moody indoor torchlit + medium fog
|
||
// makeNight dark blue ambient + far fog (night-only zone)
|
||
static WoweeLight makeCave(const std::string& zoneName);
|
||
static WoweeLight makeDungeon(const std::string& zoneName);
|
||
static WoweeLight makeNight(const std::string& zoneName);
|
||
|
||
// Lookup the interpolated lighting state at any time-of-day
|
||
// (clamped to 0..1439 minutes). Linearly blends between the
|
||
// two adjacent keyframes; wraps around midnight if the query
|
||
// time falls between the last and first keyframe.
|
||
static WoweeLight::Keyframe sampleAtTime(const WoweeLight& light,
|
||
uint32_t timeMin);
|
||
};
|
||
|
||
} // namespace pipeline
|
||
} // namespace wowee
|