A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectBase.hh
1#pragma once
2
3#include "game/field/BoxColManager.hh"
4#include "game/field/RailInterpolator.hh"
5#include "game/field/obj/ObjectId.hh"
6
7#include "game/render/DrawMdl.hh"
8
9#include "game/system/map/MapdataGeoObj.hh"
10
11#include <egg/math/Matrix.hh>
12
13namespace Field {
14
16public:
17 ObjectBase(const System::MapdataGeoObj &params);
18 virtual ~ObjectBase();
19
20 virtual void init() {}
21 virtual void calc() {}
22 virtual void calcModel();
23 virtual void load() = 0;
24 [[nodiscard]] virtual const char *getResources() const;
25 virtual void loadGraphics();
26 virtual void loadAnims() {}
27 virtual void createCollision() = 0;
28 virtual void loadRail();
29 virtual void calcCollisionTransform() = 0;
30
32 [[nodiscard]] virtual u32 loadFlags() const {
33 // TODO: This references LOD to determine load flags
34 return 0;
35 }
36
37 [[nodiscard]] virtual const char *getKclName() const;
38
40 [[nodiscard]] virtual const EGG::Vector3f &getPosition() const {
41 return m_pos;
42 }
43
45 [[nodiscard]] virtual f32 getCollisionRadius() const {
46 return 100.0f;
47 }
48
50 [[nodiscard]] ObjectId id() const {
51 return m_id;
52 }
53
54 void setPos(const EGG::Vector3f &pos) {
55 m_flags |= 0x1;
56 m_pos = pos;
57 }
58
59protected:
60 void calcTransform();
61 void linkAnims(const std::span<const char *> &names, const std::span<Render::AnmType> types);
62 void setMatrixTangentTo(const EGG::Vector3f &up, const EGG::Vector3f &tangent);
63
64 static EGG::Vector3f RotateAxisAngle(f32 angle, const EGG::Vector3f &axis,
65 const EGG::Vector3f &v1);
66 static void SetRotTangentHorizontal(EGG::Matrix34f &mat, const EGG::Vector3f &up,
67 const EGG::Vector3f &tangent);
68
70 [[nodiscard]] static EGG::Vector3f Interpolate(f32 t, const EGG::Vector3f &v0,
71 const EGG::Vector3f &v1) {
72 return v0 + (v1 - v0) * t;
73 }
74
75 Render::DrawMdl *m_drawMdl;
76 Abstract::g3d::ResFile *m_resFile;
77 ObjectId m_id;
78 RailInterpolator *m_railInterpolator;
79 BoxColUnit *m_boxColUnit;
80 u16 m_flags;
81 EGG::Vector3f m_pos;
82 EGG::Vector3f m_rot;
83 EGG::Vector3f m_scale;
84 EGG::Matrix34f m_transform;
85 const System::MapdataGeoObj *m_mapObj;
86};
87
88} // namespace Field
Represents a binary resource file which contains object models, textures, and animations.
Definition ResFile.hh:15
A 3 x 4 matrix.
Definition Matrix.hh:8
Pertains to collision.
A 3D float vector.
Definition Vector.hh:87
A representation of the boundaries of an entity that has dynamic collision.