mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 03:23:51 +00:00
feat(pipeline): add WANI (Wowee Animation) catalog
46th open format — replaces AnimationData.dbc plus the hard-coded animation-id tables in M2 model loaders. Defines named animations (Stand, Walk, Run, Cast, Death, MountIdle, Fly, ...) with fallback chains, behavior tier (default / mounted / sitting / aerial / swimming), and weapon-flag bitmasks that select the correct animation variant when the model wields 1H / 2H / dual / bow / rifle / wand / etc. Cross-references with prior formats — fallbackId resolves within the same WANI catalog (graceful degradation when the requested animation is absent: Run falls back to Walk, Attack2H falls back to Attack1H). 10 weapon-flag constants + 6 behavior flags (Looped, BlendableCycle, Interruptable, MovementSync, OneShot, PreserveAtEnd). 5 behavior tiers. CLI: --gen-animations (5 essentials), --gen-animations-combat (8 weapon-typed attacks + parry + channel), --gen-animations-movement (6 locomotion anims with tier transitions). Validator catches id-uniqueness, fallback-self-loop, looped-without-duration, mutually-exclusive Looped+OneShot flags, weaponFlags=0 warning, and unresolved fallback warnings. Also extends --list-formats and --info-magic with WANI.
This commit is contained in:
parent
cdfb55c477
commit
dadf72307c
10 changed files with 670 additions and 0 deletions
|
|
@ -633,6 +633,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_vehicles.cpp
|
||||
src/pipeline/wowee_holidays.cpp
|
||||
src/pipeline/wowee_liquids.cpp
|
||||
src/pipeline/wowee_animations.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1414,6 +1415,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_liquids_catalog.cpp
|
||||
tools/editor/cli_list_formats.cpp
|
||||
tools/editor/cli_info_magic.cpp
|
||||
tools/editor/cli_animations_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1525,6 +1527,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_vehicles.cpp
|
||||
src/pipeline/wowee_holidays.cpp
|
||||
src/pipeline/wowee_liquids.cpp
|
||||
src/pipeline/wowee_animations.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
119
include/pipeline/wowee_animations.hpp
Normal file
119
include/pipeline/wowee_animations.hpp
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Animation Data catalog (.wani) — novel
|
||||
// replacement for Blizzard's AnimationData.dbc plus the
|
||||
// hard-coded animation-id tables in M2 models. The 46th
|
||||
// open format added to the editor.
|
||||
//
|
||||
// Defines named animations (Stand, Walk, Run, Cast, Death,
|
||||
// SitGround, Mount, ...) with fallback chains, behavior
|
||||
// tier (default / mounted / aerial / sitting), and weapon-
|
||||
// flag bitmasks that select the right animation variant
|
||||
// when the model is wielding 1H / 2H / dual / unarmed /
|
||||
// ranged.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WANI.entry.fallbackId → WANI.entry.animationId
|
||||
// (graceful degradation when the
|
||||
// requested animation is absent)
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WANI"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// animationId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// fallbackId (uint32)
|
||||
// behaviorId (uint32)
|
||||
// behaviorTier (uint8) / pad[3]
|
||||
// flags (uint32)
|
||||
// weaponFlags (uint32)
|
||||
// loopDurationMs (uint32) — 0 = oneshot
|
||||
struct WoweeAnimation {
|
||||
enum BehaviorTier : uint8_t {
|
||||
Default = 0, // standing on the ground
|
||||
Mounted = 1, // riding a vehicle / mount
|
||||
Sitting = 2, // sitting in a chair / on the ground
|
||||
Aerial = 3, // flying / hovering
|
||||
Swimming = 4, // underwater
|
||||
};
|
||||
|
||||
// Flag bits — animation behavior modifiers.
|
||||
static constexpr uint32_t kFlagLooped = 0x00000001;
|
||||
static constexpr uint32_t kFlagBlendableCycle = 0x00000002;
|
||||
static constexpr uint32_t kFlagInterruptable = 0x00000004;
|
||||
static constexpr uint32_t kFlagMovementSync = 0x00000008;
|
||||
static constexpr uint32_t kFlagOneShot = 0x00000010;
|
||||
static constexpr uint32_t kFlagPreserveAtEnd = 0x00000020;
|
||||
|
||||
// Weapon-flag bits — which wielded weapon this anim
|
||||
// applies to. Match the WoW weapon class enum.
|
||||
static constexpr uint32_t kWeaponUnarmed = 0x00000001;
|
||||
static constexpr uint32_t kWeapon1HMelee = 0x00000002;
|
||||
static constexpr uint32_t kWeapon2HMelee = 0x00000004;
|
||||
static constexpr uint32_t kWeaponDualWield = 0x00000008;
|
||||
static constexpr uint32_t kWeaponBow = 0x00000010;
|
||||
static constexpr uint32_t kWeaponCrossbow = 0x00000020;
|
||||
static constexpr uint32_t kWeaponRifle = 0x00000040;
|
||||
static constexpr uint32_t kWeaponWand = 0x00000080;
|
||||
static constexpr uint32_t kWeaponPolearm = 0x00000100;
|
||||
static constexpr uint32_t kWeaponShield = 0x00000200;
|
||||
static constexpr uint32_t kWeaponAny = 0xFFFFFFFFu;
|
||||
|
||||
struct Entry {
|
||||
uint32_t animationId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint32_t fallbackId = 0; // WANI cross-ref
|
||||
uint32_t behaviorId = 0;
|
||||
uint8_t behaviorTier = Default;
|
||||
uint32_t flags = 0;
|
||||
uint32_t weaponFlags = kWeaponAny;
|
||||
uint32_t loopDurationMs = 0; // 0 = oneshot
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
const Entry* findById(uint32_t animationId) const;
|
||||
|
||||
static const char* behaviorTierName(uint8_t t);
|
||||
};
|
||||
|
||||
class WoweeAnimationLoader {
|
||||
public:
|
||||
static bool save(const WoweeAnimation& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeAnimation load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-animations* variants.
|
||||
//
|
||||
// makeStarter — 5 essential animations every model
|
||||
// needs (Stand / Walk / Run / Death /
|
||||
// AttackUnarmed).
|
||||
// makeCombat — 8 combat animations covering 1H/2H/
|
||||
// dual-wield melee + bow/rifle/crossbow
|
||||
// ranged + channeled spell + parry.
|
||||
// makeMovement — 6 movement animations (Walk / Run /
|
||||
// Sprint / Swim / Mount / Fly) with
|
||||
// behavior-tier transitions.
|
||||
static WoweeAnimation makeStarter(const std::string& catalogName);
|
||||
static WoweeAnimation makeCombat(const std::string& catalogName);
|
||||
static WoweeAnimation makeMovement(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
268
src/pipeline/wowee_animations.cpp
Normal file
268
src/pipeline/wowee_animations.cpp
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
#include "pipeline/wowee_animations.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'A', 'N', 'I'};
|
||||
constexpr uint32_t kVersion = 1;
|
||||
|
||||
template <typename T>
|
||||
void writePOD(std::ofstream& os, const T& v) {
|
||||
os.write(reinterpret_cast<const char*>(&v), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool readPOD(std::ifstream& is, T& v) {
|
||||
is.read(reinterpret_cast<char*>(&v), sizeof(T));
|
||||
return is.gcount() == static_cast<std::streamsize>(sizeof(T));
|
||||
}
|
||||
|
||||
void writeStr(std::ofstream& os, const std::string& s) {
|
||||
uint32_t n = static_cast<uint32_t>(s.size());
|
||||
writePOD(os, n);
|
||||
if (n > 0) os.write(s.data(), n);
|
||||
}
|
||||
|
||||
bool readStr(std::ifstream& is, std::string& s) {
|
||||
uint32_t n = 0;
|
||||
if (!readPOD(is, n)) return false;
|
||||
if (n > (1u << 20)) return false;
|
||||
s.resize(n);
|
||||
if (n > 0) {
|
||||
is.read(s.data(), n);
|
||||
if (is.gcount() != static_cast<std::streamsize>(n)) {
|
||||
s.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string normalizePath(std::string base) {
|
||||
if (base.size() < 5 || base.substr(base.size() - 5) != ".wani") {
|
||||
base += ".wani";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeAnimation::Entry*
|
||||
WoweeAnimation::findById(uint32_t animationId) const {
|
||||
for (const auto& e : entries)
|
||||
if (e.animationId == animationId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* WoweeAnimation::behaviorTierName(uint8_t t) {
|
||||
switch (t) {
|
||||
case Default: return "default";
|
||||
case Mounted: return "mounted";
|
||||
case Sitting: return "sitting";
|
||||
case Aerial: return "aerial";
|
||||
case Swimming: return "swimming";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeAnimationLoader::save(const WoweeAnimation& cat,
|
||||
const std::string& basePath) {
|
||||
std::ofstream os(normalizePath(basePath), std::ios::binary);
|
||||
if (!os) return false;
|
||||
os.write(kMagic, 4);
|
||||
writePOD(os, kVersion);
|
||||
writeStr(os, cat.name);
|
||||
uint32_t entryCount = static_cast<uint32_t>(cat.entries.size());
|
||||
writePOD(os, entryCount);
|
||||
for (const auto& e : cat.entries) {
|
||||
writePOD(os, e.animationId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writePOD(os, e.fallbackId);
|
||||
writePOD(os, e.behaviorId);
|
||||
writePOD(os, e.behaviorTier);
|
||||
uint8_t pad[3] = {0, 0, 0};
|
||||
os.write(reinterpret_cast<const char*>(pad), 3);
|
||||
writePOD(os, e.flags);
|
||||
writePOD(os, e.weaponFlags);
|
||||
writePOD(os, e.loopDurationMs);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeAnimation WoweeAnimationLoader::load(const std::string& basePath) {
|
||||
WoweeAnimation out;
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
if (!is) return out;
|
||||
char magic[4];
|
||||
is.read(magic, 4);
|
||||
if (std::memcmp(magic, kMagic, 4) != 0) return out;
|
||||
uint32_t version = 0;
|
||||
if (!readPOD(is, version) || version != kVersion) return out;
|
||||
if (!readStr(is, out.name)) return out;
|
||||
uint32_t entryCount = 0;
|
||||
if (!readPOD(is, entryCount)) return out;
|
||||
if (entryCount > (1u << 20)) return out;
|
||||
out.entries.resize(entryCount);
|
||||
for (auto& e : out.entries) {
|
||||
if (!readPOD(is, e.animationId)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.fallbackId) ||
|
||||
!readPOD(is, e.behaviorId) ||
|
||||
!readPOD(is, e.behaviorTier)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
uint8_t pad[3];
|
||||
is.read(reinterpret_cast<char*>(pad), 3);
|
||||
if (is.gcount() != 3) { out.entries.clear(); return out; }
|
||||
if (!readPOD(is, e.flags) ||
|
||||
!readPOD(is, e.weaponFlags) ||
|
||||
!readPOD(is, e.loopDurationMs)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeAnimationLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeAnimation WoweeAnimationLoader::makeStarter(const std::string& catalogName) {
|
||||
WoweeAnimation c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint32_t fallback,
|
||||
uint32_t flags, uint32_t durMs, const char* desc) {
|
||||
WoweeAnimation::Entry e;
|
||||
e.animationId = id; e.name = name; e.description = desc;
|
||||
e.fallbackId = fallback;
|
||||
e.flags = flags;
|
||||
e.loopDurationMs = durMs;
|
||||
e.behaviorTier = WoweeAnimation::Default;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Animation IDs match the canonical WoW table.
|
||||
add(0, "Stand", 0,
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagBlendableCycle, 2000,
|
||||
"Idle stance — looping default.");
|
||||
add(4, "Walk", 0, // fall back to Stand
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 1000,
|
||||
"Slow walk cycle — synced to movement speed.");
|
||||
add(5, "Run", 4, // fall back to Walk
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 800,
|
||||
"Run cycle — synced to movement speed.");
|
||||
add(1, "Death", 0,
|
||||
WoweeAnimation::kFlagOneShot |
|
||||
WoweeAnimation::kFlagPreserveAtEnd, 2500,
|
||||
"Death animation — pose preserved at end.");
|
||||
add(17, "AttackUnarmed", 0,
|
||||
WoweeAnimation::kFlagOneShot |
|
||||
WoweeAnimation::kFlagInterruptable, 1500,
|
||||
"Bare-handed melee swing.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeAnimation WoweeAnimationLoader::makeCombat(const std::string& catalogName) {
|
||||
WoweeAnimation c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint32_t fallback,
|
||||
uint32_t weaponFlags, uint32_t durMs,
|
||||
const char* desc) {
|
||||
WoweeAnimation::Entry e;
|
||||
e.animationId = id; e.name = name; e.description = desc;
|
||||
e.fallbackId = fallback;
|
||||
e.flags = WoweeAnimation::kFlagOneShot |
|
||||
WoweeAnimation::kFlagInterruptable;
|
||||
e.weaponFlags = weaponFlags;
|
||||
e.loopDurationMs = durMs;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(17, "Attack1H", 0,
|
||||
WoweeAnimation::kWeapon1HMelee, 1500,
|
||||
"1H melee swing.");
|
||||
add(18, "Attack2H", 17, // fall back to Attack1H
|
||||
WoweeAnimation::kWeapon2HMelee, 2000,
|
||||
"2H melee swing — slower wind-up.");
|
||||
add(19, "AttackDualWield", 17,
|
||||
WoweeAnimation::kWeaponDualWield, 1200,
|
||||
"Dual-wield alternating swings.");
|
||||
add(40, "AttackBow", 0,
|
||||
WoweeAnimation::kWeaponBow, 1800,
|
||||
"Bow draw + release.");
|
||||
add(41, "AttackRifle", 40,
|
||||
WoweeAnimation::kWeaponRifle, 1500,
|
||||
"Rifle shoulder + fire.");
|
||||
add(46, "AttackThrown", 0,
|
||||
WoweeAnimation::kWeaponAny, 1000,
|
||||
"Thrown weapon over-arm release.");
|
||||
add(53, "Parry", 0,
|
||||
WoweeAnimation::kWeapon1HMelee |
|
||||
WoweeAnimation::kWeapon2HMelee, 600,
|
||||
"Defensive weapon parry.");
|
||||
add(54, "ChannelCast", 0,
|
||||
WoweeAnimation::kWeaponAny, 3000,
|
||||
"Channeled spell cast — looping arms-out.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeAnimation WoweeAnimationLoader::makeMovement(const std::string& catalogName) {
|
||||
WoweeAnimation c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint32_t fallback,
|
||||
uint8_t tier, uint32_t flags, uint32_t durMs,
|
||||
const char* desc) {
|
||||
WoweeAnimation::Entry e;
|
||||
e.animationId = id; e.name = name; e.description = desc;
|
||||
e.fallbackId = fallback;
|
||||
e.behaviorTier = tier;
|
||||
e.flags = flags;
|
||||
e.loopDurationMs = durMs;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(4, "Walk", 0,
|
||||
WoweeAnimation::Default,
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 1000,
|
||||
"Walk cycle (default tier).");
|
||||
add(5, "Run", 4,
|
||||
WoweeAnimation::Default,
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 800,
|
||||
"Run cycle.");
|
||||
add(7, "Sprint", 5,
|
||||
WoweeAnimation::Default,
|
||||
WoweeAnimation::kFlagLooped, 600,
|
||||
"Sprint — boosted run.");
|
||||
add(8, "Swim", 4,
|
||||
WoweeAnimation::Swimming,
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 1200,
|
||||
"Underwater swim cycle.");
|
||||
add(91, "MountIdle", 0,
|
||||
WoweeAnimation::Mounted,
|
||||
WoweeAnimation::kFlagLooped, 2500,
|
||||
"Sitting on a mount, holding the reins.");
|
||||
add(132, "Fly", 5,
|
||||
WoweeAnimation::Aerial,
|
||||
WoweeAnimation::kFlagLooped |
|
||||
WoweeAnimation::kFlagMovementSync, 1000,
|
||||
"Flying with wings extended.");
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
253
tools/editor/cli_animations_catalog.cpp
Normal file
253
tools/editor/cli_animations_catalog.cpp
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
#include "cli_animations_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_animations.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string stripWaniExt(std::string base) {
|
||||
stripExt(base, ".wani");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeAnimation& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeAnimationLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wani\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeAnimation& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wani\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" animations : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterAnimations";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWaniExt(base);
|
||||
auto c = wowee::pipeline::WoweeAnimationLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-animations")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenCombat(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "CombatAnimations";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWaniExt(base);
|
||||
auto c = wowee::pipeline::WoweeAnimationLoader::makeCombat(name);
|
||||
if (!saveOrError(c, base, "gen-animations-combat")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenMovement(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "MovementAnimations";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWaniExt(base);
|
||||
auto c = wowee::pipeline::WoweeAnimationLoader::makeMovement(name);
|
||||
if (!saveOrError(c, base, "gen-animations-movement")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleInfo(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWaniExt(base);
|
||||
if (!wowee::pipeline::WoweeAnimationLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WANI not found: %s.wani\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeAnimationLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wani"] = base + ".wani";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"animationId", e.animationId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"fallbackId", e.fallbackId},
|
||||
{"behaviorId", e.behaviorId},
|
||||
{"behaviorTier", e.behaviorTier},
|
||||
{"behaviorTierName", wowee::pipeline::WoweeAnimation::behaviorTierName(e.behaviorTier)},
|
||||
{"flags", e.flags},
|
||||
{"weaponFlags", e.weaponFlags},
|
||||
{"loopDurationMs", e.loopDurationMs},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WANI: %s.wani\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" animations : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id tier flags weapons dur(ms) fallback name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %4u %-9s 0x%08x 0x%08x %5u %4u %s\n",
|
||||
e.animationId,
|
||||
wowee::pipeline::WoweeAnimation::behaviorTierName(e.behaviorTier),
|
||||
e.flags, e.weaponFlags, e.loopDurationMs,
|
||||
e.fallbackId, e.name.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleValidate(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
||||
base = stripWaniExt(base);
|
||||
if (!wowee::pipeline::WoweeAnimationLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wani: WANI not found: %s.wani\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeAnimationLoader::load(base);
|
||||
std::vector<std::string> errors;
|
||||
std::vector<std::string> warnings;
|
||||
if (c.entries.empty()) {
|
||||
warnings.push_back("catalog has zero entries");
|
||||
}
|
||||
std::vector<uint32_t> idsSeen;
|
||||
// First pass — collect all animationIds for fallback
|
||||
// resolution.
|
||||
std::vector<uint32_t> allIds;
|
||||
for (const auto& e : c.entries) allIds.push_back(e.animationId);
|
||||
auto idExists = [&](uint32_t id) {
|
||||
for (uint32_t a : allIds) if (a == id) return true;
|
||||
return false;
|
||||
};
|
||||
for (size_t k = 0; k < c.entries.size(); ++k) {
|
||||
const auto& e = c.entries[k];
|
||||
std::string ctx = "entry " + std::to_string(k) +
|
||||
" (id=" + std::to_string(e.animationId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.name.empty())
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
if (e.behaviorTier > wowee::pipeline::WoweeAnimation::Swimming) {
|
||||
errors.push_back(ctx + ": behaviorTier " +
|
||||
std::to_string(e.behaviorTier) + " not in 0..4");
|
||||
}
|
||||
if (e.weaponFlags == 0) {
|
||||
warnings.push_back(ctx +
|
||||
": weaponFlags=0 (animation never selected for any weapon)");
|
||||
}
|
||||
// fallbackId == animationId would create an infinite
|
||||
// loop. fallback to id 0 (Stand) is conventional and
|
||||
// always valid even if Stand isn't in this catalog.
|
||||
if (e.fallbackId == e.animationId &&
|
||||
e.animationId != 0) {
|
||||
errors.push_back(ctx +
|
||||
": fallbackId equals animationId (infinite loop)");
|
||||
}
|
||||
if (e.fallbackId != 0 && !idExists(e.fallbackId)) {
|
||||
warnings.push_back(ctx + ": fallbackId=" +
|
||||
std::to_string(e.fallbackId) +
|
||||
" not found in this catalog (resolved at runtime)");
|
||||
}
|
||||
// Looped animations must have a non-zero duration —
|
||||
// otherwise the renderer divides by zero stepping the
|
||||
// animation cursor.
|
||||
if ((e.flags & wowee::pipeline::WoweeAnimation::kFlagLooped) &&
|
||||
e.loopDurationMs == 0) {
|
||||
errors.push_back(ctx +
|
||||
": kFlagLooped set but loopDurationMs=0 "
|
||||
"(animation cursor would divide by zero)");
|
||||
}
|
||||
// Mutually exclusive — Looped + OneShot is contradictory.
|
||||
if ((e.flags & wowee::pipeline::WoweeAnimation::kFlagLooped) &&
|
||||
(e.flags & wowee::pipeline::WoweeAnimation::kFlagOneShot)) {
|
||||
errors.push_back(ctx +
|
||||
": both kFlagLooped and kFlagOneShot set "
|
||||
"(mutually exclusive)");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.animationId) {
|
||||
errors.push_back(ctx + ": duplicate animationId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.animationId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wani"] = base + ".wani";
|
||||
j["ok"] = ok;
|
||||
j["errors"] = errors;
|
||||
j["warnings"] = warnings;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
std::printf("validate-wani: %s.wani\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu animations, all animationIds unique\n",
|
||||
c.entries.size());
|
||||
return 0;
|
||||
}
|
||||
if (!warnings.empty()) {
|
||||
std::printf(" warnings (%zu):\n", warnings.size());
|
||||
for (const auto& w : warnings)
|
||||
std::printf(" - %s\n", w.c_str());
|
||||
}
|
||||
if (!errors.empty()) {
|
||||
std::printf(" ERRORS (%zu):\n", errors.size());
|
||||
for (const auto& e : errors)
|
||||
std::printf(" - %s\n", e.c_str());
|
||||
}
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool handleAnimationsCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-animations") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-animations-combat") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenCombat(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-animations-movement") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenMovement(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wani") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wani") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
11
tools/editor/cli_animations_catalog.hpp
Normal file
11
tools/editor/cli_animations_catalog.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleAnimationsCatalog(int& i, int argc, char** argv, int& outRc);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
|
|
@ -135,6 +135,8 @@ const char* const kArgRequired[] = {
|
|||
"--info-wliq", "--validate-wliq",
|
||||
"--export-wliq-json", "--import-wliq-json",
|
||||
"--info-magic",
|
||||
"--gen-animations", "--gen-animations-combat", "--gen-animations-movement",
|
||||
"--info-wani", "--validate-wani",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
#include "cli_liquids_catalog.hpp"
|
||||
#include "cli_list_formats.hpp"
|
||||
#include "cli_info_magic.hpp"
|
||||
#include "cli_animations_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -191,6 +192,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleLiquidsCatalog,
|
||||
handleListFormats,
|
||||
handleInfoMagic,
|
||||
handleAnimationsCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -1351,6 +1351,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print the catalog of all novel open formats (magic / extension / category / replaces / description)\n");
|
||||
std::printf(" --info-magic <path> [--json]\n");
|
||||
std::printf(" Auto-detect any .w* file by 4-byte magic; report format / version / catalog name / entry count + suggest --info-* flag\n");
|
||||
std::printf(" --gen-animations <wani-base> [name]\n");
|
||||
std::printf(" Emit .wani starter: 5 essential animations (Stand / Walk / Run / Death / AttackUnarmed) with fallback chains\n");
|
||||
std::printf(" --gen-animations-combat <wani-base> [name]\n");
|
||||
std::printf(" Emit .wani 8 combat anims (1H/2H/dual-wield/bow/rifle/thrown + parry + channel) with weapon-flag bitmasks\n");
|
||||
std::printf(" --gen-animations-movement <wani-base> [name]\n");
|
||||
std::printf(" Emit .wani 6 movement anims (Walk/Run/Sprint/Swim/Mount/Fly) with behavior-tier transitions (default/aerial/swim)\n");
|
||||
std::printf(" --info-wani <wani-base> [--json]\n");
|
||||
std::printf(" Print WANI entries (id / tier / flags / weapon mask / loop duration / fallback / name)\n");
|
||||
std::printf(" --validate-wani <wani-base> [--json]\n");
|
||||
std::printf(" Static checks: id-unique, name not empty, tier 0..4, fallback != self, loop+oneshot exclusivity, looped requires duration\n");
|
||||
std::printf(" --gen-weather-temperate <wow-base> [zoneName]\n");
|
||||
std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n");
|
||||
std::printf(" --gen-weather-arctic <wow-base> [zoneName]\n");
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ constexpr MagicEntry kMagicTable[] = {
|
|||
{{'W','V','H','C'}, ".wvhc", "vehicles", "--info-wvhc", "Vehicle catalog"},
|
||||
{{'W','H','O','L'}, ".whol", "holiday", "--info-whol", "Holiday catalog"},
|
||||
{{'W','L','I','Q'}, ".wliq", "liquids", "--info-wliq", "Liquid catalog"},
|
||||
{{'W','A','N','I'}, ".wani", "anim", "--info-wani", "Animation catalog"},
|
||||
{{'W','F','A','C'}, ".wfac", "factions", nullptr, "Faction catalog"},
|
||||
{{'W','L','C','K'}, ".wlck", "locks", nullptr, "Lock catalog"},
|
||||
{{'W','S','K','L'}, ".wskl", "skills", nullptr, "Skill catalog"},
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ constexpr FormatRow kFormats[] = {
|
|||
{"WVHC", ".wvhc", "vehicles", "Vehicle.dbc + VehicleSeat.dbc", "Vehicle + seat-layout catalog"},
|
||||
{"WHOL", ".whol", "holiday", "Holidays.dbc + game_event", "Calendar holiday + event catalog"},
|
||||
{"WLIQ", ".wliq", "liquids", "LiquidType.dbc", "Liquid material catalog (water/lava/slime)"},
|
||||
{"WANI", ".wani", "anim", "AnimationData.dbc", "Animation ID + fallback + weapon-flag catalog"},
|
||||
|
||||
// Additional pipeline catalogs without the alternating
|
||||
// gen/info/validate CLI surface (loaded by the engine
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue