Aggiunta pavimento
This commit is contained in:
+2
-1
@@ -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"
|
||||
#include "collections/headers/lower_body.hpp"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
#include "piece_interface.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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user