Aggiunta selezione trasparenza pezzi

This commit is contained in:
2026-06-20 09:42:32 +02:00
parent a2eee90e10
commit 83f132a1c4
5 changed files with 14 additions and 11 deletions
Binary file not shown.
+5
View File
@@ -36,6 +36,7 @@ class PieceInterface{
rb::Vector3 globalPos; rb::Vector3 globalPos;
rb::rigidbody body; rb::rigidbody body;
sf::Color color; sf::Color color;
float transparency = 1.0; //canale alpha del pezzo
virtual void update(sf::Clock cl) = 0; virtual void update(sf::Clock cl) = 0;
virtual sf::Shape* draw(ReferencePlane plane) = 0; virtual sf::Shape* draw(ReferencePlane plane) = 0;
@@ -43,6 +44,10 @@ class PieceInterface{
virtual void setDirection(Direction dir){ virtual void setDirection(Direction dir){
direction = dir; direction = dir;
} }
virtual bool setTransparency(float alpha){
if (alpha < 0 || alpha > 1) return false;
transparency = alpha;
}
}; };
+3 -1
View File
@@ -26,12 +26,13 @@ sf::Shape* Caviglia::draw(ReferencePlane plane){
switch (plane) switch (plane)
{ {
case ReferencePlane::XZ: case ReferencePlane::XZ : case ReferencePlane::XZN:
{ {
sf::Shape* shape = shapeXZ; sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
shape->setScale({1,cos(float(tmpRot[0]))}); shape->setScale({1,cos(float(tmpRot[0]))});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;} return shape;}
break; break;
@@ -41,6 +42,7 @@ sf::Shape* Caviglia::draw(ReferencePlane plane){
shape->setRotation(sf::Angle(sf::radians(tmpRot[0]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
shape->setScale({1,cos(float(tmpRot[1]))}); shape->setScale({1,cos(float(tmpRot[1]))});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;} return shape;}
break; break;
+3 -9
View File
@@ -25,17 +25,13 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
switch (plane) switch (plane)
{ {
case ReferencePlane::XZ: case ReferencePlane::XZ : case ReferencePlane::XZN:
{ {
sf::Shape* shape = shapeXZ; sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
//calcolo ridimensionamento dato da cos(x)-> questo per definire l'ancoraggio corretto del pivot
shape->setScale({1,cos(float(tmpRot[0]))}); shape->setScale({1,cos(float(tmpRot[0]))});
//shape->setScale({1,(0.5* cos(float(tmpRot[0]*2)))+0.5}); shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;} return shape;}
break; break;
@@ -44,10 +40,8 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
sf::Shape* shape = shapeYZ; sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[0]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
//calcolo ridimensionamento dato da cos(x) -> questo per definire l'ancoraggio corretto del pivot
shape->setScale({1,cos(float(tmpRot[1]))}); shape->setScale({1,cos(float(tmpRot[1]))});
//shape->setScale({1,(0.5* cos(float(tmpRot[1]*2)))+0.5});
return shape;} return shape;}
break; break;
+3 -1
View File
@@ -60,12 +60,13 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
switch (plane) switch (plane)
{ {
case ReferencePlane::XZ: case ReferencePlane::XZ : case ReferencePlane::XZN:
{ {
sf::Shape* shape = shapeXZ; sf::Shape* shape = shapeXZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[1]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;} return shape;}
break; break;
@@ -74,6 +75,7 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
sf::Shape* shape = shapeYZ; sf::Shape* shape = shapeYZ;
shape->setRotation(sf::Angle(sf::radians(tmpRot[0]))); shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]}); shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;} return shape;}
break; break;