A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartParam.hh
1#pragma once
2
3#include <egg/math/Vector.hh>
4
5namespace Kinoko::Kart {
6
8struct BSP {
10 struct Hitbox {
13 f32 radius;
14 u16 wallsOnly;
15 u16 tireCollisionIdx;
16 };
17 STATIC_ASSERT(sizeof(Hitbox) == 0x18);
18
20 struct Wheel {
21 u16 enable;
22 f32 springStiffness;
23 f32 dampingFactor;
24 f32 maxTravel;
25 EGG::Vector3f relPosition;
26 f32 xRot;
27 f32 wheelRadius;
28 f32 sphereRadius;
29 u32 _28;
30 };
31 STATIC_ASSERT(sizeof(Wheel) == 0x2c);
32
33 BSP();
34 BSP(EGG::RamStream &stream);
35
36 void read(EGG::RamStream &stream);
37
38 f32 initialYPos;
39 std::array<Hitbox, 16> hitboxes;
41 f32 angVel0Factor;
42 f32 _1a0;
43 std::array<Wheel, 4> wheels;
46};
47STATIC_ASSERT(sizeof(BSP) == 0x25c);
48
51class KartParam {
52public:
53 struct BikeDisp {
54 BikeDisp();
55 BikeDisp(EGG::RamStream &stream);
56
57 void read(EGG::RamStream &stream);
58
59 f32 m_cameraDistY;
60 u8 _04[0x0c - 0x04];
61 EGG::Vector3f m_handlePos;
62 EGG::Vector3f m_handleRot;
63 u8 _24[0xb0 - 0x24];
64 };
65 STATIC_ASSERT(sizeof(BikeDisp) == 0xB0);
66
67 struct KartDisp {
68 KartDisp();
69 KartDisp(EGG::RamStream &stream);
70
71 void read(EGG::RamStream &stream);
72
73 f32 m_cameraDistY;
74 u8 _004[0x150 - 0x004];
75 };
76 STATIC_ASSERT(sizeof(KartDisp) == 0x150);
77
79 struct Stats {
81 enum class Body {
82 Four_Wheel_Kart = 0,
86 };
87
89 enum class DriftType {
90 Outside_Drift_Kart = 0,
91 Outside_Drift_Bike = 1,
92 Inside_Drift_Bike = 2,
93 };
94
95 Stats();
96 Stats(EGG::RamStream &stream);
97
98 void read(EGG::RamStream &stream);
100
101 Body body;
102 DriftType driftType;
103 WeightClass weightClass;
104 f32 _00c;
105
106 f32 weight;
107 f32 bumpDeviationLevel;
108 f32 speed;
110 f32 tilt;
111 std::array<f32, 4> accelerationStandardA;
112 std::array<f32, 3> accelerationStandardT;
113 std::array<f32, 2> accelerationDriftA;
114 std::array<f32, 1> accelerationDriftT;
121 f32 driftOutsideTargetAngle;
122 f32 driftOutsideDecrement;
124 std::array<f32, 32> kclSpeed;
125 std::array<f32, 32> kclRot;
130 f32 maxNormalAcceleration;
131 f32 megaScale;
132 f32 shrinkScale;
133 };
134 STATIC_ASSERT(sizeof(Stats) == 0x18c);
135
139
140 void read(EGG::RamStream &stream);
141
142 f32 fov;
143 f32 dist;
144 f32 posY;
145 f32 targetPosY;
146 };
147
148 KartParam(Character character, Vehicle vehicle, u8 playerIdx);
149 ~KartParam();
150
152 void setTireCount(u16 tireCount) {
153 m_tireCount = tireCount;
154 }
155
156 void setSuspCount(u16 suspCount) {
157 m_suspCount = suspCount;
158 }
160
162 [[nodiscard]] const BSP &bsp() const {
163 return m_bsp;
164 }
165
166 [[nodiscard]] const Stats &stats() const {
167 return m_stats;
168 }
169
170 [[nodiscard]] const BikeDisp &bikeDisp() const {
171 return m_bikeDisp;
172 }
173
174 [[nodiscard]] const KartDisp &kartDisp() const {
175 return m_kartDisp;
176 }
177
179 [[nodiscard]] const KartCameraParam &camera() const {
180 return m_camera;
181 }
182
183 [[nodiscard]] u8 playerIdx() const {
184 return m_playerIdx;
185 }
186
187 [[nodiscard]] bool isBike() const {
188 return m_isBike;
189 }
190
191 [[nodiscard]] bool isVehicleRelativeBike() const {
192 return m_stats.body == Stats::Body::Vehicle_Relative_Bike;
193 }
194
195 [[nodiscard]] u16 suspCount() const {
196 return m_suspCount;
197 }
198
199 [[nodiscard]] u16 tireCount() const {
200 return m_tireCount;
201 }
203
204private:
205 void initStats(Character character, Vehicle vehicle);
206 void initBikeDispParams(Vehicle vehicle);
207 void initKartDispParams(Vehicle vehicle);
208 void initHitboxes(Vehicle vehicle);
209 void initCameraParams(Character character);
210
211 Stats m_stats;
212 BikeDisp m_bikeDisp;
213 KartDisp m_kartDisp;
214 BSP m_bsp;
215 KartCameraParam m_camera;
216 u8 m_playerIdx;
217 bool m_isBike;
218 u16 m_suspCount;
219 u16 m_tireCount;
220};
221
222} // namespace Kinoko::Kart
A stream of data stored in memory.
Definition Stream.hh:83
Houses stats regarding a given character/vehicle combo.
Definition KartParam.hh:51
Pertains to kart-related functionality.
A 3D float vector.
Definition Vector.hh:107
Represents one of the many hitboxes that make up a vehicle.
Definition KartParam.hh:10
EGG::Vector3f position
The relative position of the hitbox.
Definition KartParam.hh:12
u16 enable
Specifies if this is an active hitbox (since BSP always has 16).
Definition KartParam.hh:11
Info pertaining to the suspension, position, etc. of a wheel.
Definition KartParam.hh:20
Houses hitbox and wheel positions, radii, and suspension info.
Definition KartParam.hh:8
EGG::Vector3f cuboids[2]
Mask cuboids for computing moment of inertia.
Definition KartParam.hh:40
u16 rumbleSpeed
Speed of the vehicle body's rumble animation.
Definition KartParam.hh:45
std::array< Hitbox, 16 > hitboxes
Array of vehicle hitboxes, not all of which are active.
Definition KartParam.hh:39
f32 rumbleHeight
Max vertical distance of the vehicle body's rumble animation.
Definition KartParam.hh:44
Various character/vehicle-related handling and speed stats.
Definition KartParam.hh:79
std::array< f32, 32 > kclSpeed
Speed multipliers, indexed using KCL attributes.
Definition KartParam.hh:124
f32 speed
Base full speed of the character/vehicle combo.
Definition KartParam.hh:108
void read(EGG::RamStream &stream)
Parses out the stats for a given KartParam.bin stream.
Definition KartParam.cc:93
f32 driftReactivity
A weight applied to turn radius when drifting.
Definition KartParam.hh:120
std::array< f32, 32 > kclRot
Rotation scalars, indexed using KCL attributes.
Definition KartParam.hh:125
f32 weight
Contrary to popular belief, this does not affect gravity.
Definition KartParam.hh:106
f32 driftManualTightness
Affects turn radius when manual drifting.
Definition KartParam.hh:118
void applyCharacterBonus(EGG::RamStream &stream)
Applies character stats on top of the kart stats.
Definition KartParam.cc:141
DriftType
The type of drift (inside/outside).
Definition KartParam.hh:89
u32 miniTurbo
The framecount duration of a charged mini-turbo.
Definition KartParam.hh:123
f32 driftAutomaticTightness
Affects turn radius when automatic drifting.
Definition KartParam.hh:119
f32 handlingManualTightness
Affects turn radius when manual and not drifting.
Definition KartParam.hh:115
Body
The body style of the vehicle. Basically the number of wheels.
Definition KartParam.hh:81
@ Three_Wheel_Kart
Used by Blue Falcon.
@ Handle_Relative_Bike
Used by most bikes.
@ Four_Wheel_Kart
Used by most karts.
f32 handlingAutomaticTightness
Affects turn radius when auto and not drifting.
Definition KartParam.hh:116
f32 turningSpeed
Speed decrement percentage of the vehicle when handling.
Definition KartParam.hh:109
f32 handlingReactivity
A weight applied to turn radius when not drifting.
Definition KartParam.hh:117