Impl hm ship actors

This commit is contained in:
MegaMech
2025-02-09 16:35:28 -07:00
parent 0f0f295a39
commit 46f69d3ef9
17 changed files with 10609 additions and 42 deletions
+18 -38
View File
@@ -6,12 +6,26 @@ extern "C" {
#include "common_structs.h"
#include "math_util.h"
#include "main.h"
#include "courses/ship_model.h"
#include "courses/hm64/ghostship_model.h"
#include "courses/hm64/ship2_model.h"
#include "courses/hm64/ship3_model.h"
}
AShip::AShip(FVector pos) {
AShip::AShip(FVector pos, AShip::Skin skin) {
Pos = pos;
Pos.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() {
@@ -27,55 +41,21 @@ void AShip::Tick() {
// Rotate to face forward along the circle
Rot.yaw = -static_cast<int16_t>(angle * (32768.0f / M_PI / 2.0f));
WheelRot.pitch += 500;
}
void AShip::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);
if (render_set_position(shipMtx, 0) != 0) {
gSPDisplayList(gDisplayListHead++, _skin);
}
}
bool AShip::IsMod() { return true; }