Aggiunta selezione trasparenza pezzi
This commit is contained in:
Binary file not shown.
@@ -36,6 +36,7 @@ class PieceInterface{
|
||||
rb::Vector3 globalPos;
|
||||
rb::rigidbody body;
|
||||
sf::Color color;
|
||||
float transparency = 1.0; //canale alpha del pezzo
|
||||
|
||||
virtual void update(sf::Clock cl) = 0;
|
||||
virtual sf::Shape* draw(ReferencePlane plane) = 0;
|
||||
@@ -43,6 +44,10 @@ class PieceInterface{
|
||||
virtual void setDirection(Direction dir){
|
||||
direction = dir;
|
||||
}
|
||||
virtual bool setTransparency(float alpha){
|
||||
if (alpha < 0 || alpha > 1) return false;
|
||||
transparency = alpha;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@ sf::Shape* Caviglia::draw(ReferencePlane plane){
|
||||
|
||||
switch (plane)
|
||||
{
|
||||
case ReferencePlane::XZ:
|
||||
case ReferencePlane::XZ : case ReferencePlane::XZN:
|
||||
{
|
||||
sf::Shape* shape = shapeXZ;
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
|
||||
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
|
||||
shape->setScale({1,cos(float(tmpRot[0]))});
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
@@ -41,6 +42,7 @@ sf::Shape* Caviglia::draw(ReferencePlane plane){
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
|
||||
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
|
||||
shape->setScale({1,cos(float(tmpRot[1]))});
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
|
||||
@@ -25,17 +25,13 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
|
||||
|
||||
switch (plane)
|
||||
{
|
||||
case ReferencePlane::XZ:
|
||||
case ReferencePlane::XZ : case ReferencePlane::XZN:
|
||||
{
|
||||
sf::Shape* shape = shapeXZ;
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
|
||||
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,(0.5* cos(float(tmpRot[0]*2)))+0.5});
|
||||
|
||||
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
@@ -44,10 +40,8 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
|
||||
sf::Shape* shape = shapeYZ;
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
|
||||
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
|
||||
|
||||
//calcolo ridimensionamento dato da cos(x) -> questo per definire l'ancoraggio corretto del pivot
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
shape->setScale({1,cos(float(tmpRot[1]))});
|
||||
//shape->setScale({1,(0.5* cos(float(tmpRot[1]*2)))+0.5});
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
|
||||
@@ -60,12 +60,13 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
|
||||
|
||||
switch (plane)
|
||||
{
|
||||
case ReferencePlane::XZ:
|
||||
case ReferencePlane::XZ : case ReferencePlane::XZN:
|
||||
{
|
||||
|
||||
sf::Shape* shape = shapeXZ;
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[1])));
|
||||
shape->setPosition({tmpPos[0]+globalPos[0],tmpPos[2]+globalPos[2]});
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
@@ -74,6 +75,7 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
|
||||
sf::Shape* shape = shapeYZ;
|
||||
shape->setRotation(sf::Angle(sf::radians(tmpRot[0])));
|
||||
shape->setPosition({tmpPos[1]+globalPos[1],tmpPos[2]+globalPos[2]});
|
||||
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
|
||||
return shape;}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user