Aggiunto clock per i pezzi (aggiusta calcolo veocità)

This commit is contained in:
2026-06-21 12:43:21 +02:00
parent e1965aaf1e
commit 1349de403c
3 changed files with 17 additions and 7 deletions
+12 -4
View File
@@ -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});
}