From 32632cacdb316d7f2d3b6ecdb634f0ef9aebadf0 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Wed, 14 May 2025 18:30:32 -0600 Subject: Impl new intro (#193) * Update menus * Update CMakeLists.txt * Add Ship * Impl hm ship actors * Update HM course * Impl new intro * Finish intro scene * Rename * Start Editor Work * raycast works * Fix ScreenRayTrace in widescreen * Basic Actor Picking * wip * Editor use vtx collision * gizmo work * otr works for object picking * Impl objects for editor * actor init * Update * Add all axis move (freemove) * Docking Windows works here * Setup imgui layout for editor * Editor Snap to Ground works * Basic Scene Explorer Works * Editor get actor names * Impl editor object names * impl Editor Play and Pause buttons * Editor translate works while paused * Fix freecam lighting * Added adjustable track properties to editor * Editor matrix, icons, rotation, impl light * Setup Track Properties 1 * Editor tooling wip * Load modded o2rs * Don't enable hud if editor is enabled * Updates * SceneManager nearly working * Fix mario kart 64 intro logo sizing * Fix Rotator * Finish new matrix translation code * Cleanup headers * Cleanup * Cleanup 2 * Cleanup 3 * Prevent divize by zero crash * Add visible circle for translate in all axis * Editor scaling/rot works properly now * Scale All_Axis evenly * Fixes to includes to work on Linux. * Removed overfilled arguments in gfx_create_framebuffer() * Added missing function definitions to Game.h * Editor sun face the camera * Add rotation model to gizmo * Add new handles * Failed attempt at transforming collision * Impl water volume * Import fast64 paths * water surface * Scene Setup 1 * Custom Track O2R almost working needs testing * Custom Track Load path O2r * Render custom track. Wip collision * Add missing function * Debug Spawning Custom O2R Track * Import courses working now * Fix memory leak * Remove New Track Button * Engine.cpp more consistent with sf64 * Fix Editor Enable Button * Editor Accurate mouse click drag objects * Editor selects closest object and cleanup * Gizmo rot and scale collision working * Remove constexpr from IRotator * Impl properties for location/rot/scale * Better Properties display, swap rot handles * Fix content browser dock and editor now disabled by default * Remove GameInfoWindow, Multiplayer Button, and FPS Slider * Disable Editor when its disabled * Add new logo to hm intro * Fix pause menu item box cursor * Remove minimap from Course::from_json and to_json * Impl Import Minimap * Fix custom minimap rendering * minimap uses extension .png * Refactor minimap * Freecam only for player 1 * GrandPrix Balloons work in custom track * Track Id is now std::string and outside of Props * Moved editor assets to be included in ship.o2r * Fixed GenerateO2R to package the correct folder and save to the correct filename * Linux specific changes. * Added "#include " that required them * Changed how the "ship.o2r" file is loaded to allow it to load the file from within appimages. * Changed the Linuxdeploy version to avoid errors later when the Github Actions creates appimages(same fix applied to other ports.) * Revert "Moved editor assets to be included in ship.o2r" This reverts commit 05704c01f761baa67a83e357d9765f5c6b5e3fdb. * Added back files(this time without LUS changes) * Changed workflow file to use correct filename for assets file. * Missed a few spots in the workflow file. * Added .desktop file and made corrections to the main workflow. * Added the rest of upstream CMakeLists.txt * disabled USE_NETWORKING * New InverseMatrix * Renamed both .o2r files to be more accurate to its contents. * Reverted CmakeList.txt --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com> --- src/engine/Matrix.cpp | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) (limited to 'src/engine/Matrix.cpp') diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp index 354389db9..1f2301258 100644 --- a/src/engine/Matrix.cpp +++ b/src/engine/Matrix.cpp @@ -4,6 +4,8 @@ extern "C" { #include "common_structs.h" +#include "math_util.h" +#include "math_util_2.h" } void AddMatrix(std::vector& stack, Mat4 mtx, s32 flags) { @@ -26,7 +28,7 @@ Mtx* GetMatrix(std::vector& stack) { } /** - * Use GetMatrix first + * Use GetMatrix() first */ void AddMatrixFixed(std::vector& stack, s32 flags) { // Load the matrix @@ -58,6 +60,76 @@ Mtx* SetTextMatrix(f32 arg1, f32 arg2, f32 arg3, f32 arg4) { return mtx; } +void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector scale) { + f32 sine1, cosine1; + f32 sine2, cosine2; + f32 sine3, cosine3; + + // Compute the sine and cosine of the orientation (Euler angles) + sine1 = sins(rot.pitch); + cosine1 = coss(rot.pitch); + sine2 = sins(rot.yaw); + cosine2 = coss(rot.yaw); + sine3 = sins(rot.roll); + cosine3 = coss(rot.roll); + + // Compute the rotation matrix + mtx[0][0] = (cosine2 * cosine3) + ((sine1 * sine2) * sine3); + mtx[1][0] = (-cosine2 * sine3) + ((sine1 * sine2) * cosine3); + mtx[2][0] = cosine1 * sine2; + mtx[3][0] = pos.x; + + mtx[0][1] = cosine1 * sine3; + mtx[1][1] = cosine1 * cosine3; + mtx[2][1] = -sine1; + mtx[3][1] = pos.y; + + mtx[0][2] = (-sine2 * cosine3) + ((sine1 * cosine2) * sine3); + mtx[1][2] = (sine2 * sine3) + ((sine1 * cosine2) * cosine3); + mtx[2][2] = cosine1 * cosine2; + mtx[3][2] = pos.z; + + // Apply scaling + mtx[0][0] *= scale.x; + mtx[1][0] *= scale.x; + mtx[2][0] *= scale.x; + mtx[0][1] *= scale.y; + mtx[1][1] *= scale.y; + mtx[2][1] *= scale.y; + mtx[0][2] *= scale.z; + mtx[1][2] *= scale.z; + mtx[2][2] *= scale.z; + + // Set the last row and column for the homogeneous coordinate system + mtx[0][3] = 0.0f; + mtx[1][3] = 0.0f; + mtx[2][3] = 0.0f; + mtx[3][3] = 1.0f; +} + +void AddLocalRotation(Mat4 mat, IRotator rot) { + f32 sin_pitch = sins(rot.pitch); + f32 cos_pitch = coss(rot.pitch); + f32 sin_yaw = sins(rot.yaw); + f32 cos_yaw = coss(rot.yaw); + f32 sin_roll = sins(rot.roll); + f32 cos_roll = coss(rot.roll); + + // Modify only the rotation part (keep translation intact) + mat[0][0] = (cos_yaw * cos_roll) + (sin_pitch * sin_yaw * sin_roll); + mat[0][1] = (cos_pitch * sin_roll); + mat[0][2] = (-sin_yaw * cos_roll) + (sin_pitch * cos_yaw * sin_roll); + + mat[1][0] = (-cos_yaw * sin_roll) + (sin_pitch * sin_yaw * cos_roll); + mat[1][1] = (cos_pitch * cos_roll); + mat[1][2] = (sin_yaw * sin_roll) + (sin_pitch * cos_yaw * cos_roll); + + mat[2][0] = (cos_pitch * sin_yaw); + mat[2][1] = -sin_pitch; + mat[2][2] = (cos_pitch * cos_yaw); +} + + // API extern "C" { @@ -122,3 +194,4 @@ extern "C" { gWorldInstance.Mtx.Objects.clear(); } } + -- cgit v1.2.3