A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
Field::ObjectWanwan Class Referencefinal

#include <ObjectWanwan.hh>

Description

Represents Chain Chomps chained to a stake that attack in a limited arc.

Definition at line 35 of file ObjectWanwan.hh.

Inheritance diagram for Field::ObjectWanwan:

Public Member Functions

 ObjectWanwan (const System::MapdataGeoObj &params)
 
void init () override
 
void calc () override
 
u32 loadFlags () const override
 
Kart::Reaction onCollision (Kart::KartObject *kartObj, Kart::Reaction reactionOnKart, Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override
 
- Public Member Functions inherited from Field::ObjectCollidable
 ObjectCollidable (const System::MapdataGeoObj &params)
 
 ObjectCollidable (const char *name, const EGG::Vector3f &pos, const EGG::Vector3f &rot, const EGG::Vector3f &scale)
 
void load () override
 
void calcCollisionTransform () override
 
f32 getCollisionRadius () const override
 Finds the radius that fits fully in a BoxColUnit.
 
virtual void loadAABB (f32 maxSpeed)
 
virtual void loadAABB (f32 radius, f32 maxSpeed)
 
virtual void processKartReactions (Kart::KartObject *kartObj, Kart::Reaction &reactionOnKart, Kart::Reaction &reactionOnObj)
 
virtual void onWallCollision (Kart::KartObject *, const EGG::Vector3f &)
 
virtual void onObjectCollision (Kart::KartObject *)
 
virtual bool checkCollision (ObjectCollisionBase *lhs, EGG::Vector3f &dist)
 
virtual const EGG::Vector3fgetCollisionTranslation () const
 
virtual ObjectCollisionBasecollision () const
 
- Public Member Functions inherited from Field::ObjectBase
 ObjectBase (const System::MapdataGeoObj &params)
 
 ObjectBase (const char *name, const EGG::Vector3f &pos, const EGG::Vector3f &rot, const EGG::Vector3f &scale)
 
virtual void calcModel ()
 
virtual const char * getResources () const
 
virtual void loadGraphics ()
 
virtual void loadAnims ()
 
virtual void loadRail ()
 
virtual const char * getName () const
 
virtual const char * getKclName () const
 
virtual void resize (f32 radius, f32 maxSpeed)
 
virtual void unregisterCollision ()
 
virtual void disableCollision () const
 
virtual void enableCollision () const
 
virtual const BoxColUnitgetUnit () const
 
const RailInterpolatorrailInterpolator () const
 
virtual const EGG::Vector3fgetPosition () const
 
virtual ObjectId id () const
 
const EGG::Vector3fpos () const
 
void setPos (const EGG::Vector3f &pos)
 
void setScale (const EGG::Vector3f &scale)
 
void setTransform (const EGG::Matrix34f &mat)
 
const EGG::Vector3fscale () const
 

Private Member Functions

void enterWait ()
 
void enterAttack ()
 
void enterBack ()
 
void calcWait ()
 
void calcAttack ()
 
void calcBack ()
 
void calcPos ()
 
void calcCollision ()
 
void calcMat ()
 
void calcChainAttachMat ()
 
void calcSpeed ()
 
void calcBounce ()
 
void calcWanderTimer ()
 
void calcWanderEnd ()
 
void calcChain ()
 
void calcTangent (f32 t)
 
void calcUp (f32 t)
 
void calcRandomTarget ()
 
void initTransformKeyframes ()
 
void calcAttackPos ()
 
void calcChainAttachPos (EGG::Matrix34f mat)
 

Static Private Member Functions

static f32 CrossXZ (const EGG::Vector3f &v0, const EGG::Vector3f &v1, const EGG::Vector3f &v2)
 
static void SampleHermiteInterp (f32 start, f32 end, f32 startTangent, f32 endTangent, std::span< f32 > dst)
 

Private Attributes

EGG::Vector3f m_vel
 
EGG::Vector3f m_accel
 
f32 m_speed
 
f32 m_pitch
 
EGG::Vector3f m_tangent
 
EGG::Vector3f m_up
 
EGG::Vector3f m_targetUp
 
std::array< EGG::Matrix34f, 15 > m_transformKeyframes
 
const f32 m_chainLength
 
const f32 m_attackDistance
 
const f32 m_attackArcTargetX
 
const f32 m_attackArcTargetZ
 
u32 m_chainCount
 
EGG::Vector3f m_chainAttachPos
 Where the chain attaches to the Chain Chomp.
 
EGG::Vector3f m_initPos
 
EGG::Vector3f m_anchor
 Effectively the position of the wooden stake.
 
EGG::Vector3f m_attackArcCenter
 
bool m_touchingFloor
 
bool m_chainTaut
 Chain Chomp cannot move further because the chain is fully taut.
 
u32 m_frame
 Counts up every frame.
 
EGG::Vector3f m_target
 Where the chain chomp is currently moving towards.
 
EGG::Vector3f m_targetDir
 
bool m_retarget
 Tracks whether the target position has changed in the wait state.
 
u32 m_wanderTimer
 How long the chain chomp has been wandering for.
 
bool m_attackStill
 True when lurched forward and stationary.
 
u32 m_idleDuration
 
f32 m_attackArc
 Half of size of the arc the chain chomp can lurch within (in degrees)
 
EGG::Vector3f m_backDir
 
EGG::Matrix34f m_chainAttachMat
 Represents the position and rotation of where the Chain Chomp attaches to the chain.
 

Static Private Attributes

static constexpr f32 SCALE = 2.0f
 
static constexpr EGG::Vector3f GRAVITY = EGG::Vector3f(0.0f, 2.5f, 0.0f)
 
static constexpr f32 CHAIN_LENGTH = 135.0f
 
static constexpr std::array< StateManagerEntry, 3 > STATE_ENTRIES
 

Additional Inherited Members

- Public Types inherited from Field::ObjectBase
enum class  eFlags {
  Position = 0 ,
  Rotation = 1 ,
  Matrix = 2 ,
  Scale = 3
}
 
typedef EGG::TBitFlag< u16, eFlags > Flags
 
- Protected Member Functions inherited from Field::ObjectCollidable
void createCollision () override
 
virtual const EGG::Vector3fcollisionCenter () const
 
void registerManagedObject ()
 
- Protected Member Functions inherited from Field::ObjectBase
void calcTransform ()
 
void calcRotLock ()
 
void linkAnims (const std::span< const char * > &names, const std::span< Render::AnmType > types)
 
void setMatrixTangentTo (const EGG::Vector3f &up, const EGG::Vector3f &tangent)
 
void setMatrixFromOrthonormalBasisAndPos (const EGG::Vector3f &v)
 
- Protected Member Functions inherited from Field::StateManager
 StateManager (void *obj, const std::span< const StateManagerEntry > &entries)
 
void calc ()
 
- Static Protected Member Functions inherited from Field::ObjectBase
static f32 CheckPointAgainstLineSegment (const EGG::Vector3f &point, const EGG::Vector3f &a, const EGG::Vector3f &b)
 Calculates on what side of line segment ab point lies.
 
static EGG::Vector3f RotateXZByYaw (f32 angle, const EGG::Vector3f &v)
 Rotates a vector around the Y-axis and returns the XZ-plane portion of the vector.
 
static EGG::Vector3f RotateAxisAngle (f32 angle, const EGG::Vector3f &axis, const EGG::Vector3f &v1)
 
static void SetRotTangentHorizontal (EGG::Matrix34f &mat, const EGG::Vector3f &up, const EGG::Vector3f &tangent)
 
static EGG::Matrix34f OrthonormalBasis (const EGG::Vector3f &v)
 
static EGG::Matrix34f RailOrthonormalBasis (const RailInterpolator &railInterpolator)
 
static EGG::Vector3f AdjustVecForward (f32 sidewaysScalar, f32 forwardScalar, f32 minSpeed, const EGG::Vector3f &src, EGG::Vector3f forward)
 
static f32 CalcParabolicDisplacement (f32 initVel, f32 accel, u32 frame)
 Solves the standard kinematic equation \(y(t) = v_0\, t - \frac{1}{2} a t^{2}\).
 
static EGG::Vector3f Interpolate (f32 t, const EGG::Vector3f &v0, const EGG::Vector3f &v1)
 
- Protected Attributes inherited from Field::ObjectCollidable
ObjectCollisionBasem_collision
 
- Protected Attributes inherited from Field::ObjectBase
Render::DrawMdlm_drawMdl
 
Abstract::g3d::ResFilem_resFile
 
ObjectId m_id
 
RailInterpolatorm_railInterpolator
 
BoxColUnitm_boxColUnit
 
Flags m_flags
 
EGG::Vector3f m_pos
 
EGG::Vector3f m_scale
 
EGG::Vector3f m_rot
 
bool m_rotLock
 
EGG::Matrix34f m_transform
 
const System::MapdataGeoObjm_mapObj
 
- Protected Attributes inherited from Field::StateManager
u16 m_currentStateId
 
s32 m_nextStateId
 
u32 m_currentFrame
 
std::span< u16m_entryIds
 
std::span< const StateManagerEntrym_entries
 
void * m_obj
 

Constructor & Destructor Documentation

◆ ObjectWanwan()

Field::ObjectWanwan::ObjectWanwan ( const System::MapdataGeoObj & params)
0x806E4224

Definition at line 15 of file ObjectWanwan.cc.

Member Function Documentation

◆ calc()

void Field::ObjectWanwan::calc ( )
overridevirtual0x806E4F2C

Reimplemented from Field::ObjectBase.

Definition at line 99 of file ObjectWanwan.cc.

◆ calcAttack()

void Field::ObjectWanwan::calcAttack ( )
private0x806E6F6C

Definition at line 225 of file ObjectWanwan.cc.

◆ calcAttackPos()

void Field::ObjectWanwan::calcAttackPos ( )
private0x806E9084

Definition at line 453 of file ObjectWanwan.cc.

◆ calcBack()

void Field::ObjectWanwan::calcBack ( )
private0x806E7494

Definition at line 275 of file ObjectWanwan.cc.

◆ calcBounce()

void Field::ObjectWanwan::calcBounce ( )
private0x806E794C

Definition at line 382 of file ObjectWanwan.cc.

◆ calcChain()

void Field::ObjectWanwan::calcChain ( )
inlineprivate0x806E7BA4

Definition at line 80 of file ObjectWanwan.hh.

◆ calcChainAttachMat()

void Field::ObjectWanwan::calcChainAttachMat ( )
private0x806E5EDC

Definition at line 352 of file ObjectWanwan.cc.

◆ calcChainAttachPos()

void Field::ObjectWanwan::calcChainAttachPos ( EGG::Matrix34f mat)
private

Definition at line 476 of file ObjectWanwan.cc.

◆ calcCollision()

void Field::ObjectWanwan::calcCollision ( )
private0x806E5A8C

Definition at line 304 of file ObjectWanwan.cc.

◆ calcMat()

void Field::ObjectWanwan::calcMat ( )
private0x806E5D70

Definition at line 334 of file ObjectWanwan.cc.

◆ calcPos()

void Field::ObjectWanwan::calcPos ( )
private0x806E59BC

Definition at line 296 of file ObjectWanwan.cc.

◆ calcRandomTarget()

void Field::ObjectWanwan::calcRandomTarget ( )
private0x806E87C8

Definition at line 412 of file ObjectWanwan.cc.

◆ calcSpeed()

void Field::ObjectWanwan::calcSpeed ( )
private0x806E78B0

Definition at line 367 of file ObjectWanwan.cc.

◆ calcTangent()

void Field::ObjectWanwan::calcTangent ( f32 t)
private0x806E7E38

Definition at line 392 of file ObjectWanwan.cc.

◆ calcUp()

void Field::ObjectWanwan::calcUp ( f32 t)
private0x806E7F64

Definition at line 402 of file ObjectWanwan.cc.

◆ calcWait()

void Field::ObjectWanwan::calcWait ( )
private0x806E63A4

Definition at line 188 of file ObjectWanwan.cc.

◆ calcWanderEnd()

void Field::ObjectWanwan::calcWanderEnd ( )
inlineprivate0x806E7B7C

Definition at line 73 of file ObjectWanwan.hh.

◆ calcWanderTimer()

void Field::ObjectWanwan::calcWanderTimer ( )
inlineprivate0x806E79E4

Definition at line 68 of file ObjectWanwan.hh.

◆ CrossXZ()

static f32 Field::ObjectWanwan::CrossXZ ( const EGG::Vector3f & v0,
const EGG::Vector3f & v1,
const EGG::Vector3f & v2 )
inlinestaticnodiscardprivate0x806B38A8

Definition at line 94 of file ObjectWanwan.hh.

◆ enterAttack()

void Field::ObjectWanwan::enterAttack ( )
private0x806E6EB0

Definition at line 156 of file ObjectWanwan.cc.

◆ enterBack()

void Field::ObjectWanwan::enterBack ( )
private0x806E73C4

Definition at line 172 of file ObjectWanwan.cc.

◆ enterWait()

void Field::ObjectWanwan::enterWait ( )
private0x806E6208

Definition at line 129 of file ObjectWanwan.cc.

◆ init()

void Field::ObjectWanwan::init ( )
overridevirtual0x806E4B9C

Reimplemented from Field::ObjectBase.

Definition at line 77 of file ObjectWanwan.cc.

◆ initTransformKeyframes()

void Field::ObjectWanwan::initTransformKeyframes ( )
private0x806E8A60

Definition at line 426 of file ObjectWanwan.cc.

◆ loadFlags()

u32 Field::ObjectWanwan::loadFlags ( ) const
inlinenodiscardoverridevirtual0x806E94BC

Reimplemented from Field::ObjectBase.

Definition at line 44 of file ObjectWanwan.hh.

◆ onCollision()

Kart::Reaction Field::ObjectWanwan::onCollision ( Kart::KartObject * kartObj,
Kart::Reaction reactionOnKart,
Kart::Reaction reactionOnObj,
EGG::Vector3f & hitDepth )
overridevirtual0x806E526C

Reimplemented from Field::ObjectCollidable.

Definition at line 119 of file ObjectWanwan.cc.

◆ SampleHermiteInterp()

void Field::ObjectWanwan::SampleHermiteInterp ( f32 start,
f32 end,
f32 startTangent,
f32 endTangent,
std::span< f32 > dst )
staticprivate0x806E8F4C

Definition at line 487 of file ObjectWanwan.cc.

Member Data Documentation

◆ CHAIN_LENGTH

f32 Field::ObjectWanwan::CHAIN_LENGTH = 135.0f
staticconstexprprivate

Definition at line 138 of file ObjectWanwan.hh.

◆ GRAVITY

EGG::Vector3f Field::ObjectWanwan::GRAVITY = EGG::Vector3f(0.0f, 2.5f, 0.0f)
staticconstexprprivate

Definition at line 137 of file ObjectWanwan.hh.

◆ m_accel

EGG::Vector3f Field::ObjectWanwan::m_accel
private

Definition at line 103 of file ObjectWanwan.hh.

◆ m_anchor

EGG::Vector3f Field::ObjectWanwan::m_anchor
private

Effectively the position of the wooden stake.

Definition at line 117 of file ObjectWanwan.hh.

◆ m_attackArc

f32 Field::ObjectWanwan::m_attackArc
private

Half of size of the arc the chain chomp can lurch within (in degrees)

Definition at line 128 of file ObjectWanwan.hh.

◆ m_attackArcCenter

EGG::Vector3f Field::ObjectWanwan::m_attackArcCenter
private

Definition at line 118 of file ObjectWanwan.hh.

◆ m_attackArcTargetX

const f32 Field::ObjectWanwan::m_attackArcTargetX
private

Definition at line 112 of file ObjectWanwan.hh.

◆ m_attackArcTargetZ

const f32 Field::ObjectWanwan::m_attackArcTargetZ
private

Definition at line 113 of file ObjectWanwan.hh.

◆ m_attackDistance

const f32 Field::ObjectWanwan::m_attackDistance
private

Definition at line 111 of file ObjectWanwan.hh.

◆ m_attackStill

bool Field::ObjectWanwan::m_attackStill
private

True when lurched forward and stationary.

Definition at line 126 of file ObjectWanwan.hh.

◆ m_backDir

EGG::Vector3f Field::ObjectWanwan::m_backDir
private

Definition at line 129 of file ObjectWanwan.hh.

◆ m_chainAttachMat

EGG::Matrix34f Field::ObjectWanwan::m_chainAttachMat
private

Represents the position and rotation of where the Chain Chomp attaches to the chain.

This is normally housed in the DrawMdl's ScnObj, but for the purposes of time trial physics, it can be defined here for simplicity.

Definition at line 134 of file ObjectWanwan.hh.

◆ m_chainAttachPos

EGG::Vector3f Field::ObjectWanwan::m_chainAttachPos
private

Where the chain attaches to the Chain Chomp.

Definition at line 115 of file ObjectWanwan.hh.

◆ m_chainCount

u32 Field::ObjectWanwan::m_chainCount
private

Definition at line 114 of file ObjectWanwan.hh.

◆ m_chainLength

const f32 Field::ObjectWanwan::m_chainLength
private

Definition at line 110 of file ObjectWanwan.hh.

◆ m_chainTaut

bool Field::ObjectWanwan::m_chainTaut
private

Chain Chomp cannot move further because the chain is fully taut.

Definition at line 120 of file ObjectWanwan.hh.

◆ m_frame

u32 Field::ObjectWanwan::m_frame
private

Counts up every frame.

Definition at line 121 of file ObjectWanwan.hh.

◆ m_idleDuration

u32 Field::ObjectWanwan::m_idleDuration
private

Definition at line 127 of file ObjectWanwan.hh.

◆ m_initPos

EGG::Vector3f Field::ObjectWanwan::m_initPos
private

Definition at line 116 of file ObjectWanwan.hh.

◆ m_pitch

f32 Field::ObjectWanwan::m_pitch
private

Definition at line 105 of file ObjectWanwan.hh.

◆ m_retarget

bool Field::ObjectWanwan::m_retarget
private

Tracks whether the target position has changed in the wait state.

Definition at line 124 of file ObjectWanwan.hh.

◆ m_speed

f32 Field::ObjectWanwan::m_speed
private

Definition at line 104 of file ObjectWanwan.hh.

◆ m_tangent

EGG::Vector3f Field::ObjectWanwan::m_tangent
private

Definition at line 106 of file ObjectWanwan.hh.

◆ m_target

EGG::Vector3f Field::ObjectWanwan::m_target
private

Where the chain chomp is currently moving towards.

Definition at line 122 of file ObjectWanwan.hh.

◆ m_targetDir

EGG::Vector3f Field::ObjectWanwan::m_targetDir
private

Definition at line 123 of file ObjectWanwan.hh.

◆ m_targetUp

EGG::Vector3f Field::ObjectWanwan::m_targetUp
private

Definition at line 108 of file ObjectWanwan.hh.

◆ m_touchingFloor

bool Field::ObjectWanwan::m_touchingFloor
private

Definition at line 119 of file ObjectWanwan.hh.

◆ m_transformKeyframes

std::array<EGG::Matrix34f, 15> Field::ObjectWanwan::m_transformKeyframes
private

Definition at line 109 of file ObjectWanwan.hh.

◆ m_up

EGG::Vector3f Field::ObjectWanwan::m_up
private

Definition at line 107 of file ObjectWanwan.hh.

◆ m_vel

EGG::Vector3f Field::ObjectWanwan::m_vel
private

Definition at line 102 of file ObjectWanwan.hh.

◆ m_wanderTimer

u32 Field::ObjectWanwan::m_wanderTimer
private

How long the chain chomp has been wandering for.

Definition at line 125 of file ObjectWanwan.hh.

◆ SCALE

f32 Field::ObjectWanwan::SCALE = 2.0f
staticconstexprprivate

Definition at line 136 of file ObjectWanwan.hh.

◆ STATE_ENTRIES

std::array<StateManagerEntry, 3> Field::ObjectWanwan::STATE_ENTRIES
staticconstexprprivate
Initial value:
= {{
{StateEntry<ObjectWanwan, &ObjectWanwan::enterWait, &ObjectWanwan::calcWait>(0)},
{StateEntry<ObjectWanwan, &ObjectWanwan::enterAttack, &ObjectWanwan::calcAttack>(1)},
{StateEntry<ObjectWanwan, &ObjectWanwan::enterBack, &ObjectWanwan::calcBack>(2)},
}}

Definition at line 140 of file ObjectWanwan.hh.