Fixing bugs, more freq updated
This commit is contained in:
1 parent
e0a60dcd6f
commit
3c55b59c8d
6 files changed
+136
-28
No files matched your search
@@ -245,6 +245,7 @@ namespace ZL
|
||||
std::chrono::system_clock::now().time_since_epoch()
|
||||
).count();
|
||||
std::string msg = "VEL:" + std::to_string(now_ms) + ":" + std::to_string(Environment::shipSelectedVelocity);
|
||||
msg = msg + ":" + formPingMessageContent();
|
||||
networkClient->Send(msg);
|
||||
}
|
||||
});
|
||||
@@ -583,6 +584,18 @@ namespace ZL
|
||||
renderer.PushMatrix();
|
||||
renderer.LoadIdentity();
|
||||
|
||||
renderer.TranslateMatrix({ 0,0, -1.0f * Environment::zoom });
|
||||
renderer.RotateMatrix(Environment::inverseShipMatrix);
|
||||
renderer.TranslateMatrix(-Environment::shipPosition);
|
||||
|
||||
Eigen::Vector3f relativePos = playerState.position;// -Environment::shipPosition;
|
||||
renderer.TranslateMatrix(relativePos);
|
||||
|
||||
// 3. Поворот врага
|
||||
renderer.RotateMatrix(playerState.rotation);
|
||||
|
||||
/*
|
||||
|
||||
// 1. Камера и вид игрока
|
||||
renderer.TranslateMatrix({ 0, 0, -1.0f * Environment::zoom });
|
||||
renderer.RotateMatrix(Environment::inverseShipMatrix);
|
||||
@@ -601,6 +614,8 @@ namespace ZL
|
||||
// В твоем drawShip() есть: renderer.TranslateMatrix({ 0, -6.f, 0 });
|
||||
renderer.TranslateMatrix({ 0, -6.f, 0 });
|
||||
|
||||
*/
|
||||
|
||||
renderer.DrawVertexRenderStruct(spaceship);
|
||||
renderer.PopMatrix();
|
||||
}
|
||||
@@ -638,6 +653,7 @@ namespace ZL
|
||||
).count();
|
||||
|
||||
// 1. Извлекаем кватернион из матрицы поворота
|
||||
/*
|
||||
Eigen::Quaternionf q(Environment::shipMatrix);
|
||||
|
||||
// 2. Формируем строку PING согласно протоколу сервера
|
||||
@@ -657,6 +673,8 @@ namespace ZL
|
||||
+ std::to_string(Environment::shipSelectedVelocity) + ":"
|
||||
+ std::to_string(Environment::lastSentMagnitude) + ":" // Используем те же static переменные из блока ROT
|
||||
+ std::to_string(Environment::lastSentAngle);
|
||||
*/
|
||||
std::string pingMsg = "PING:" + std::to_string(now_ms) + ":" + formPingMessageContent();
|
||||
|
||||
networkClient->Send(pingMsg);
|
||||
std::cout << "Sending: " << pingMsg << std::endl;
|
||||
@@ -720,6 +738,7 @@ namespace ZL
|
||||
// Формируем сетевой пакет
|
||||
// Нам нужно отправить: дискретный угол, дискретную силу и текущую матрицу/позицию для синхронизации
|
||||
std::string msg = "ROT:" + std::to_string(now_ms) + ":" + std::to_string(discreteAngle) + ":" + std::to_string(discreteMag);
|
||||
msg = msg + ":" + formPingMessageContent();
|
||||
networkClient->Send(msg);
|
||||
}
|
||||
|
||||
@@ -784,6 +803,7 @@ namespace ZL
|
||||
// Формируем сетевой пакет
|
||||
// Нам нужно отправить: дискретный угол, дискретную силу и текущую матрицу/позицию для синхронизации
|
||||
std::string msg = "ROT:" + std::to_string(now_ms) + ":" + std::to_string(discreteAngle) + ":" + std::to_string(discreteMag);
|
||||
msg = msg + ":" + formPingMessageContent();
|
||||
networkClient->Send(msg);
|
||||
}
|
||||
|
||||
@@ -1138,5 +1158,28 @@ namespace ZL
|
||||
|
||||
}
|
||||
|
||||
std::string Game::formPingMessageContent()
|
||||
{
|
||||
Eigen::Quaternionf q(Environment::shipMatrix);
|
||||
|
||||
std::string pingMsg = std::to_string(Environment::shipPosition.x()) + ":"
|
||||
+ std::to_string(Environment::shipPosition.y()) + ":"
|
||||
+ std::to_string(Environment::shipPosition.z()) + ":"
|
||||
+ std::to_string(q.w()) + ":"
|
||||
+ std::to_string(q.x()) + ":"
|
||||
+ std::to_string(q.y()) + ":"
|
||||
+ std::to_string(q.z()) + ":"
|
||||
+ std::to_string(Environment::currentAngularVelocity.x()) + ":"
|
||||
+ std::to_string(Environment::currentAngularVelocity.y()) + ":"
|
||||
+ std::to_string(Environment::currentAngularVelocity.z()) + ":"
|
||||
+ std::to_string(Environment::shipVelocity) + ":"
|
||||
+ std::to_string(Environment::shipSelectedVelocity) + ":"
|
||||
+ std::to_string(Environment::lastSentMagnitude) + ":" // Используем те же static переменные из блока ROT
|
||||
+ std::to_string(Environment::lastSentAngle);
|
||||
|
||||
|
||||
return pingMsg;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ZL
|
||||
Reference in new issue
Block a user