added ship control
This commit is contained in:
parent
da8946e9ef
commit
47fe0c4719
20
Game.cpp
20
Game.cpp
@ -492,23 +492,11 @@ void Game::processTickCount() {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user