From 2dfd5748144461ccc41756e950fd8164686a8d76 Mon Sep 17 00:00:00 2001 From: Endert0m Date: Tue, 23 Jun 2026 11:31:19 +0200 Subject: [PATCH] =?UTF-8?q?Preparazione=20controllo=20visibilit=C3=A0=20co?= =?UTF-8?q?llezioni?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../headers/collection_interface.hpp | 7 ++ src/collections/headers/lower_body.hpp | 2 +- src/collections/methods/lower_body.cpp | 72 +++++++++---------- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/collections/headers/collection_interface.hpp b/src/collections/headers/collection_interface.hpp index db647de..3d9226f 100644 --- a/src/collections/headers/collection_interface.hpp +++ b/src/collections/headers/collection_interface.hpp @@ -11,10 +11,17 @@ struct collection{ class CollectionInterface{ + protected: + float transparency = 1.0; + bool isVisible = true; public: virtual collection create(ReferencePlane plane) = 0; virtual void update(sf::Clock cl, float multiplier) = 0; virtual bool setTransparency(float alpha) = 0; + float getTransparency() { + return transparency; + } + virtual bool setVisibility(bool c); virtual ~CollectionInterface(){}; }; diff --git a/src/collections/headers/lower_body.hpp b/src/collections/headers/lower_body.hpp index c9a31d4..5fa7a1c 100644 --- a/src/collections/headers/lower_body.hpp +++ b/src/collections/headers/lower_body.hpp @@ -34,7 +34,7 @@ public: Lower_Body(rb::Vector3 pos, std::vector data); ~Lower_Body(); void update(sf::Clock cl, float multiplier) override; - void setVisibility(bool c); + bool setVisibility(bool c) override; bool setTransparency(float alpha) override; collection create(ReferencePlane plane) override; }; diff --git a/src/collections/methods/lower_body.cpp b/src/collections/methods/lower_body.cpp index 5703af0..638a472 100644 --- a/src/collections/methods/lower_body.cpp +++ b/src/collections/methods/lower_body.cpp @@ -18,42 +18,43 @@ Lower_Body::Lower_Body(rb::Vector3 pos,std::vector data){ collection Lower_Body::create(ReferencePlane plane){ collection coll; - sx->setTransparency(1); - dx->setTransparency(1); - + sx->setTransparency(transparency); + dx->setTransparency(transparency); + t->setTransparency(transparency); - coll.joints.push_back(jsx); - coll.joints.push_back(jdx); + if (isVisible){ + coll.joints.push_back(jsx); + coll.joints.push_back(jdx); - switch (plane) - { - case ReferencePlane::XZN: - dx->setTransparency(0.5); - dx->setDirection(Direction::L); - sx->setDirection(Direction::R); - coll = coll + dx->create(plane); - coll = coll + sx->create(plane); - break; - case ReferencePlane::XZ: - sx->setTransparency(0.5); - dx->setDirection(Direction::R); - sx->setDirection(Direction::L); - coll = coll + sx->create(plane); - coll = coll + dx->create(plane); - break; - case ReferencePlane::YZ: - sx->setDirection(Direction::R); - dx->setDirection(Direction::L); - coll = coll + dx->create(plane); - coll = coll + sx->create(plane); - break; + switch (plane) + { + case ReferencePlane::XZN: + dx->setTransparency(0.5 * transparency); + dx->setDirection(Direction::L); + sx->setDirection(Direction::R); + coll = coll + dx->create(plane); + coll = coll + sx->create(plane); + break; + case ReferencePlane::XZ: + sx->setTransparency(0.5 * transparency); + dx->setDirection(Direction::R); + sx->setDirection(Direction::L); + coll = coll + sx->create(plane); + coll = coll + dx->create(plane); + break; + case ReferencePlane::YZ: + sx->setDirection(Direction::R); + dx->setDirection(Direction::L); + coll = coll + dx->create(plane); + coll = coll + sx->create(plane); + break; - default: - break; + default: + break; + } + + coll.pieces.push_back(t); } - - coll.pieces.push_back(t); - return coll; } @@ -65,14 +66,13 @@ Lower_Body::~Lower_Body(){ delete jsx; } -void Lower_Body::setVisibility(bool c){ +bool Lower_Body::setVisibility(bool c){ } bool Lower_Body::setTransparency(float alpha){ - if (!sx->setTransparency(alpha)) return false; - dx->setTransparency(alpha); - t->setTransparency(alpha); + if (alpha < 0 || alpha > 1) return false; + transparency = alpha; return true; }