* Compile works now

* Update menus

* Update CMakeLists.txt

* Add Ship

* Impl hm ship actors

* Update HM course
This commit is contained in:
MegaMech
2025-02-10 15:05:53 -07:00
committed by GitHub
parent a6ecc276e9
commit 6a629fcaa9
23 changed files with 34480 additions and 1 deletions
+61
View File
@@ -0,0 +1,61 @@
#include "Ship.h"
#include <libultra/gbi.h>
extern "C" {
#include "common_structs.h"
#include "math_util.h"
#include "main.h"
#include "courses/harbour/ghostship_model.h"
#include "courses/harbour/ship2_model.h"
#include "courses/harbour/ship3_model.h"
}
AShip::AShip(FVector pos, AShip::Skin skin) {
Spawn = pos;
Spawn.y += 10;
switch(skin) {
case GHOSTSHIP:
_skin = ghostship_Plane_mesh;
break;
case SHIP2:
_skin = ship2_SoH_mesh;
break;
case SHIP3:
_skin = ship3_2Ship_mesh;
break;
}
}
void AShip::Tick() {
static float angle = 0.0f; // Keeps track of the ship's rotation around the circle
float radius = 150.0f; // The radius of the circular path
float speed = 0.01f; // Speed of rotation
angle += speed; // Increment the angle to move in a circle
// Update the position based on a circular path
Pos.x = Spawn.x + radius * cosf(angle);
Pos.z = Spawn.z + radius * sinf(angle);
// Rotate to face forward along the circle
Rot.yaw = -static_cast<int16_t>(angle * (32768.0f / M_PI / 2.0f));
}
void AShip::Draw(Camera *camera) {
Mat4 shipMtx;
Vec3f hullPos = {Pos.x, Pos.y, Pos.z};
Vec3s hullRot = {Rot.pitch, Rot.yaw, Rot.roll};
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
mtxf_pos_rotation_xyz(shipMtx, hullPos, hullRot);
mtxf_scale(shipMtx, 0.4);
if (render_set_position(shipMtx, 0) != 0) {
gSPDisplayList(gDisplayListHead++, _skin);
}
}
bool AShip::IsMod() { return true; }
+34
View File
@@ -0,0 +1,34 @@
#pragma once
#include <libultraship.h>
#include <libultra/gbi.h>
#include "engine/Actor.h"
#include "CoreMath.h"
extern "C" {
#include "common_structs.h"
#include "assets/other_textures.h"
}
class AShip : public AActor {
public:
enum Skin {
GHOSTSHIP,
SHIP2,
SHIP3,
};
explicit AShip(FVector pos, AShip::Skin);
virtual ~AShip() = default;
virtual void Tick() override;
virtual void Draw(Camera*) override;
virtual bool IsMod() override;
FVector Spawn;
FVector Pos;
FRotation Rot = {0, 0, 0};
private:
Gfx* _skin;
};
+80
View File
@@ -0,0 +1,80 @@
#include "SpaghettiShip.h"
#include <libultra/gbi.h>
extern "C" {
#include "common_structs.h"
#include "math_util.h"
#include "main.h"
#include "courses/harbour/ship_model.h"
}
ASpaghettiShip::ASpaghettiShip(FVector pos) {
Spawn = pos;
Spawn.y += 10;
}
void ASpaghettiShip::Tick() {
static float angle = 0.0f; // Keeps track of the ship's rotation around the circle
float radius = 150.0f; // The radius of the circular path
float speed = 0.01f; // Speed of rotation
angle += speed; // Increment the angle to move in a circle
// Update the position based on a circular path
Pos.x = Spawn.x + radius * cosf(angle);
Pos.z = Spawn.z + radius * sinf(angle);
// Rotate to face forward along the circle
Rot.yaw = -static_cast<int16_t>(angle * (32768.0f / M_PI / 2.0f));
WheelRot.pitch += 500;
}
void ASpaghettiShip::Draw(Camera *camera) {
Mat4 shipMtx;
Mat4 objectMtx;
Mat4 resultMtx;
Vec3f hullPos = {Pos.x, Pos.y, Pos.z};
Vec3s hullRot = {Rot.pitch, Rot.yaw, Rot.roll};
Vec3s rot = {WheelRot.pitch, WheelRot.yaw, WheelRot.roll};
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
// empty/null mtx as a base
mtxf_pos_rotation_xyz(shipMtx, hullPos, hullRot);
mtxf_scale(shipMtx, 0.4);
if (render_set_position(shipMtx, 0) != 0) {}
// Render the ships hull
Vec3f hullPos2 = {0, 0, 0};
mtxf_translate(objectMtx, hullPos2);
mtxf_multiplication(resultMtx, shipMtx, objectMtx);
if (render_set_position(resultMtx, 3) != 0) {
gSPDisplayList(gDisplayListHead++, ship1_Spaghetti_mesh);
}
// Front tyre
Vec3f pos = {0, 0, 110};
mtxf_rotate_x(shipMtx, WheelRot.pitch);
mtxf_translate(objectMtx, pos);
mtxf_multiplication(resultMtx, shipMtx, objectMtx);
if (render_set_position(resultMtx, 3) != 0) {
gSPDisplayList(gDisplayListHead++, wheels_Spaghetti_002_mesh);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
}
// Back tyre
Vec3f pos2 = {0, 0, -165};
mtxf_rotate_x(shipMtx, WheelRot.pitch);
mtxf_translate(objectMtx, pos2);
mtxf_multiplication(resultMtx, shipMtx, objectMtx);
if (render_set_position(resultMtx, 3) != 0) {
gSPDisplayList(gDisplayListHead++, wheels_Spaghetti_002_mesh);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
}
}
bool ASpaghettiShip::IsMod() { return true; }
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <libultraship.h>
#include <libultra/gbi.h>
#include "engine/Actor.h"
#include "CoreMath.h"
extern "C" {
#include "common_structs.h"
#include "assets/other_textures.h"
}
class ASpaghettiShip : public AActor {
public:
explicit ASpaghettiShip(FVector pos);
virtual ~ASpaghettiShip() = default;
virtual void Tick() override;
virtual void Draw(Camera*) override;
virtual bool IsMod() override;
FVector Spawn;
FVector Pos;
FRotation Rot = {0, 0, 0};
FRotation WheelRot = {0, 0, 0};
private:
f32 scale;
};
+49
View File
@@ -0,0 +1,49 @@
#include "Starship.h"
#include <libultra/gbi.h>
extern "C" {
#include "common_structs.h"
#include "math_util.h"
#include "main.h"
#include "courses/harbour/starship_model.h"
}
AStarship::AStarship(FVector pos) {
Spawn = pos;
}
void AStarship::Tick() {
static float angle = 0.0f;
float radius = 150.0f;
float speed = 0.01f;
angle += speed;
// Move relative to the initial position
Pos.x = Spawn.x + radius * cosf(angle);
Pos.z = Spawn.z + radius * sinf(angle);
// Keep y from changing (or adjust it if necessary)
Pos.y = Spawn.y;
// Rotate to face forward along the circle
Rot.yaw = angle * (180.0f / M_PI) + 90.0f;
}
void AStarship::Draw(Camera *camera) {
Mat4 shipMtx;
Vec3f hullPos = {Pos.x, Pos.y, Pos.z};
Vec3s hullRot = {Rot.pitch, Rot.yaw, Rot.roll};
gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
mtxf_pos_rotation_xyz(shipMtx, hullPos, hullRot);
mtxf_scale(shipMtx, 1.5);
if (render_set_position(shipMtx, 0) != 0) {
gSPDisplayList(gDisplayListHead++, starship_Cube_mesh);
}
}
bool AStarship::IsMod() { return true; }
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include <libultraship.h>
#include <libultra/gbi.h>
#include "engine/Actor.h"
#include "CoreMath.h"
extern "C" {
#include "common_structs.h"
#include "assets/other_textures.h"
}
class AStarship : public AActor {
public:
explicit AStarship(FVector pos);
virtual ~AStarship() = default;
virtual void Tick() override;
virtual void Draw(Camera*) override;
virtual bool IsMod() override;
FVector Spawn;
FVector Pos;
FRotation Rot = {0, 0, 0};
};