mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
Three additions to the Wowee Open Light format that landed
last commit:
• WoweeLightLoader::sampleAtTime(light, timeMin) returns
the linearly-interpolated keyframe at any time-of-day,
correctly handling wrap-around between the last keyframe
and the first (e.g. 21:00 blends from dusk toward
midnight by going forward through 00:00).
• --validate-wol <wol-base> [--json] walks every keyframe
and reports structural problems: time bounds (must be
[0, 1440)), strict-ascending sort order, fogEnd >
fogStart, finite color components. Exit code 0 PASS /
1 FAIL — CI-friendly.
• --info-wol-at <wol-base> <HH:MM|minutes> samples the
interpolated state at a specific time of day. Useful
for previewing what the renderer would feed in at a
given moment, debugging keyframe gaps, or previewing
a sub-range of the cycle.
Smoke-tested: dawn-to-midnight blend at 03:00 yields a
plausible mid-fade ambient (0.18, 0.16, 0.15) and dusk-to-
midnight wrap at 21:00 yields the symmetric (0.19, 0.145,
0.14). The default 4-keyframe day/night cycle from
makeDefaultDayNight passes --validate-wol cleanly.
71 lines
2.5 KiB
C++
71 lines
2.5 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);
|
||
|
||
// 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
|