more camera movement

This commit is contained in:
Asuro
2025-02-12 02:01:39 +01:00
parent 03aecb6d44
commit 137d8fa539
6 changed files with 56 additions and 6 deletions

View File

@@ -9,6 +9,21 @@ namespace
Game::GameInstance* GameInst = nullptr;
} // namespace
void Vec2::Normalize()
{
float len = bx::sqrt(X * X + Y * Y);
X /= len;
Y /= len;
}
void Vec3::Normalize()
{
float len = bx::sqrt(X * X + Y * Y + Z * Z);
X /= len;
Y /= len;
Z /= len;
}
Quat Quat::FromEuler(float x, float y, float z)
{
x *= bx::kPi / 180.0f;
@@ -47,13 +62,23 @@ void Mat4::CreateTransform(float* out, Vec3 pos, Quat rot, Vec3 scale)
bx::mtxMul(out, buf, tMat);
}
void Mat4::Translate(Vec3 offset)
void Mat4::TranslateLocal(Vec3 offset)
{
M[12] += offset.X;
M[13] += offset.Y;
M[14] += offset.Z;
}
void Mat4::Rotate(Vec3 rotation)
{
float rot[16]{0};
bx::mtxRotateXYZ(rot, rotation.X, rotation.Y, rotation.Z);
float temp[16]{0};
bx::mtxMul(temp, M, rot);
for (int32_t i = 0; i < 16; ++i)
M[i] = temp[i];
}
Vec3 Mat4::Right()
{
return {M[0], M[1], M[2]};