summaryrefslogtreecommitdiff
path: root/src/engine/StaticMeshActor.cpp
blob: aa11cd037fbbdebe4ebc242e7d3e9153fcf1664e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "StaticMeshActor.h"
#include <libultra/gbi.h>
#include "Matrix.h"

extern "C" {
#include "main.h"
#include "racing/math_util.h"
#include "math_util_2.h"
}

StaticMeshActor::StaticMeshActor(std::string name, FVector pos, IRotator rot, FVector scale, std::string model, int32_t* collision) : Name(name), Pos(pos), Rot(rot), Scale(scale), Model(""), CollisionMesh(collision) {
    Name = "StaticMesh";
    ResourceName = "hm:static_mesh";

}

void StaticMeshActor::Draw() {
    Mat4 mtx;
    gSPSetGeometryMode(gDisplayListHead++, G_SHADING_SMOOTH);
    gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING);
    if (!Model.empty()) {
        ApplyMatrixTransformations(mtx, Pos, Rot, Scale);
        if (render_set_position(mtx, 0) != 0) {
            gSPDisplayList(gDisplayListHead++, (Gfx*)Model.c_str());
        }
    }
}

void StaticMeshActor::Destroy() {
    bPendingDestroy = true;
}