added random spaceship type

This commit is contained in:
Vlad committed 2026-02-24 19:51:33 +06:00
1 parent 3893038d9a
commit ad7294ceea
5 files changed
+59 -23

No files matched your search

+25 -3
View File
@@ -310,6 +310,21 @@ namespace ZL
spaceship.AssignFrom(spaceshipBase);
spaceship.RefreshVBO();
// Load cargo
cargoTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/Cargo_Base_color_sRGB.png", CONST_ZIP_FILE));
cargoBase = LoadFromTextFile02("resources/cargoship001.txt", CONST_ZIP_FILE);
auto quat = Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitZ()));
auto rotMatrix = quat.toRotationMatrix();
cargoBase.RotateByMatrix(rotMatrix);
auto quat2 = Eigen::Quaternionf(Eigen::AngleAxisf(M_PI * 0.5, Eigen::Vector3f::UnitY()));
auto rotMatrix2 = quat2.toRotationMatrix();
cargoBase.RotateByMatrix(rotMatrix2);
//cargoBase.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(M_PI, Eigen::Vector3f::UnitY())).toRotationMatrix());
cargoBase.Move(Vector3f{ 1.2, 0, -5 });
cargo.AssignFrom(cargoBase);
cargo.RefreshVBO();
//Boxes
boxTexture = std::make_unique<Texture>(CreateTextureDataFromPng("resources/box/box.png", CONST_ZIP_FILE));
@@ -588,8 +603,8 @@ namespace ZL
static_cast<float>(Environment::width) / static_cast<float>(Environment::height),
Environment::CONST_Z_NEAR, Environment::CONST_Z_FAR);
// Биндим текстуру корабля один раз для всех удаленных игроков (оптимизация батчинга)
glBindTexture(GL_TEXTURE_2D, spaceshipTexture->getTexID());
// Биндим текÑ�туру кораблÑ� один раз длÑ� Ð?Ñ�ех правильных игроков
// ?????????: ?????? ???????? ?????????? ?????? ????? ? ??????????? ?? ClientState.shipType
// Е�ли �ервер при�лал коробки, примен�ем их однократно вме�то локальной генерации
if (!serverBoxesApplied && networkClient) {
@@ -633,7 +648,14 @@ namespace ZL
// 3. Поворот врага
renderer.RotateMatrix(playerState.rotation);
renderer.DrawVertexRenderStruct(spaceship);
if (playerState.shipType == 1 && cargoTexture) {
glBindTexture(GL_TEXTURE_2D, cargoTexture->getTexID());
renderer.DrawVertexRenderStruct(cargo);
}
else {
glBindTexture(GL_TEXTURE_2D, spaceshipTexture->getTexID());
renderer.DrawVertexRenderStruct(spaceship);
}
renderer.PopMatrix();
}