diff options
author | Bottinator22 <bottinator22@gmail.com> | 2025-03-12 11:16:18 -0700 |
---|---|---|
committer | Bottinator22 <bottinator22@gmail.com> | 2025-03-12 11:16:18 -0700 |
commit | 0c26f866c43dd92aa4001331f55eaf6ea7f1b11c (patch) | |
tree | e5d69b89a14ef945f05e8ab2ccbc7af8b13934ab | |
parent | 0fe21a8bb81c151d7f7427e788ca8cc576fe2778 (diff) |
head rotation masks
-rw-r--r-- | source/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/game/StarHumanoid.cpp | 44 | ||||
-rw-r--r-- | source/game/StarHumanoid.hpp | 7 |
3 files changed, 48 insertions, 7 deletions
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 131c6ad..98b9c6c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -297,8 +297,8 @@ if(STAR_COMPILER_GNU) set(CMAKE_SKIP_BUILD_RPATH TRUE) elseif(STAR_COMPILER_CLANG) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations -Wno-nan-infinity-disabled") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Wuninitialized -Wno-parentheses-equality -Wno-deprecated-declarations -Wno-nan-infinity-disabled") if(STAR_SYSTEM_MACOS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/source/game/StarHumanoid.cpp b/source/game/StarHumanoid.cpp index f3ac164..d8300e5 100644 --- a/source/game/StarHumanoid.cpp +++ b/source/game/StarHumanoid.cpp @@ -288,6 +288,12 @@ void Humanoid::setIdentity(HumanoidIdentity const& identity) { m_backArmFrameset = getBackArmFromIdentity(); m_frontArmFrameset = getFrontArmFromIdentity(); m_vaporTrailFrameset = getVaporTrailFrameset(); + if (m_useBodyMask) { + m_bodyMaskFrameset = getBodyMaskFromIdentity(); + } + if (m_useBodyHeadMask) { + m_bodyHeadMaskFrameset = getBodyHeadMaskFromIdentity(); + } } HumanoidIdentity const& Humanoid::identity() const { @@ -317,6 +323,8 @@ void Humanoid::loadConfig(Json merger) { m_feetOffset = jsonToVec2F(config.get("feetOffset")) / TilePixels; m_bodyFullbright = config.getBool("bodyFullbright", false); + m_useBodyMask = config.getBool("useBodyMask", false); + m_useBodyHeadMask = config.getBool("useBodyHeadMask", false); m_headArmorOffset = jsonToVec2F(config.get("headArmorOffset")) / TilePixels; m_chestArmorOffset = jsonToVec2F(config.get("chestArmorOffset")) / TilePixels; @@ -751,18 +759,32 @@ List<Drawable> Humanoid::render(bool withItems, bool withRotationAndScale) { } if (!m_bodyFrameset.empty() && !m_bodyHidden) { - String image; auto bodyDirectives = getBodyDirectives(); auto prefix = bodyDirectives.prefix(); + String framePrefix; if (dance.isValid() && danceStep->bodyFrame) - image = strf("{}:{}{}", m_bodyFrameset, *danceStep->bodyFrame, prefix); + framePrefix = strf("{}{}", *danceStep->bodyFrame, prefix); else if (m_state == Idle) - image = strf("{}:{}{}", m_bodyFrameset, m_identity.personality.idle, prefix); + framePrefix = strf("{}{}", m_identity.personality.idle, prefix); else - image = strf("{}:{}.{}{}", m_bodyFrameset, frameBase(m_state), bodyStateSeq, prefix); - auto drawable = Drawable::makeImage(std::move(image), 1.0f / TilePixels, true, {}); + framePrefix = strf("{}.{}{}", frameBase(m_state), bodyStateSeq, prefix); + String image = strf("{}:{}",m_bodyFrameset,framePrefix); + auto drawable = Drawable::makeImage(m_useBodyHeadMask ? image : std::move(image), 1.0f / TilePixels, true, {}); drawable.imagePart().addDirectives(bodyDirectives, true); + if (m_useBodyMask && !m_bodyMaskFrameset.empty()) { + String maskImage = strf("{}:{}",m_bodyMaskFrameset,framePrefix); + Directives maskDirectives = "?addmask="+maskImage+";0;0"; + drawable.imagePart().addDirectives(maskDirectives, true); + } addDrawable(std::move(drawable), m_bodyFullbright); + if (m_useBodyHeadMask && !m_bodyHeadMaskFrameset.empty()) { + String maskImage = strf("{}:{}",m_bodyHeadMaskFrameset,framePrefix); + Directives maskDirectives = "?addmask="+maskImage+";0;0"; + auto drawable = Drawable::makeImage(std::move(image), 1.0f / TilePixels, true, {}); + drawable.imagePart().addDirectives(bodyDirectives, true); + drawable.imagePart().addDirectives(maskDirectives, true); + addHeadDrawable(std::move(drawable), m_bodyFullbright); + } } if (!m_legsArmorFrameset.empty()) { @@ -1275,6 +1297,18 @@ String Humanoid::getBodyFromIdentity() const { GenderNames.getRight(m_identity.gender)); } +String Humanoid::getBodyMaskFromIdentity() const { + return strf("/humanoid/{}/mask/{}body.png", + m_identity.imagePath ? *m_identity.imagePath : m_identity.species, + GenderNames.getRight(m_identity.gender)); +} + +String Humanoid::getBodyHeadMaskFromIdentity() const { + return strf("/humanoid/{}/headmask/{}body.png", + m_identity.imagePath ? *m_identity.imagePath : m_identity.species, + GenderNames.getRight(m_identity.gender)); +} + String Humanoid::getFacialEmotesFromIdentity() const { return strf("/humanoid/{}/emote.png", m_identity.imagePath ? *m_identity.imagePath : m_identity.species); } diff --git a/source/game/StarHumanoid.hpp b/source/game/StarHumanoid.hpp index d11de1d..dc4f3d9 100644 --- a/source/game/StarHumanoid.hpp +++ b/source/game/StarHumanoid.hpp @@ -262,6 +262,8 @@ public: String getHeadFromIdentity() const; String getBodyFromIdentity() const; + String getBodyMaskFromIdentity() const; + String getBodyHeadMaskFromIdentity() const; String getFacialEmotesFromIdentity() const; String getHairFromIdentity() const; String getFacialHairFromIdentity() const; @@ -329,6 +331,9 @@ private: Vec2F m_chestArmorOffset; Vec2F m_legsArmorOffset; Vec2F m_backArmorOffset; + + bool m_useBodyMask; + bool m_useBodyHeadMask; bool m_bodyHidden; @@ -345,6 +350,8 @@ private: String m_headFrameset; String m_bodyFrameset; + String m_bodyMaskFrameset; + String m_bodyHeadMaskFrameset; String m_backArmFrameset; String m_frontArmFrameset; String m_emoteFrameset; |