added ship control

This commit is contained in:
Ariari04 2025-12-11 21:14:39 +06:00
parent da8946e9ef
commit 47fe0c4719

View File

@ -492,23 +492,11 @@ void Game::processTickCount() {
Environment::shipVelocity = velocity * delta / 100; Environment::shipVelocity = velocity * delta / 100;
Vector3f direction = { diffx, 0, -diffy }; Vector3f dir = { -diffx, 0, diffy };
float angle = atan2(dir.v[0], -dir.v[2]); // [-pi, pi]
Vector4f quat = { 0, sin(angle * 0.5f), 0, cos(angle * 0.5f) };
rotateShipMat = QuatToMatrix(quat);
Vector3f origin = { 0,0, -1 };
float dir_module = sqrtf(diffx * diffx + diffy * diffy);
float scalar = direction.v[0] * origin.v[0] + direction.v[1] * origin.v[1]+ direction.v[2] * origin.v[2];
float angle = acos(scalar / dir_module);
Vector4f quat = {
0,
1 * sin(angle / 2),
0,
cos(angle / 2)
};
rotateShipMat = QuatToMatrix(quat); rotateShipMat = QuatToMatrix(quat);