Kinoko
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/core/BitFlag.hh>
12
#include <egg/math/Matrix.hh>
13
14
namespace
Field
{
15
16
class
ObjectBase
{
17
public
:
18
enum class
eFlags {
19
Position = 0,
20
Rotation = 1,
21
Matrix = 2,
22
Scale = 3,
23
};
24
typedef
EGG::TBitFlag<u16, eFlags>
Flags
;
25
26
ObjectBase
(
const
System::MapdataGeoObj
¶ms);
27
ObjectBase
(
const
char
*name,
const
EGG::Vector3f
&pos,
const
EGG::Vector3f
&rot,
28
const
EGG::Vector3f
&scale);
29
virtual
~ObjectBase
();
30
31
virtual
void
init() {}
32
virtual
void
calc() {}
33
virtual
void
calcModel();
34
virtual
void
load() = 0;
35
[[nodiscard]]
virtual
const
char
*getResources()
const
;
36
virtual
void
loadGraphics();
37
virtual
void
loadAnims() {}
38
virtual
void
createCollision() = 0;
39
virtual
void
loadRail();
40
virtual
void
calcCollisionTransform() = 0;
41
42
[[nodiscard]]
virtual
const
char
*getName()
const
;
43
45
[[nodiscard]]
virtual
u32
loadFlags()
const
{
46
// TODO: This references LOD to determine load flags
47
return
0;
48
}
49
50
[[nodiscard]]
virtual
const
char
*getKclName()
const
;
51
53
[[nodiscard]]
virtual
const
EGG::Vector3f
&getPosition()
const
{
54
return
m_pos;
55
}
56
58
[[nodiscard]]
virtual
f32 getCollisionRadius()
const
{
59
return
100.0f;
60
}
61
63
[[nodiscard]]
virtual
ObjectId id()
const
{
64
return
m_id;
65
}
66
67
[[nodiscard]]
const
EGG::Vector3f
&pos()
const
{
68
return
m_pos;
69
}
70
71
void
setPos(
const
EGG::Vector3f
&pos) {
72
m_flags.
setBit
(eFlags::Position);
73
m_pos = pos;
74
}
75
76
protected
:
77
void
calcTransform();
78
void
linkAnims(
const
std::span<const char *> &names,
const
std::span<Render::AnmType> types);
79
void
setMatrixTangentTo(
const
EGG::Vector3f
&up,
const
EGG::Vector3f
&tangent);
80
81
[[nodiscard]]
static
EGG::Vector3f
RotateAxisAngle(f32 angle,
const
EGG::Vector3f
&axis,
82
const
EGG::Vector3f
&v1);
83
static
void
SetRotTangentHorizontal(
EGG::Matrix34f
&mat,
const
EGG::Vector3f
&up,
84
const
EGG::Vector3f
&tangent);
85
[[nodiscard]]
static
EGG::Matrix34f
OrthonormalBasis(
const
EGG::Vector3f
&v);
86
88
[[nodiscard]]
static
EGG::Vector3f
Interpolate(f32 t,
const
EGG::Vector3f
&v0,
89
const
EGG::Vector3f
&v1) {
90
return
v0 + (v1 - v0) * t;
91
}
92
93
Render::DrawMdl
*m_drawMdl;
94
Abstract::g3d::ResFile
*m_resFile;
95
ObjectId m_id;
96
RailInterpolator
*m_railInterpolator;
97
BoxColUnit
*m_boxColUnit;
98
Flags
m_flags;
99
EGG::Vector3f
m_pos;
100
EGG::Vector3f
m_rot;
101
EGG::Vector3f
m_scale;
102
EGG::Matrix34f
m_transform;
103
const
System::MapdataGeoObj
*m_mapObj;
104
};
105
106
}
// namespace Field
Abstract::g3d::ResFile
Represents a binary resource file which contains object models, textures, and animations.
Definition
ResFile.hh:15
EGG::Matrix34f
A 3 x 4 matrix.
Definition
Matrix.hh:8
Field::ObjectBase
Definition
ObjectBase.hh:16
Field::RailInterpolator
Definition
RailInterpolator.hh:13
Render::DrawMdl
Definition
DrawMdl.hh:7
System::MapdataGeoObj
Definition
MapdataGeoObj.hh:9
uint32_t
Field
Pertains to collision.
Definition
BoxColManager.cc:8
EGG::TBitFlag
Wrapper around an integral type with an enum corresponding to its bits.
Definition
BitFlag.hh:16
EGG::TBitFlag::setBit
constexpr TBitFlag< T, E > & setBit(Es... es)
Sets the corresponding bits for the provided enum values.
Definition
BitFlag.hh:57
EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:87
Field::BoxColUnit
A representation of the boundaries of an entity that has dynamic collision.
Definition
BoxColManager.hh:38
game
field
obj
ObjectBase.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.12.0