Experiment with rotation
This commit is contained in:
parent
a103055ce0
commit
a86763ddc3
|
@ -1,33 +1,25 @@
|
||||||
#include "../../../include/asset_mgr.hpp"
|
#include "../../../include/asset_mgr.hpp"
|
||||||
#include "../../../include/shared.hpp"
|
#include "../../../include/shared.hpp"
|
||||||
#include <PSX/GTE/gte.hpp>
|
#include "include/GTE_Sprite.hpp"
|
||||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
|
||||||
#include <PSX/Periphery/periphery.hpp>
|
#include <PSX/Periphery/periphery.hpp>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace GTETest {
|
namespace GTETest {
|
||||||
using namespace JabyEngine;
|
using namespace JabyEngine;
|
||||||
|
using namespace GTETest;
|
||||||
|
|
||||||
static auto matrix = GTE::MATRIX::identity();
|
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
|
||||||
static GPU::POLY_FT4 doener_fish;
|
Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size),
|
||||||
static auto rotation = 5_DEG;
|
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(),
|
||||||
|
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||||
static GPU::POLY_FT4 create_doener_fish() {
|
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()),
|
||||||
return Make::POLY_FT4(
|
GPU::Color24::Grey()
|
||||||
GPU::Display::center(Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size)),
|
));
|
||||||
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(),
|
static auto rotation = 0_DEG;
|
||||||
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
|
||||||
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()),
|
|
||||||
GPU::Color24::Grey()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setup() {
|
static void setup() {
|
||||||
Shared::back_menu.reset();
|
Shared::back_menu.reset();
|
||||||
|
|
||||||
matrix = GTE::MATRIX::rotation(0, 0, 0);
|
|
||||||
doener_fish = create_doener_fish();
|
|
||||||
|
|
||||||
GTE::set_geom_offset(0, 0);
|
GTE::set_geom_offset(0, 0);
|
||||||
GTE::set_geom_screen(512);
|
GTE::set_geom_screen(512);
|
||||||
}
|
}
|
||||||
|
@ -38,28 +30,17 @@ namespace GTETest {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto matrix = GTE::MATRIX::rotation(0, 0, rotation);
|
||||||
GTE::set_trans_matrix(matrix);
|
GTE::set_trans_matrix(matrix);
|
||||||
GTE::set_rot_matrix(matrix);
|
GTE::set_rot_matrix(matrix);
|
||||||
|
|
||||||
// for now?
|
doener_fish.apply();
|
||||||
doener_fish = create_doener_fish();
|
|
||||||
GPU::Vertex* doener_vertices[] = {&doener_fish.vertex0, &doener_fish.vertex1, &doener_fish.vertex2, &doener_fish.vertex3};
|
|
||||||
for(auto* vertex : doener_vertices) {
|
|
||||||
GTE::VECTOR output;
|
|
||||||
int32_t flag;
|
|
||||||
|
|
||||||
GTE::rot_trans(GTE::SVECTOR::from(*vertex), output, flag);
|
|
||||||
*vertex = output.to<GPU::Vertex>();
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix = GTE::MATRIX::rotation(0, 0, rotation);
|
|
||||||
rotation += 5_DEG;
|
rotation += 5_DEG;
|
||||||
//GTE::multiply_matrix(matrix, GTE::MATRIX::rotation(0, 0, 5_DEG), matrix);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render() {
|
static void render() {
|
||||||
GPU::render(doener_fish);
|
doener_fish.render();
|
||||||
Shared::back_menu.render();
|
Shared::back_menu.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
#include <PSX/GPU/gpu_primitives.hpp>
|
||||||
|
#include <PSX/GPU/gpu.hpp>
|
||||||
|
#include <PSX/GTE/gte.hpp>
|
||||||
|
|
||||||
|
namespace GTETest {
|
||||||
|
using namespace JabyEngine;
|
||||||
|
|
||||||
|
struct GTE_Sprite {
|
||||||
|
GPU::AreaI16 area;
|
||||||
|
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()),
|
||||||
|
.display = base
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void apply() {
|
||||||
|
static const auto apply_to = [](GTE::SVECTOR vector) -> GPU::Vertex {
|
||||||
|
GTE::VECTOR output;
|
||||||
|
int32_t flag;
|
||||||
|
|
||||||
|
GTE::rot_trans(vector, output, flag);
|
||||||
|
return output.to<GPU::Vertex>();
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto& area = this->area;
|
||||||
|
this->display.vertex0 = apply_to(GTE::SVECTOR::from(area.get_top_left()));
|
||||||
|
this->display.vertex1 = apply_to(GTE::SVECTOR::from(area.get_top_right()));
|
||||||
|
this->display.vertex2 = apply_to(GTE::SVECTOR::from(area.get_bottom_left()));
|
||||||
|
this->display.vertex3 = apply_to(GTE::SVECTOR::from(area.get_bottom_right()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void render() {
|
||||||
|
GPU::render(this->display);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -54,6 +54,13 @@ namespace JabyEngine {
|
||||||
return *static_cast<T*>(this);
|
return *static_cast<T*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr PositionI16 get_rect_pos() const {
|
||||||
|
return PositionI16::create(
|
||||||
|
static_cast<const T*>(this)->vertex0.x,
|
||||||
|
static_cast<const T*>(this)->vertex0.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr SizeI16 get_rect_size() const {
|
constexpr SizeI16 get_rect_size() const {
|
||||||
return SizeI16::create(
|
return SizeI16::create(
|
||||||
static_cast<const T*>(this)->vertex1.x - static_cast<const T*>(this)->vertex0.x,
|
static_cast<const T*>(this)->vertex1.x - static_cast<const T*>(this)->vertex0.x,
|
||||||
|
|
|
@ -264,7 +264,19 @@ namespace JabyEngine {
|
||||||
return Area(this->position.sub(this->size.width/2, this->size.height/2), this->size);
|
return Area(this->position.sub(this->size.width/2, this->size.height/2), this->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr Position<T> get_top_left() const {
|
||||||
|
return this->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Position<T> get_top_right() const {
|
||||||
|
return this->position.add(this->size.width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
constexpr Position<T> get_bottom_left() const {
|
constexpr Position<T> get_bottom_left() const {
|
||||||
|
return this->position.add(0, this->size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr Position<T> get_bottom_right() const {
|
||||||
return this->position.move(this->size.width, this->size.height);
|
return this->position.move(this->size.width, this->size.height);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue