14 Commits

36 changed files with 279 additions and 166 deletions
+2 -2
View File
@@ -53,9 +53,9 @@ target_compile_options(common INTERFACE
set(METHODS_PATH "./src/*/methods/*.cpp")
set(VERSION "V8")
set(VERSION "V10")
file(GLOB_RECURSE METHODS_SRC "${METHODS_PATH}")
add_executable(main${VERSION} ./src/testMain.cpp ${METHODS_SRC} )
add_executable(main${VERSION} ./src/Main.cpp ${METHODS_SRC} )
target_link_libraries(main${VERSION} PRIVATE SFML::Graphics ImGui-SFML::ImGui-SFML common glm)
target_compile_definitions(main${VERSION} PRIVATE $<$<CONFIG:Debug>:DEBUG_MODE>)
+11 -1
View File
@@ -54,10 +54,20 @@ Per spostare l'intera scena si tiene premuto il tasto centrale del mouse.
- Aggiunta oscillazione bacino
- Aggiustato calcolo posizione con clock dedicato
## Nella versione v0.9
- Modificata la funzione update di pezzi e collezioni per implementare controllo sul tempo
- Aggiunta finestra con slider per selezione moltiplicatore del tempo
## Nella versione v0.10
- Aggiunta controllo texture
- Aggiunta pavimento
- Refactoring generale
- Definizione main finale (non più di test)
# Per compilare:
cmake --build
# Per lanciare:
./build/bin/mainV8
./build/bin/mainV10
+8 -3
View File
@@ -5,6 +5,7 @@ Size=400,400
[Window][Dear ImGui Demo]
Pos=487,44
Size=455,873
Collapsed=1
[Window][Hello, world!]
Pos=11,12
@@ -23,8 +24,8 @@ Pos=68,96
Size=740,472
[Window][Set data position]
Pos=0,670
Size=800,30
Pos=0,732
Size=924,30
[Window][Dear ImGui Demo/ResizableChild_478B81A3]
IsChild=1
@@ -39,6 +40,10 @@ Pos=60,60
Size=353,1005
[Window][Set visualization plane]
Pos=400,0
Pos=524,0
Size=400,30
[Window][Set time multiplier]
Pos=524,702
Size=400,30
Binary file not shown.
Binary file not shown.
+77
View File
@@ -0,0 +1,77 @@
#include "include.hpp"
int main() {
CSVProcessor processor;
// inizializzo variabili per gestire l'intervallo di visualizzazione
unsigned int min = 0;
unsigned int pos = 0;
unsigned int maj = 100;
//Costruisco la GUI
State gs(800, 700, "Visualizzatore passo",&maj,&min,&pos);
gs.window.setFramerateLimit(70);
printf("Costruisco gli oggetti\n");
try{
processor.readCSVFile (DATA_PATH + "coscia_filt.csv"); //utilizzo questo file per definire la dimensione dei dati
const auto& coscia = processor.getData();
gs.setIntervall(coscia.size());
//provo ad aggiungere una collection
//gs.collections.push_back(new Gamba({220,0,220},&pos,"coscia_filt.csv","caviglia_filt.csv"));
std::vector<gamba_data> data;
gamba_data d;
d.dataPos = &pos;
d.cavigliaData = "caviglia_dx.csv";
d.cosciaData = "coscia_dx.csv";
gamba_data s;
s.dataPos = &pos;
s.cavigliaData = "caviglia_sx.csv";
s.cosciaData = "coscia_sx.csv";
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},_Float16(0.2) ));
gs.pieces[0]->body.setRot({0,-0.03,0});
printf("Ho costruito tutto!\n");
}
catch(char* e){
printf("%s\n",e);
}
printf("Avvio l'interfaccia grafica\n");
unsigned int curTime = 0;
unsigned int freq = 50; //frequenza campionamento sensori
const unsigned int T = 1000/freq; //i sensori hanno una freq di campionamento di 50hz
//Avvio il loop della GUI
gs.clock.start();
gs.updateCollections();
sf::Clock mainClock;
while (gs.window.isOpen())
{
curTime += mainClock.restart().asMilliseconds() *(*gs.tMul) ;
if (curTime > T){
if (gs.play && pos+curTime/T < maj) pos += curTime / T;
curTime = 0;
}
// Show update
gs.update();
doGraphics(gs);
}
return 0;
}
@@ -13,7 +13,7 @@ struct collection{
class CollectionInterface{
public:
virtual collection create(ReferencePlane plane) = 0;
virtual void update(sf::Clock cl) = 0;
virtual void update(sf::Clock cl, float multiplier) = 0;
virtual bool setTransparency(float alpha) = 0;
virtual ~CollectionInterface(){};
};
+1 -1
View File
@@ -15,7 +15,7 @@ class Gamba : public CollectionInterface {
PieceInterface* getJointPiece();
void setDirection(Direction dir);
bool setTransparency(float alpha) override;
void update(sf::Clock cl)override {};
void update(sf::Clock cl, float multiplier)override {};
float getZ_Acc();
};
+1 -1
View File
@@ -33,7 +33,7 @@ protected:
public:
Lower_Body(rb::Vector3 pos, std::vector<gamba_data> data);
~Lower_Body();
void update(sf::Clock cl) override;
void update(sf::Clock cl, float multiplier) override;
void setVisibility(bool c);
bool setTransparency(float alpha) override;
collection create(ReferencePlane plane) override;
+1 -1
View File
@@ -76,7 +76,7 @@ bool Lower_Body::setTransparency(float alpha){
return true;
}
void Lower_Body::update(sf::Clock cl){
void Lower_Body::update(sf::Clock cl, float multiplier){
float sxAcc = sx->getZ_Acc() ;
float dxAcc = dx->getZ_Acc() ;
+1
View File
@@ -5,6 +5,7 @@
#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"
+5 -2
View File
@@ -3,18 +3,21 @@
#ifndef CAVIGLIA_H
#define CAVIGLIA_H
class Caviglia : public PieceInterface{
private:
const sf::Vector3f caviglia_Dim = {60, 200, 60};
const sf::Color caviglia_Col = sf::Color(230,160,11,255);
const std::string TEXTURE_F = std::string("cavigliaF.png");
const std::string TEXTURE_L = std::string("cavigliaL.png");
public:
Caviglia(rb::Vector3 coords, _Float16 mass);
~Caviglia();
void update(sf::Clock cl) override;
void update(sf::Clock cl, float multiplier) override;
sf::Shape* draw(ReferencePlane plane) override;
};
+5 -1
View File
@@ -5,17 +5,21 @@
class Coscia : public PieceInterface{
private:
const sf::Vector3f coscia_Dim = {80, 200, 80};
const sf::Color coscia_Col = sf::Color::Yellow;
const std::string TEXTURE_F = std::string("cosciaF.png");
const std::string TEXTURE_L = std::string("cosciaL.png");
public:
Coscia(rb::Vector3 coords, _Float16 mass);
~Coscia();
void update(sf::Clock cl) override;
void update(sf::Clock cl, float multiplier) override;
sf::Shape* draw(ReferencePlane plane) override;
};
-1
View File
@@ -1 +0,0 @@
#include "piece_interface.hpp"
+25
View File
@@ -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, 40, 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
+18 -1
View File
@@ -2,6 +2,7 @@
#include <math.h>
#include "../../rigidbody/headers/rb.hpp"
#define TEXTUREPATH std::string("./../../textures/")
#ifndef PIECE_INTERFACE_H
#define PIECE_INTERFACE_H
@@ -31,6 +32,22 @@ class PieceInterface{
shapeYZ->setFillColor(color);
}
Direction direction = Direction::L;
sf::Texture TextureF ;
sf::Texture TextureL ;
void setTextures (std::string F, std::string L){
try{
TextureF = sf::Texture(TEXTUREPATH + F);
TextureL = sf::Texture(TEXTUREPATH + L);
shapeXZ->setTexture(&TextureL);
shapeYZ->setTexture(&TextureF);
}catch(...){
throw "Errore nel caricamento texture.";
}
}
public:
sf::Shape* shapeXZ, *shapeYZ;
rb::Vector3 globalPos;
@@ -38,7 +55,7 @@ class PieceInterface{
sf::Color color;
float transparency = 1.0; //canale alpha del pezzo
virtual void update(sf::Clock cl) = 0;
virtual void update(sf::Clock cl, float multiplier) = 0;
virtual sf::Shape* draw(ReferencePlane plane) = 0;
virtual ~PieceInterface(){}
virtual void setDirection(Direction dir){
+2 -2
View File
@@ -7,7 +7,7 @@
class Sensore : public PieceInterface{
private:
const sf::Vector3f sensore_Dim = {30, 60, 30};
const sf::Vector3f sensore_Dim = {15, 20, 15};
const sf::Color sensore_Col = sf::Color::Red;
std::vector<std::vector<float>> accData;
@@ -29,7 +29,7 @@ class Sensore : public PieceInterface{
Sensore(rb::Vector3 coords, _Float16 mass, unsigned int* st, std::vector<std::vector<float>> data);
~Sensore();
void update(sf::Clock cl) override;
void update(sf::Clock cl,float multiplier) override;
sf::Shape* draw(ReferencePlane plane) override;
//funzioni specifiche
+5 -3
View File
@@ -4,17 +4,19 @@
#define TORSO_H
class Torso : public PieceInterface{
private:
const sf::Vector3f torso_Dim = {100, 100, 150};
const sf::Color torso_Col = sf::Color::Red;
const std::string TEXTURE_F = std::string("bacinoF.png");
const std::string TEXTURE_L = std::string("bacinoL.png");
public:
Torso(rb::Vector3 coords, _Float16 mass);
~Torso();
void update(sf::Clock cl) override;
void update(sf::Clock cl, float multiplier) override;
sf::Shape* draw(ReferencePlane plane) override;
};
+11 -3
View File
@@ -7,6 +7,13 @@ Caviglia::Caviglia(rb::Vector3 coords, _Float16 mass){
globalPos = {0,0,0};
initialize_shapes(caviglia_Dim);
try{
setTextures(TEXTURE_F,TEXTURE_L);
}
catch (const char* &e ){
printf("Caviglia: %s\n", e);
}
}
@@ -15,7 +22,7 @@ Caviglia::~Caviglia(){
delete shapeYZ;
}
void Caviglia::update(sf::Clock cl){
void Caviglia::update(sf::Clock cl,float multiplier){
//body.step(cl);
}
@@ -31,8 +38,9 @@ sf::Shape* Caviglia::draw(ReferencePlane plane){
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->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;
@@ -41,7 +49,7 @@ sf::Shape* Caviglia::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->setScale({1,cos(float(tmpRot[1]))});
shape->setScale({direction == Direction::R ? float(1.0) : float(-1.0),cos(float(tmpRot[1]))});
shape->setFillColor(color*sf::Color(255,255,255,transparency*255));
return shape;}
break;
+10 -3
View File
@@ -6,6 +6,13 @@ Coscia::Coscia(rb::Vector3 coords, _Float16 mass){
color = coscia_Col;
globalPos = {0,0,0};
initialize_shapes(coscia_Dim);
try{
setTextures(TEXTURE_F,TEXTURE_L);
}
catch (const char* &e ){
printf("Coscia: %s\n", e);
}
}
Coscia::~Coscia(){
@@ -13,7 +20,7 @@ Coscia::~Coscia(){
delete shapeYZ;
}
void Coscia::update(sf::Clock cl){
void Coscia::update(sf::Clock cl, float multiplier){
//body.step(cl);
}
@@ -30,7 +37,7 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
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->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;
@@ -41,7 +48,7 @@ sf::Shape* Coscia::draw(ReferencePlane plane){
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]))});
shape->setScale({direction == Direction::R ? float(1.0) : float(-1.0),cos(float(tmpRot[1]))});
return shape;}
break;
+57
View File
@@ -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;
}
+5 -3
View File
@@ -49,7 +49,7 @@ void Sensore::initCSV(std::vector<std::vector<float>> data){
}
void Sensore::update(sf::Clock cl){
void Sensore::update(sf::Clock cl, float multiplier){
//calcolo la posizione e velocità
if (*dataPos >= gData.size()) *dataPos = gData.size()-1;
@@ -58,7 +58,7 @@ void Sensore::update(sf::Clock cl){
body.setAcc(rb::Vector3{accData[*dataPos]});
body.step(cl);
body.step(cl, multiplier);
}
@@ -76,6 +76,7 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
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));
shape->setScale({plane == ReferencePlane::XZ ? float(1.0) : float(-1.0),1});
return shape;}
break;
@@ -85,6 +86,7 @@ sf::Shape* Sensore::draw(ReferencePlane plane){
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({direction == Direction::R ? float(1.0) : float(-1.0),1});
return shape;}
break;
@@ -115,7 +117,7 @@ void Sensore::calcRotWithG(unsigned int index){ // calcolo rotazione con valori
}
float Sensore::getZ_Acc(){
int id = *dataPos;
//int id = *dataPos;
float tmpAcc = 0;
rb::Vector3 acc = body.getAcc();
+9 -1
View File
@@ -7,6 +7,13 @@ Torso::Torso(rb::Vector3 coords, _Float16 mass){
globalPos = {0,0,0};
initialize_shapes(torso_Dim);
try{
setTextures(TEXTURE_F,TEXTURE_L);
}
catch (const char* &e){
printf("Caviglia: %s\n", e);
}
}
Torso::~Torso(){
@@ -14,7 +21,7 @@ Torso::~Torso(){
delete shapeYZ;
}
void Torso::update(sf::Clock cl){
void Torso::update(sf::Clock cl,float multiplier){
}
@@ -31,6 +38,7 @@ sf::Shape* Torso::draw(ReferencePlane plane){
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;
+1 -1
View File
@@ -49,7 +49,7 @@
void setVel(const Vector3 Nacc);
void setAcc(const Vector3 Nvel);
void setTanAcc(const Vector3 Dacc);
void step(const sf::Clock time);
void step(const sf::Clock time, float multiplier);
//complesso, deve definire accelerazione e accelerazione tangenziale
void appForce(Vector3 f, Vector3 pos);
+2 -2
View File
@@ -85,12 +85,12 @@ void rigidbody::calcPos(const float Dtime){
}
}
void rigidbody::step(const sf::Clock time){
void rigidbody::step(const sf::Clock time, float multiplier){
int64_t Dtime = time.getElapsedTime().asMicroseconds();
if (prevT == 0) prevT = Dtime;
float dt = (float(Dtime) / 1000000.0) - (float(prevT) / 1000000.0);
float dt = ((float(Dtime) / 1000000.0) - (float(prevT) / 1000000.0)) * multiplier;
prevT = Dtime;
calcRot(dt);
+19 -9
View File
@@ -29,11 +29,11 @@ struct State
sf::Vector2f cameraOffset = {0.,0.};
sf::Clock clock;
float* tMul;
sf::Clock PieceClock;
ReferencePlane selectedPlane = ReferencePlane::XZ;
PieceInterface* selected = nullptr;
bool rot_Piece = false;
bool drag_Piece = false;
bool drag = false;
@@ -51,6 +51,7 @@ struct State
window = sf::RenderWindow(sf::VideoMode({w, h}), title);
if (ImGui::SFML::Init(window)); // L'if è solo per togliere il warning, va aggiustato gestendo le eccezioni
clock.restart();
tMul = new float(1.0);
PieceClock.restart();
intervalMajLimit = maj;
intervalMinLimit = min;
@@ -68,6 +69,9 @@ struct State
createdColl.push_back(c->create(selectedPlane));
}
}
~State(){
delete tMul;
}
};
///
@@ -84,14 +88,14 @@ void State::update(){
*/
if (play){
for (auto i : collections){
i->update(PieceClock);
i->update(PieceClock, *tMul);
}
}
for (auto i : createdColl){
if (play){
for (auto j : i.pieces){
j->update(PieceClock);
j->update(PieceClock, *tMul);
}
}
for (auto j : i.joints){
@@ -101,7 +105,7 @@ void State::update(){
if (play){
for(PieceInterface* p : pieces){
p->update(PieceClock);
p->update(PieceClock, *tMul);
}
}
for(JointInterface* j : joints){
@@ -283,14 +287,12 @@ void handle_resize(const sf::Event::Resized &resized, State &gs)
/// Graphics
void doGUI(State &gs)
{
// TODO: here code to display the menus
//Bottoni
sf::Time elapsed = gs.clock.restart();
unsigned int zero = 0;
ImGui::SFML::Update(gs.window, elapsed);
ImGui::ShowDemoWindow();
//Finestra gestione posizione nei dati
ImGuiWindowFlags sdp_flags = ImGuiWindowFlags_NoMove|
@@ -331,15 +333,21 @@ void doGUI(State &gs)
gs.selectedPlane = (ReferencePlane)currentPlane;
gs.updateCollections();
}
ImGui::End();
/*////// DA FARE ///////*/
//Finestra gestione velocità di riproduzione
ImGui::Begin("Set time multiplier", 0,sdp_flags);
const float TimeMul[] = {0.5, 0.75, 1, 1.25, 1.5};
const char* TimeMulChar[] = {"0.5", "0.75", "1", "1.25", "1.5"};
static int Timeid = 2;
ImGui::SliderInt("Time", &Timeid,0,4,TimeMulChar[Timeid]);
*gs.tMul = TimeMul[Timeid];
ImGui::End();
//Finestra controllo sovrapposizione
ImGui::End();
sf::Vector2u wsize = gs.window.getSize();
@@ -347,6 +355,8 @@ void doGUI(State &gs)
ImGui::SetWindowSize("Set data position",ImVec2(wsize.x,30));
ImGui::SetWindowPos("Set visualization plane",ImVec2(wsize.x-400,0));
ImGui::SetWindowSize("Set visualization plane",ImVec2(400,30));
ImGui::SetWindowPos("Set time multiplier",ImVec2(wsize.x-400,wsize.y - 60));
ImGui::SetWindowSize("Set time multiplier",ImVec2(400,30));
ImGui::SFML::Render(gs.window);
}
-122
View File
@@ -1,122 +0,0 @@
#include "include.hpp"
int main() {
CSVProcessor processor;
try {
processor.readCSVFile("data.csv");
// Access headers
const auto& headers = processor.getHeaders();
for (const auto& header : headers) {
std::cout << header << "\t";
}
std::cout << std::endl;
// Access data
int n = 0;
const auto& data = processor.getData();
for (const auto& row : data) {
if (n++ >40) break;
for (float value : row) {
std::cout << value << "\t";
}
std::cout << std::endl;
}
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
// inizializzo variabili per gestire l'intervallo di visualizzazione
unsigned int min = 0;
unsigned int pos = 0;
unsigned int maj = 100;
//Costruisco la GUI
State gs(800, 700, "Visualizzatore passo",&maj,&min,&pos);
gs.window.setFramerateLimit(70);
printf("Costruisco gli oggetti\n");
try{
processor.readCSVFile (DATA_PATH + "coscia_filt.csv");
const auto& coscia = processor.getData();
gs.setIntervall(coscia.size());
/*
gs.pieces.push_back(new Coscia (rb::Vector3{0,0,0},2));
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,300},_Float16( 0.2 ),&pos,coscia));
gs.pieces.push_back(new Caviglia (rb::Vector3{300,300,500},1));
gs.pieces[1]->body.setRot({0,0,0});
processor.readCSVFile(DATA_PATH + "caviglia_filt.csv");
const auto& caviglia = processor.getData();
gs.pieces.push_back(new Sensore (rb::Vector3{300,300,500},_Float16( 0.2 ),&pos,caviglia));
gs.pieces.push_back(new Torso(rb::Vector3{300,400,150},2));
// modifico la rotazione relativa della gamba
gs.pieces[1]->body.setRot({_Float16 (1.3),_Float16 (1.7),0});
gs.pieces[3]->body.setRot({_Float16 (1.8),_Float16 (1.7),0});
// aggiungo i joint
gs.joints.push_back(new PivotJoint(gs.pieces[4], {gs.pieces[1]}, rb::Vector3{0,-100,50}));
gs.joints.push_back(new RigidJoint(gs.pieces[1], {gs.pieces[0]}));
gs.joints.push_back(new PivotJoint(gs.pieces[1], {gs.pieces[3]}, rb::Vector3{0,0,100}));
gs.joints.push_back(new RigidJoint(gs.pieces[3], {gs.pieces[2]}));
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"));
std::vector<gamba_data> data;
gamba_data d;
d.dataPos = &pos;
d.cavigliaData = "caviglia_dx.csv";
d.cosciaData = "coscia_dx.csv";
gamba_data s;
s.dataPos = &pos;
s.cavigliaData = "caviglia_sx.csv";
s.cosciaData = "coscia_sx.csv";
data.push_back(d);
data.push_back(s);
gs.collections.push_back(new Lower_Body(rb::Vector3{200,200,100},data));
printf("Ho costruito tutto!\n");
}
catch(char* e){
printf("%s\n",e);
}
printf("Avvio l'interfaccia grafica\n");
unsigned int curTime = 0;
unsigned int freq = 50;
const unsigned int T = 1000/freq; //i sensori hanno una freq di campionamento di 50hz
//Avvio il loop della GUI
gs.clock.start();
gs.updateCollections();
sf::Clock mainClock;
while (gs.window.isOpen())
{
curTime += mainClock.restart().asMilliseconds();
if (curTime > T){
if (gs.play && pos+curTime/T < maj) pos += curTime / T;
curTime = 0;
}
// Show update
gs.update();
doGraphics(gs);
}
return 0;
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB