Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f74155e9f7 | |||
| 68b9d89c12 | |||
| 1dd7ce812a | |||
| 276e00aee1 | |||
| d2a0256a3e | |||
| 4e763fc2af | |||
| 818677f831 | |||
| 37619774f2 | |||
| 821dd67b5b | |||
| 4ac25779bd |
@@ -53,9 +53,9 @@ target_compile_options(common INTERFACE
|
||||
|
||||
set(METHODS_PATH "./src/*/methods/*.cpp")
|
||||
|
||||
set(VERSION "V9")
|
||||
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>)
|
||||
@@ -58,10 +58,16 @@ Per spostare l'intera scena si tiene premuto il tasto centrale del mouse.
|
||||
- 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/mainV9
|
||||
./build/bin/mainV10
|
||||
|
||||
@@ -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,10 +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=400,640
|
||||
Pos=524,702
|
||||
Size=400,30
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void Lower_Body::update(sf::Clock cl, float multiplier){
|
||||
float dxAcc = dx->getZ_Acc() ;
|
||||
|
||||
int64_t Dtime = cl.getElapsedTime().asMicroseconds();
|
||||
if (prevT == 0) prevT >= Dtime;
|
||||
if (prevT == 0) prevT = Dtime;
|
||||
float dt = (float(Dtime) / 1000000.0) - (float(prevT) / 1000000.0);
|
||||
prevT = Dtime;
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
#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:
|
||||
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -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, 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
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
#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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(){
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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(){
|
||||
@@ -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;
|
||||
|
||||
@@ -87,7 +87,7 @@ void rigidbody::calcPos(const float Dtime){
|
||||
|
||||
void rigidbody::step(const sf::Clock time, float multiplier){
|
||||
int64_t Dtime = time.getElapsedTime().asMicroseconds();
|
||||
if (prevT == 0) prevT >= Dtime;
|
||||
if (prevT == 0) prevT = Dtime;
|
||||
|
||||
|
||||
float dt = ((float(Dtime) / 1000000.0) - (float(prevT) / 1000000.0)) * multiplier;
|
||||
|
||||
@@ -287,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|
|
||||
|
||||
@@ -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() *(*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;
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 11 KiB |