Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
KartPhysics.hh
1
#pragma once
2
3
#include "game/kart/CollisionGroup.hh"
4
#include "game/kart/KartDynamics.hh"
5
#include "game/kart/KartParam.hh"
6
7
#include <egg/math/Matrix.hh>
8
9
namespace
Kinoko::Kart
{
10
13
class
KartPhysics {
14
public
:
15
KartPhysics(
bool
isBike);
16
~KartPhysics();
17
18
void
reset();
19
void
updatePose
();
20
21
void
calc
(f32 dt, f32 maxSpeed,
const
EGG::Vector3f
&scale,
bool
air);
22
24
void
setPos(
const
EGG::Vector3f
&pos) {
25
m_pos = pos;
26
}
27
28
void
setVelocity(
const
EGG::Vector3f
&vel) {
29
m_velocity
= vel;
30
}
31
32
void
set_fc(f32 val) {
33
m_fc = val;
34
}
35
37
void
composeStuntRot(
const
EGG::Quatf
&rot) {
38
m_instantaneousStuntRot *= rot;
39
}
40
42
void
composeExtraRot(
const
EGG::Quatf
&rot) {
43
m_instantaneousExtraRot *= rot;
44
}
45
47
void
composeDecayingStuntRot(
const
EGG::Quatf
&rot) {
48
m_decayingStuntRot *= rot;
49
}
50
52
void
composeDecayingExtraRot(
const
EGG::Quatf
&rot) {
53
m_decayingExtraRot
*= rot;
54
}
55
57
void
composeMovingObjVel(
const
EGG::Vector3f
&vel, f32 t) {
58
m_movingObjVel += (vel - m_movingObjVel) * t;
59
dynamics()->setMovingObjVel(m_movingObjVel);
60
}
61
63
void
composeDecayingMovingObjVel(f32 floorScalar, f32 airScalar,
bool
floor) {
64
m_movingObjVel *= floor ? floorScalar : airScalar;
65
dynamics()->setMovingObjVel(m_movingObjVel);
66
}
67
69
void
composeMovingRoadVel(
const
EGG::Vector3f
&vel, f32 t) {
70
m_movingRoadVel += (vel - m_movingRoadVel) * t;
71
dynamics()->setMovingRoadVel(m_movingRoadVel);
72
}
73
74
void
shiftDecayMovingRoadVel(
const
EGG::Vector3f
&v, f32 maxPullSpeed);
75
77
void
decayMovingRoadVel(f32 floorScalar, f32 airScalar,
bool
floor) {
78
m_movingRoadVel *= floor ? floorScalar : airScalar;
79
m_movingRoadVel.y = 0.0f;
80
dynamics()->setMovingRoadVel(m_movingRoadVel);
81
}
82
84
void
clearDecayingRot() {
85
m_decayingStuntRot = EGG::Quatf::ident;
86
m_decayingExtraRot
= EGG::Quatf::ident;
87
}
89
91
[[nodiscard]]
KartDynamics
*dynamics() {
92
return
m_dynamics;
93
}
94
95
[[nodiscard]]
const
KartDynamics
*dynamics()
const
{
96
return
m_dynamics;
97
}
98
99
[[nodiscard]]
const
EGG::Matrix34f
&pose()
const
{
100
return
m_pose
;
101
}
102
103
[[nodiscard]]
CollisionGroup
*hitboxGroup() {
104
return
m_hitboxGroup;
105
}
106
107
[[nodiscard]]
const
EGG::Vector3f
&xAxis()
const
{
108
return
m_xAxis
;
109
}
110
111
[[nodiscard]]
const
EGG::Vector3f
&yAxis()
const
{
112
return
m_yAxis
;
113
}
114
115
[[nodiscard]]
const
EGG::Vector3f
&zAxis()
const
{
116
return
m_zAxis
;
117
}
118
119
[[nodiscard]]
const
EGG::Vector3f
&pos()
const
{
120
return
m_pos;
121
}
122
123
[[nodiscard]] f32 fc()
const
{
124
return
m_fc;
125
}
127
128
[[nodiscard]]
static
KartPhysics *Create(
const
KartParam
¶m);
129
130
private
:
131
KartDynamics
*m_dynamics;
132
CollisionGroup
*m_hitboxGroup;
133
EGG::Vector3f
m_pos;
134
EGG::Quatf
m_decayingStuntRot;
135
EGG::Quatf
m_instantaneousStuntRot;
136
EGG::Quatf
m_specialRot;
138
EGG::Quatf
m_decayingExtraRot
;
139
EGG::Quatf
m_instantaneousExtraRot;
140
EGG::Quatf
m_extraRot;
141
EGG::Vector3f
m_movingObjVel;
142
EGG::Vector3f
m_movingRoadVel;
143
EGG::Matrix34f
m_pose
;
144
EGG::Vector3f
m_xAxis
;
145
EGG::Vector3f
m_yAxis
;
146
EGG::Vector3f
m_zAxis
;
147
EGG::Vector3f
m_velocity
;
148
f32 m_fc;
149
};
150
151
}
// namespace Kinoko::Kart
Kinoko::EGG::Matrix34f
A 3 x 4 matrix.
Definition
Matrix.hh:10
Kinoko::Kart::CollisionGroup
Houses hitbox and collision info for an object (body or wheel).
Definition
CollisionGroup.hh:122
Kinoko::Kart::KartDynamics
State management for most components of a kart's physics.
Definition
KartDynamics.hh:12
Kinoko::Kart::KartParam
Houses stats regarding a given character/vehicle combo.
Definition
KartParam.hh:51
Kinoko::Kart::KartPhysics::m_zAxis
EGG::Vector3f m_zAxis
The third column of the pose.
Definition
KartPhysics.hh:146
Kinoko::Kart::KartPhysics::m_velocity
EGG::Vector3f m_velocity
Copied from KartDynamics.
Definition
KartPhysics.hh:147
Kinoko::Kart::KartPhysics::m_yAxis
EGG::Vector3f m_yAxis
The second column of the pose.
Definition
KartPhysics.hh:145
Kinoko::Kart::KartPhysics::m_pose
EGG::Matrix34f m_pose
The kart's current rotation and position.
Definition
KartPhysics.hh:143
Kinoko::Kart::KartPhysics::calc
void calc(f32 dt, f32 maxSpeed, const EGG::Vector3f &scale, bool air)
Computes trick rotation and calls to KartDynamics::calc().
Definition
KartPhysics.cc:56
Kinoko::Kart::KartPhysics::m_decayingExtraRot
EGG::Quatf m_decayingExtraRot
Rotation that occurs when landing from a trick.
Definition
KartPhysics.hh:138
Kinoko::Kart::KartPhysics::m_xAxis
EGG::Vector3f m_xAxis
The first column of the pose.
Definition
KartPhysics.hh:144
Kinoko::Kart::KartPhysics::updatePose
void updatePose()
Constructs a transformation matrix from rotation and position.
Definition
KartPhysics.cc:44
Kinoko::Kart
Pertains to kart-related functionality.
Definition
BoxColManager.hh:14
Kinoko::EGG::Quatf
A quaternion, used to represent 3D rotation.
Definition
Quat.hh:12
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
game
kart
KartPhysics.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0