#pragma once // Paper-doll compositor for player sprites. Every body and item is a sheet of // identical frame layout (3 direction rows x [standing, walk 0..3], 64 px // cells) made of a recolorable shade layer plus fixed-color pixels, so any // look is composed on the CPU in a few milliseconds without new art. // Mirrors tools/character_compose.py. #include "Appearance.h" #include "hd2d/Texture.h" #include #include #include namespace bs { // Shade 1 (darkest) .. 4 (highlight) of a base color; matches ramp() in tools/character_compose.py. std::array colorRamp(uint32_t rgb); class CharacterArt { public: bool load(const std::string& charDir, const CharacterManifest& manifest); // Full sprite sheet for a look (GL orientation, same layout as the source sheets). hd2d::Image compose(const Appearance& look) const; const CharacterManifest& manifest() const { return *manifest_; } private: struct Layer { hd2d::Image shade, fixed; // either may be empty }; struct Body { hd2d::Image fixed; Layer skin; std::map items; // includes top_tee / bottom_shorts shade layers }; std::map bodies_; const CharacterManifest* manifest_ = nullptr; }; // Sheet layout helpers shared by players and NPCs. struct SheetLayout { int cell = 64, framesPerDir = 5, walkFrames = 4; // Direction row for a facing relative to the camera; `flip` mirrors east into west. // relYaw: facing yaw minus camera yaw (0 = walking away from the camera). static int rowFor(float relYaw, bool& flip); }; } // namespace bs