diff --git a/build/bin/mainV10.exe b/build/bin/mainV10.exe index 3fd404f..0083684 100644 Binary files a/build/bin/mainV10.exe and b/build/bin/mainV10.exe differ diff --git a/src/include.hpp b/src/include.hpp index a2485f5..a2e1ac2 100644 --- a/src/include.hpp +++ b/src/include.hpp @@ -5,7 +5,8 @@ #include "pieces/headers/caviglia.hpp" #include "pieces/headers/sensore.hpp" #include "pieces/headers/torso.hpp" +#include "pieces/headers/pavimento.hpp" #include "joints/headers/rigid_joint.hpp" #include "joints/headers/pivot_joint.hpp" #include "collections/headers/gamba.hpp" -#include "collections/headers/lower_body.hpp" \ No newline at end of file +#include "collections/headers/lower_body.hpp" diff --git a/src/pieces/headers/joint_piece.hpp b/src/pieces/headers/joint_piece.hpp deleted file mode 100644 index df4a2e1..0000000 --- a/src/pieces/headers/joint_piece.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "piece_interface.hpp" \ No newline at end of file diff --git a/src/pieces/headers/pavimento.hpp b/src/pieces/headers/pavimento.hpp new file mode 100644 index 0000000..b35749f --- /dev/null +++ b/src/pieces/headers/pavimento.hpp @@ -0,0 +1,25 @@ +#include "piece_interface.hpp" + + +#ifndef PAVIMENTO_H +#define PAVIMENTO_H + +class Pavimento : public PieceInterface{ + private: + const sf::Vector3f pavimento_Dim = {600, 20, 600}; + const sf::Color pavimento_Col = sf::Color(255,255,255,255); + + const std::string TEXTURE_F = std::string("pavimentoF.png"); + const std::string TEXTURE_L = std::string("pavimentoL.png"); + + + public: + + Pavimento(rb::Vector3 coords, _Float16 mass); + ~Pavimento(); + + void update(sf::Clock cl, float multiplier) override {}; + sf::Shape* draw(ReferencePlane plane) override; +}; + +#endif \ No newline at end of file diff --git a/src/pieces/methods/coscia_class.cpp b/src/pieces/methods/coscia_class.cpp index 716e030..834bcc2 100644 --- a/src/pieces/methods/coscia_class.cpp +++ b/src/pieces/methods/coscia_class.cpp @@ -11,7 +11,7 @@ Coscia::Coscia(rb::Vector3 coords, _Float16 mass){ setTextures(TEXTURE_F,TEXTURE_L); } catch (const char* &e ){ - printf("Caviglia: %s\n", e); + printf("Coscia: %s\n", e); } } diff --git a/src/pieces/methods/pavimento.cpp b/src/pieces/methods/pavimento.cpp new file mode 100644 index 0000000..c80c6c6 --- /dev/null +++ b/src/pieces/methods/pavimento.cpp @@ -0,0 +1,57 @@ +#include "../headers/pavimento.hpp" + +Pavimento::Pavimento(rb::Vector3 coords, _Float16 mass){ + rb::Vector3 com = {pavimento_Dim.x/2,pavimento_Dim.z/2,pavimento_Dim.y/2}; + body = rb::rigidbody(coords, com, mass, pavimento_Dim.z/2); + color = pavimento_Col; + globalPos = {0,0,0}; + initialize_shapes(pavimento_Dim); + + try{ + setTextures(TEXTURE_F,TEXTURE_L); + } + catch (const char* &e ){ + printf("Pavimento: %s\n", e); + } +} + +Pavimento::~Pavimento(){ + delete shapeXZ; + delete shapeYZ; +} + + sf::Shape* Pavimento::draw(ReferencePlane plane){ + + rb::Vector3 tmpPos = body.getPos(); + rb::Vector3 tmpRot = body.getRot(); + + + switch (plane) + { + 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({plane == ReferencePlane::XZ ? float(1.0) : float(-1.0),cos(float(tmpRot[0]))}); + shape->setFillColor(color*sf::Color(255,255,255,transparency*255)); + return shape;} + break; + + case ReferencePlane::YZ: + { + 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)); + shape->setScale({1,cos(float(tmpRot[1]))}); + return shape;} + break; + + default: + break; + } + + + return nullptr; + } \ No newline at end of file diff --git a/src/testMain.cpp b/src/testMain.cpp index 4d53cd8..123d775 100755 --- a/src/testMain.cpp +++ b/src/testMain.cpp @@ -71,6 +71,11 @@ int main() { gs.pieces[2]->setDirection(Direction::R); */ + + + + + //provo ad aggiungere una collection //gs.collections.push_back(new Gamba({220,0,220},&pos,"coscia_filt.csv","caviglia_filt.csv")); @@ -86,6 +91,11 @@ int main() { data.push_back(d); data.push_back(s); gs.collections.push_back(new Lower_Body(rb::Vector3{200,200,100},data)); + + + + //aggiungo il pavimento + gs.pieces.push_back(new Pavimento({200,200,550},0.2)); printf("Ho costruito tutto!\n"); }