diff --git a/build/bin/mainV8.exe b/build/bin/mainV8.exe index 72e167f..b1fbe91 100644 Binary files a/build/bin/mainV8.exe and b/build/bin/mainV8.exe differ diff --git a/src/collections/methods/lower_body.cpp b/src/collections/methods/lower_body.cpp index 756abe6..d24cf53 100644 --- a/src/collections/methods/lower_body.cpp +++ b/src/collections/methods/lower_body.cpp @@ -78,7 +78,7 @@ bool Lower_Body::setTransparency(float alpha){ void Lower_Body::update(sf::Clock cl){ float sxAcc = sx->getZ_Acc() * 10; - float dxAcc = dx->getZ_Acc() * 10000; + float dxAcc = dx->getZ_Acc(); //float totAcc = sxAcc + dxAcc; //t->body.setTanAcc({0,totAcc,0}); // non funziona, cambio sistema @@ -86,6 +86,8 @@ void Lower_Body::update(sf::Clock cl){ /* Posso considerare lo spostamento come A*sin(alpha)*/ /* Mi calcolo le velocità totali sull'asse z */ + printf("Acc: %f\n", dxAcc); + int64_t Dtime = cl.getElapsedTime().asMicroseconds(); if (prevT == 0) prevT = Dtime; float dt = (float(Dtime) / 1000000.0) - (float(prevT) / 1000000.0); @@ -94,9 +96,15 @@ void Lower_Body::update(sf::Clock cl){ float tmpVelS = sxAcc*dt; float tmpVelD = dxAcc*dt; - float tmpPosD = velD *dt ; + printf("Vel: %f\n", tmpVelD); + + + float tmpPosD = velD *dt *100 ; float tmpPosS = velS * 100 * dt + tmpVelD * 100 *dt; + + printf("DPos: %f\n\n", tmpPosD); + velD += tmpVelD; velS += tmpVelS; posD += tmpPosD; @@ -106,7 +114,7 @@ void Lower_Body::update(sf::Clock cl){ float alpha = asin(posD/60.0); t->body.setRot({alpha,0,0}); - //auto tPos = t->body.getPos(); - //t->body.setPos({tPos[0],tPos[1],tPos[2]+tmpPosD}); + auto tPos = t->body.getPos(); + //t->body.setPos({tPos[0],tPos[1],tPos[2]+posD}); } \ No newline at end of file diff --git a/src/sfml_util.cpp b/src/sfml_util.cpp index 0979824..da3d2fd 100644 --- a/src/sfml_util.cpp +++ b/src/sfml_util.cpp @@ -29,6 +29,7 @@ struct State sf::Vector2f cameraOffset = {0.,0.}; sf::Clock clock; + sf::Clock PieceClock; ReferencePlane selectedPlane = ReferencePlane::XZ; PieceInterface* selected = nullptr; @@ -50,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(); + PieceClock.restart(); intervalMajLimit = maj; intervalMinLimit = min; this->pos = pos; @@ -82,13 +84,13 @@ void State::update(){ */ for (auto i : collections){ - i->update(clock); + i->update(PieceClock); } for (auto i : createdColl){ if (play){ for (auto j : i.pieces){ - j->update(clock); + j->update(PieceClock); } } for (auto j : i.joints){ @@ -98,7 +100,7 @@ void State::update(){ if (play){ for(PieceInterface* p : pieces){ - p->update(clock); + p->update(PieceClock); } } for(JointInterface* j : joints){