Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
ObjectWanwan.hh
1
#pragma once
2
3
#include "game/field/StateManager.hh"
4
#include "game/field/obj/ObjectCollidable.hh"
5
6
namespace
Kinoko::Field
{
7
9
class
ObjectWanwanPile final :
public
ObjectCollidable {
10
public
:
12
ObjectWanwanPile(
const
EGG::Vector3f
&pos,
const
EGG::Vector3f
&rot,
const
EGG::Vector3f
&scale)
13
: ObjectCollidable(
"pile"
, pos, rot, scale) {}
14
16
~ObjectWanwanPile()
override
=
default
;
17
19
[[nodiscard]] u32 loadFlags()
const override
{
20
return
1;
21
}
22
24
[[nodiscard]]
const
char
*getResources()
const override
{
25
return
"wanwan"
;
26
}
27
29
[[nodiscard]]
const
char
*getKclName()
const override
{
30
return
"pile"
;
31
}
32
};
33
35
class
ObjectWanwan final :
public
ObjectCollidable,
public
StateManager {
36
public
:
37
ObjectWanwan(
const
System::MapdataGeoObj
¶ms);
38
~ObjectWanwan()
override
;
39
40
void
init()
override
;
41
void
calc()
override
;
42
44
[[nodiscard]] u32 loadFlags()
const override
{
45
return
3;
46
}
47
48
Kart::Reaction onCollision(
Kart::KartObject
*kartObj, Kart::Reaction reactionOnKart,
49
Kart::Reaction reactionOnObj,
EGG::Vector3f
&hitDepth)
override
;
50
51
private
:
52
void
enterWait();
53
void
enterAttack();
54
void
enterBack();
55
56
void
calcWait();
57
void
calcAttack();
58
void
calcBack();
59
60
void
calcPos();
61
void
calcCollision();
62
void
calcMat();
63
void
calcChainAttachMat();
64
void
calcSpeed();
65
void
calcBounce();
66
68
void
calcWanderTimer() {
69
calcWanderEnd();
70
}
71
73
void
calcWanderEnd() {
74
if
(
m_wanderTimer
++ >= m_idleDuration) {
75
m_nextStateId = 1;
76
}
77
}
78
80
void
calcChain() {
81
if
(
m_chainAttachMat
.base(3).squaredLength() > std::numeric_limits<f32>::epsilon()) {
82
calcChainAttachPos(
m_chainAttachMat
);
83
}
84
}
85
86
void
calcTangent(f32 t);
87
void
calcUp(f32 t);
88
void
calcRandomTarget();
89
void
initTransformKeyframes();
90
void
calcAttackPos();
91
void
calcChainAttachPos(
EGG::Matrix34f
mat);
92
94
[[nodiscard]]
static
f32 CrossXZ(
const
EGG::Vector3f
&v0,
const
EGG::Vector3f
&v1,
95
const
EGG::Vector3f
&v2) {
96
return
(v2.x - v1.x) * (v0.z - v1.z) - (v0.x - v1.x) * (v2.z - v1.z);
97
}
98
99
static
void
SampleHermiteInterp(f32 start, f32 end, f32 startTangent, f32 endTangent,
100
std::span<f32> dst);
101
102
EGG::Vector3f
m_vel;
103
EGG::Vector3f
m_accel;
104
f32 m_speed;
105
f32 m_pitch;
106
EGG::Vector3f
m_tangent;
107
EGG::Vector3f
m_up;
108
EGG::Vector3f
m_targetUp;
109
std::array<EGG::Matrix34f, 15> m_transformKeyframes;
110
const
f32 m_chainLength;
111
const
f32 m_attackDistance;
112
const
f32 m_attackArcTargetX;
113
const
f32 m_attackArcTargetZ;
114
u32 m_chainCount;
115
EGG::Vector3f
m_chainAttachPos
;
116
EGG::Vector3f
m_initPos;
117
EGG::Vector3f
m_anchor
;
118
EGG::Vector3f
m_attackArcCenter;
119
bool
m_touchingFloor;
120
bool
m_chainTaut
;
121
u32
m_frame
;
122
EGG::Vector3f
m_target
;
123
EGG::Vector3f
m_targetDir;
124
bool
m_retarget
;
125
u32
m_wanderTimer
;
126
bool
m_attackStill
;
127
u32 m_idleDuration;
128
f32
m_attackArc
;
129
EGG::Vector3f
m_backDir;
130
134
EGG::Matrix34f
m_chainAttachMat
;
135
136
static
constexpr
f32 SCALE = 2.0f;
137
static
constexpr
EGG::Vector3f
GRAVITY =
EGG::Vector3f
(0.0f, 2.5f, 0.0f);
138
static
constexpr
f32 CHAIN_LENGTH = 135.0f;
139
140
static
constexpr
std::array<StateManagerEntry, 3> STATE_ENTRIES = {{
141
{StateEntry<ObjectWanwan, &ObjectWanwan::enterWait, &ObjectWanwan::calcWait>(0)},
142
{StateEntry<ObjectWanwan, &ObjectWanwan::enterAttack, &ObjectWanwan::calcAttack>(1)},
143
{StateEntry<ObjectWanwan, &ObjectWanwan::enterBack, &ObjectWanwan::calcBack>(2)},
144
}};
145
};
146
147
}
// namespace Kinoko::Field
Kinoko::EGG::Matrix34f
A 3 x 4 matrix.
Definition
Matrix.hh:10
Kinoko::Field::ObjectWanwan::m_target
EGG::Vector3f m_target
Where the chain chomp is currently moving towards.
Definition
ObjectWanwan.hh:122
Kinoko::Field::ObjectWanwan::m_anchor
EGG::Vector3f m_anchor
Effectively the position of the wooden stake.
Definition
ObjectWanwan.hh:117
Kinoko::Field::ObjectWanwan::m_attackStill
bool m_attackStill
True when lurched forward and stationary.
Definition
ObjectWanwan.hh:126
Kinoko::Field::ObjectWanwan::m_retarget
bool m_retarget
Tracks whether the target position has changed in the wait state.
Definition
ObjectWanwan.hh:124
Kinoko::Field::ObjectWanwan::m_attackArc
f32 m_attackArc
Half of size of the arc the chain chomp can lurch within (in degrees).
Definition
ObjectWanwan.hh:128
Kinoko::Field::ObjectWanwan::m_chainTaut
bool m_chainTaut
Chain Chomp cannot move further because the chain is fully taut.
Definition
ObjectWanwan.hh:120
Kinoko::Field::ObjectWanwan::m_wanderTimer
u32 m_wanderTimer
How long the chain chomp has been wandering for.
Definition
ObjectWanwan.hh:125
Kinoko::Field::ObjectWanwan::m_chainAttachPos
EGG::Vector3f m_chainAttachPos
Where the chain attaches to the Chain Chomp.
Definition
ObjectWanwan.hh:115
Kinoko::Field::ObjectWanwan::m_frame
u32 m_frame
Counts up every frame.
Definition
ObjectWanwan.hh:121
Kinoko::Field::ObjectWanwan::m_chainAttachMat
EGG::Matrix34f m_chainAttachMat
Represents the position and rotation of where the Chain Chomp attaches to the chain.
Definition
ObjectWanwan.hh:134
Kinoko::Kart::KartObject
The highest level abstraction for a kart.
Definition
KartObject.hh:11
Kinoko::System::MapdataGeoObj
Definition
MapdataGeoObj.hh:9
Kinoko::Field
Pertains to collision.
Definition
BoxColManager.cc:10
Kinoko::EGG::Vector3f
A 3D float vector.
Definition
Vector.hh:107
game
field
obj
ObjectWanwan.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0