diff options
| author | MegaMech <MegaMech@users.noreply.github.com> | 2025-05-14 18:30:32 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-14 18:30:32 -0600 |
| commit | 32632cacdb316d7f2d3b6ecdb634f0ef9aebadf0 (patch) | |
| tree | d374a84675fc0f49100c275aa34828bc9db538f8 /src/engine/HM_Intro.cpp | |
| parent | 70f049cb6c326dede27e0ba7e88ac0d67b7651a4 (diff) | |
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 <stdio.h>" 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>
Diffstat (limited to 'src/engine/HM_Intro.cpp')
| -rw-r--r-- | src/engine/HM_Intro.cpp | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/src/engine/HM_Intro.cpp b/src/engine/HM_Intro.cpp new file mode 100644 index 000000000..e27d5db0c --- /dev/null +++ b/src/engine/HM_Intro.cpp @@ -0,0 +1,183 @@ +#include <libultra/gbi.h> +#include <libultra/gu.h> +#include "HM_Intro.h" + +#include "port/Game.h" + +extern "C" { +#include "main.h" +#include "memory.h" +#include "math_util.h" +#include "courses/harbour/track.h" +#include "courses/harbour/powered.h" +#include "courses/harbour/ship2_model.h" +#include "courses/harbour/ship3_model.h" +#include "collision.h" +#include "menu_items.h" +#include "external.h" +#include "menus.h" +extern Gfx ship1_spag1_mesh[]; +} + +HarbourMastersIntro::HarbourMastersIntro() { +} + +void HarbourMastersIntro::HM_InitIntro() { + _camera.Pos.x = 0; + _camera.Pos.y = 0; + _camera.Pos.z = 0; + + // The camera setup was broken when this was first made. And then it was fixed. + // That's why this file has weird coordinates as the objects were positioned in-front of the camera view + // Instead of moving the camera to the right spot in the scene. + _camera.LookAt.x = 0; + _camera.LookAt.y = 0; + _camera.LookAt.z = -2500; + + _cameraSpeed = 0.0f; + _cameraMaxSpeed = 16.0f; + _cameraAcceleration = 1.0f; + + _pos = FVector(-1000, -205, -800); // -1000, -210, -800 + _rot = IRotator(-5, 100, 0); + _scale = {0.7f, 0.7f, 0.7f}; + + _ship2Pos = FVector(300, -210, -1960); + _ship2Rot = IRotator(0, 45, 0); + + _shipPos = FVector(20, -210, -1650); + _shipRot = IRotator(0, 45, 0); + + _posHM64 = FVector(0, -500, -1000); + _rotHM64 = IRotator(0, -90, -4); // -0x2100 + + _hPos = FVector(-2000, 100, -4900); + _hRot = IRotator(0, -45.0f, 0); + _hScale = {2.0f, 2.0f, 2.0f}; + + lusPos = FVector(0, -400, -614); // 12, 190, -1000 + lusRot = IRotator(0, 0, 0); + lusScale = FVector(1, 1, 1); + + ground_f3d_material_013_lights = gdSPDefLights1( + 0x7F, 0x30, 0x80, + 0x60, 20, 10, 0x49, 0x49, 0x49 + ); + + gEditor.AddObject("lus", &lusPos, &lusRot, &lusScale, nullptr, 1, Editor::GameObject::CollisionType::BOUNDING_BOX, 10, &DespawnValue, -1); +} + +void HarbourMastersIntro::HM_TickIntro() { + _water += 1; + if (_water > 255) { + _water = 0; + } + + HarbourMastersIntro::SpagBob(_pos, _rot, 2.5f, 0.18f, 1.5f, 0.05f, 1.7f, 0.06f); + HarbourMastersIntro::Bob(_shipPos, _shipRot, 1.2f, 0.06f, 1.6f, -0.04f, 1.1f, -0.04f); + HarbourMastersIntro::Bob(_ship2Pos, _ship2Rot, 1.2f, 0.06f, 1.6f, -0.04f, 1.1f, -0.04f); + + _pos.x += 9; + if (lusPos.y < -60) { + lusPos.y += 3; + } + //_camera.Pos.x -= 1; + + // SWITCH TO NEXT MENU LOGO_INTRO_MENU + if (_pos.x >= 1100) { + gMenuFadeType = 0; + gMenuSelection = LOGO_INTRO_MENU; + gFadeModeSelection = FADE_MODE_LOGO; + } + + find_and_set_tile_size((uintptr_t) ((void*)mat_water_water1), 0, _water); + find_and_set_tile_size((uintptr_t) ((void*)mat_water_water2), _water, 0);; +} + +void HarbourMastersIntro::Bob(FVector& pos, IRotator& rot, f32 bobAmp, f32 bobSpeed, f32 tiltAmp, f32 tiltSpeed, f32 rollAmp, f32 rollSpeed) { + float time = (float)gGlobalTimer; + + pos.y = -210 + bobAmp * sin(time * bobSpeed); + + rot.pitch = (tiltAmp * sin(time * tiltSpeed)) * (UINT16_MAX / 360); + + rot.roll = (rollAmp * sin(time * rollSpeed)) * (UINT16_MAX / 360); +} + +void HarbourMastersIntro::SpagBob(FVector& pos, IRotator& rot, f32 bobAmp, f32 bobSpeed, f32 tiltAmp, f32 tiltSpeed, f32 rollAmp, f32 rollSpeed) { + float time = (float)gGlobalTimer; + + pos.y = -205 + bobAmp * sin(time * bobSpeed); + + rot.pitch = (-5 + tiltAmp * sin(time * tiltSpeed)) * (UINT16_MAX / 360); + + rot.roll = (rollAmp * sin(time * rollSpeed)) * (UINT16_MAX / 360); +} + +void HarbourMastersIntro::HM_DrawIntro() { + HarbourMastersIntro::Setup(); + + gSPMatrix(gDisplayListHead++, &gGfxPool->mtxScreen, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gDisplayListHead++, &gGfxPool->mtxLookAt[0], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); + gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); + gDPSetEnvColor(gDisplayListHead++, 0x00, 0x00, 0x00, 0x00); + + Mat4 mtx_spaghettiShip; + ApplyMatrixTransformations(mtx_spaghettiShip, _pos, _rot, _scale); + render_set_position(mtx_spaghettiShip, 0); + gSPDisplayList(gDisplayListHead++, ship1_spag1_mesh); + + Mat4 mtx_ship2; + ApplyMatrixTransformations(mtx_ship2, _ship2Pos, _ship2Rot, _scale); + render_set_position(mtx_ship2, 0); + gSPDisplayList(gDisplayListHead++, ship2_SoH_mesh); + + Mat4 mtx_ship3; + ApplyMatrixTransformations(mtx_ship3, _shipPos, _shipRot, _scale); + render_set_position(mtx_ship3, 0); + gSPDisplayList(gDisplayListHead++, ship3_2Ship_mesh); + + Mat4 mtx_geo; + ApplyMatrixTransformations(mtx_geo, _hPos, _hRot, _hScale); + render_set_position(mtx_geo, 0); + + gSPDisplayList(gDisplayListHead++, ground_map_mesh); + //gSPDisplayList(gDisplayListHead++, powered_Text_mesh); // Replaced by poweredbylus + gSPDisplayList(gDisplayListHead++, castle_map_002_mesh); + gSPDisplayList(gDisplayListHead++, road_map_001_mesh); + gSPDisplayList(gDisplayListHead++, water_water1_mesh); + + Mat4 lusMtx; + ApplyMatrixTransformations(lusMtx, lusPos, lusRot, lusScale); + render_set_position(lusMtx, 0); + gSPDisplayList(gDisplayListHead++, (Gfx*)"__OTR__hmintro/poweredbylus"); + + HarbourMastersIntro::Sync(); +} + +void HarbourMastersIntro::Setup() { + u16 perspNorm; + move_segment_table_to_dmem(); + gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); + guPerspective(&gGfxPool->mtxScreen, &perspNorm, 45.0f, 1.3333334f, 100.0f, 12800.0f, 1.0f); + gSPPerspNormalize(gDisplayListHead++, perspNorm); + guLookAt(&gGfxPool->mtxLookAt[0], _camera.Pos.x, _camera.Pos.y, _camera.Pos.z, _camera.LookAt.x, _camera.LookAt.y, _camera.LookAt.z, 0.0f, 1.0f, 0.0f); + + gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); + gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); + gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER | G_CULL_BACK | G_LIGHTING); + gDPSetFillColor(gDisplayListHead++, 0x00010001); + gDPFillRectangle(gDisplayListHead++, 0, 0, 319, 239); + gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_CULL_BACK | G_LIGHTING); + gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); + gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE); + gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); + gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + gDPPipeSync(gDisplayListHead++); +} + +void HarbourMastersIntro::Sync() { + gDPPipeSync(gDisplayListHead++); + gDPSetTexturePersp(gDisplayListHead++, G_TP_NONE); + gDPSetTextureFilter(gDisplayListHead++, G_TF_BILERP); +} |
