diff --git a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp index 8c19aa8a..1847fa6b 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/gte_test.cpp @@ -22,9 +22,10 @@ namespace GTETest { GPU::Color24::Grey() )); - static auto rotation = 0.0_deg; + static auto gbl_rotation = 0.0_deg; static void setup() { + doener_fish.area.position = GPU::PositionI16::create(100, 100); Shared::back_menu.reset(); GTE::set_geom_offset(0, 0); @@ -37,12 +38,10 @@ namespace GTETest { return true; } - const auto matrix = GTE::MATRIX{ - GTE::ROTMATRIX::rotated(-rotation, rotation, -rotation), - GTE::TRANSFERVECTOR::translated((Assets::Main::DoenerFishInfo.size.width/2), (Assets::Main::DoenerFishInfo.size.height/2)) - }; + auto matrix = GTE::MATRIX::rotated(-gbl_rotation, gbl_rotation, -gbl_rotation); doener_fish.apply(matrix); - rotation += 5.0_deg; + doener_fish.angle += 25.0_deg; + gbl_rotation += 2.5_deg; return false; } diff --git a/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp b/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp index 1fd470a7..51f1d0e7 100644 --- a/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp +++ b/examples/PoolBox/application/src/Overlay/GTETest/include/GTE_Sprite.hpp @@ -7,24 +7,33 @@ namespace GTETest { using namespace JabyEngine; struct GTE_Sprite { - GPU::AreaI16 area; - GPU::POLY_FT4 display; + GPU::AreaI16 area; + GPU::PositionI16 pivot; + deg_t angle; + GPU::POLY_FT4 display; static constexpr GTE_Sprite create(const GPU::POLY_FT4& base) { return GTE_Sprite{ .area = GPU::AreaI16::create(base.get_rect_pos(), base.get_rect_size()), + .pivot = GPU::PositionI16::create(base.get_rect_size().width/2, base.get_rect_size().height/2), + .angle = 0.0_deg, .display = base }; } - void apply(const GTE::MATRIX& matrix) { - const auto move_back = GTE::MATRIX::comp(GTE::MATRIX::translated(-matrix.transfer.x, -matrix.transfer.y, -matrix.transfer.z), matrix); - const auto& area = this->area; + void apply(const GTE::MATRIX& gbl_matrix) { + auto matrix = GTE::MATRIX::translated(-this->pivot.x, -this->pivot.y, 0).comp( + GTE::MATRIX::rotated(0.0_deg, 0.0_deg, this->angle) + ).comp( + GTE::MATRIX::translated(this->pivot.x, this->pivot.y, 0) + ).comp( + GTE::MATRIX::translated(this->area.position.x, this->area.position.y) + ).comp(gbl_matrix); - this->display.vertex0 = move_back.apply_to(area.get_top_left()); - this->display.vertex1 = move_back.apply_to(area.get_top_right()); - this->display.vertex2 = move_back.apply_to(area.get_bottom_left()); - this->display.vertex3 = move_back.apply_to(area.get_bottom_right()); + this->display.vertex0 = matrix.apply_to(GPU::Vertex::create(0, 0)); + this->display.vertex1 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, 0)); + this->display.vertex2 = matrix.apply_to(GPU::Vertex::create(0, this->area.size.height)); + this->display.vertex3 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, this->area.size.height)); } void render() {