From de9c5d510175bba11ab8704e67be3a3a94f9149e Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 9 Nov 2025 19:07:44 -0700 Subject: Implement SpawnParams struct (#536) * Impl SpawnParams * Added json submodule * Update json * Update * Works * Remove comment * Works refactor * Snowman and thwomp working * Impl hot air balloon * More progress * All OObjects are done * cleanup * Refactor 2Dpath to normal path * Update nlohmann json & fix compile * Rest of actors * MORE CHANGES * Finish actors * Done PR, some fix to collision viewer * Impl falling rocks * Add const * wip editor refactor * Property work * continue * Overridable editor properties * Actor saving/loading works now * Fix light alignment * Clarification * Impl penguin * params impl signs * properties impl falling rock * More property impls * impl air balloon * Add spawnParams to OObject Translate * Snowman translate better * impl hedgehog properly * properties impl trophy * thwomp progress * Finish impl properties * Fix compile * Fix cursor collisions * Move registered actors * Rename pathPoint XYZ to xyz * Fix editor pause bug * Clean up * Review comments * Remove SpawnParams struct from actor classes * Rename * Player Label First Iteration * Work now * Working 3d text * Fix boo bug * Finish AText actor * Fix spawnparams compile * Register AText * Finish Text Actor * Fix thwomp interpolation * Fix compile * Fix crab and hedgehog * Fix loading flagpole * Fix Hot Air Balloon * Turn zbuffer on for AText * Update --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> --- src/engine/Matrix.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src/engine/Matrix.cpp') diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp index 954b0fd90..44a9a1799 100644 --- a/src/engine/Matrix.cpp +++ b/src/engine/Matrix.cpp @@ -119,6 +119,56 @@ void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector sca mtx[3][3] = 1.0f; } +/* + * Spherical billboarding + * Rotates the object to face the camera + * Rotates on all three axis + */ +void ApplySphericalBillBoard(Mat4 mat, FVector pos, FVector scale, s32 cameraIndex) { + Mtx* lookAt = GetLookAtMatrix(cameraIndex); + Mat4 lookAtF; + guMtxL2F((float(*)[4])&lookAtF, lookAt); + + // Camera Right + mat[0][0] = lookAtF[0][0]; + mat[1][0] = lookAtF[0][1]; + mat[2][0] = lookAtF[0][2]; + mat[3][0] = 0; + + // Camera Up + mat[0][1] = lookAtF[1][0]; + mat[1][1] = lookAtF[1][1]; + mat[2][1] = lookAtF[1][2]; + mat[3][1] = 0; + + // Camera Forward + mat[0][2] = lookAtF[2][0]; + mat[1][2] = lookAtF[2][1]; + mat[2][2] = lookAtF[2][2]; + mat[3][2] = 0; + + mat[0][3] = 0; + mat[1][3] = 0; + mat[2][3] = 0; + mat[3][3] = 1; + + // Set position + mat[3][0] = pos.x; + mat[3][1] = pos.y; + mat[3][2] = pos.z; + + // Apply scaling + mat[0][0] *= scale.x; + mat[1][0] *= scale.x; + mat[2][0] *= scale.x; + mat[0][1] *= scale.y; + mat[1][1] *= scale.y; + mat[2][1] *= scale.y; + mat[0][2] *= scale.z; + mat[1][2] *= scale.z; + mat[2][2] *= scale.z; +} + void AddLocalRotation(Mat4 mat, IRotator rot) { f32 sin_pitch = sins(rot.pitch); f32 cos_pitch = coss(rot.pitch); @@ -141,7 +191,6 @@ void AddLocalRotation(Mat4 mat, IRotator rot) { mat[2][2] = (cos_pitch * cos_yaw); } - // API extern "C" { -- cgit v1.2.3