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

Description

Definition at line 16 of file ObjectBase.hh.

Inheritance diagram for Kinoko::Field::ObjectBase:

Public Types

enum class  eFlags {
  Position = 0 ,
  Rotation = 1 ,
  Matrix = 2 ,
  Scale = 3
}
enum class  eLoadFlags {
  Calc = 0 ,
  Draw = 1 ,
  AlwaysRecalc = 2
}
 Describes whether the object needs to be updated every frame. More...
typedef EGG::TBitFlag< u16, eFlags > Flags
typedef EGG::TBitFlag< u8, eLoadFlags > LoadFlags
 A bitfield of eLoadFlags that represents the update requirements of the object.

Public Member Functions

 ObjectBase (const System::MapdataGeoObj &params)
 ObjectBase (const char *name, const EGG::Vector3f &pos, const EGG::Vector3f &rot, const EGG::Vector3f &scale)
virtual void init ()
virtual void calc ()
virtual void calcModel ()
virtual void load ()=0
virtual const char * getResources () const
virtual void loadGraphics ()
virtual void loadAnims ()
virtual void createCollision ()=0
virtual void loadRail ()
virtual void calcCollisionTransform ()=0
virtual const char * getName () const
virtual LoadFlags loadFlags () const
 Returns a bitmask indicating which lifecycle hooks should be called for the object.
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 BoxColUnit * getUnit () const
const RailInterpolator * railInterpolator () const
virtual const EGG::Vector3f & getPosition () const
virtual f32 getCollisionRadius () const
virtual ObjectId id () const
void setPos (const EGG::Vector3f &pos)
void addPos (const EGG::Vector3f &v)
void subPos (const EGG::Vector3f &v)
void setScale (const EGG::Vector3f &scale)
void setScale (f32 scale)
void setRot (const EGG::Vector3f &rot)
void setRotNoFlag (const EGG::Vector3f &rot)
void addRot (const EGG::Vector3f &v)
void subRot (const EGG::Vector3f &v)
void setTransform (const EGG::Matrix34f &mat)
const EGG::Vector3f & pos () const
const EGG::Vector3f & scale () const
const EGG::Vector3f & rot () const
const EGG::Matrix34f & transform ()

Protected Member Functions

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)

Static Protected Member Functions

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::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

Render::DrawMdl * m_drawMdl
Abstract::g3d::ResFile * m_resFile
ObjectId m_id
RailInterpolator * m_railInterpolator
BoxColUnit * m_boxColUnit
const System::MapdataGeoObj * m_mapObj

Private Types

enum class  PendingRotation {
  None ,
  TangentTo ,
  OrthonormalBasis
}
 The source of a rotation for m_transform which has not been computed yet. More...

Private Member Functions

void resolvePendingRotation ()
 Computes the rotation columns of m_transform from the PendingRotation, if any.

Private Attributes

Flags m_flags
EGG::Vector3f m_pos
EGG::Vector3f m_scale
EGG::Vector3f m_rot
bool m_rotLock
EGG::Matrix34f m_transform
PendingRotation m_pendingRot
 Rotation of m_transform yet to be computed.
EGG::Vector3f m_pendingWork0
 Up/forward vector depending on the PendingRotation type.
EGG::Vector3f m_pendingWork1
 Tangent vector of the PendingRotation.

Member Typedef Documentation

◆ Flags

typedef EGG::TBitFlag<u16, eFlags> Kinoko::Field::ObjectBase::Flags

Definition at line 24 of file ObjectBase.hh.

◆ LoadFlags

A bitfield of eLoadFlags that represents the update requirements of the object.

Definition at line 36 of file ObjectBase.hh.

Member Enumeration Documentation

◆ eFlags

enum class Kinoko::Field::ObjectBase::eFlags
strong

Definition at line 18 of file ObjectBase.hh.

◆ eLoadFlags

Describes whether the object needs to be updated every frame.

For the current purposes of Kinoko, we really only care about Calc. The others are effectively unused.

Enumerator
Calc 

The state of the object should be recalculated every frame.

Draw 

The object should be re-drawn every frame.

AlwaysRecalc 

The object's BoxColUnit will always be recalculated.

Definition at line 29 of file ObjectBase.hh.

◆ PendingRotation

The source of a rotation for m_transform which has not been computed yet.

Kinoko-specific optimization. Many objects recompute their rotation every frame, but it is usually only read when checking collision against the kart, so the rotation columns of m_transform are only computed when the matrix is next read.

Enumerator
None 

m_transform is up-to-date

TangentTo 

SetRotTangentHorizontal() with the pending up and tangent

OrthonormalBasis 

OrthonormalBasis() of the pending forward vector

Definition at line 227 of file ObjectBase.hh.

Constructor & Destructor Documentation

◆ ObjectBase() [1/2]

Kinoko::Field::ObjectBase::ObjectBase ( const System::MapdataGeoObj & params)
0x8081F828

Definition at line 16 of file ObjectBase.cc.

◆ ObjectBase() [2/2]

Kinoko::Field::ObjectBase::ObjectBase ( const char * name,
const EGG::Vector3f & pos,
const EGG::Vector3f & rot,
const EGG::Vector3f & scale )
0x8081FB04

Definition at line 26 of file ObjectBase.cc.

◆ ~ObjectBase()

Kinoko::Field::ObjectBase::~ObjectBase ( )
virtual0x8067E3C4

Definition at line 37 of file ObjectBase.cc.

Member Function Documentation

◆ addPos()

void Kinoko::Field::ObjectBase::addPos ( const EGG::Vector3f & v)
inline

Definition at line 117 of file ObjectBase.hh.

◆ addRot()

void Kinoko::Field::ObjectBase::addRot ( const EGG::Vector3f & v)
inline

Definition at line 146 of file ObjectBase.hh.

◆ AdjustVecForward()

EGG::Vector3f Kinoko::Field::ObjectBase::AdjustVecForward ( f32 sidewaysScalar,
f32 forwardScalar,
f32 minSpeed,
const EGG::Vector3f & src,
EGG::Vector3f forward )
staticnodiscardprotected0x807DE934

Definition at line 250 of file ObjectBase.cc.

◆ calc()

virtual void Kinoko::Field::ObjectBase::calc ( )
inlinevirtual

Reimplemented in Kinoko::Field::ObjectCowHerd.

Definition at line 44 of file ObjectBase.hh.

◆ calcModel()

void Kinoko::Field::ObjectBase::calcModel ( )
virtual0x808217B8

Definition at line 44 of file ObjectBase.cc.

◆ CalcParabolicDisplacement()

f32 Kinoko::Field::ObjectBase::CalcParabolicDisplacement ( f32 initVel,
f32 accel,
u32 frame )
inlinestaticnodiscardprotected0x806B59A8

Solves the standard kinematic equation \(y(t) = v_0\, t - \frac{1}{2} a t^{2}\).

Definition at line 204 of file ObjectBase.hh.

◆ calcRotLock()

void Kinoko::Field::ObjectBase::calcRotLock ( )
protected

Definition at line 124 of file ObjectBase.cc.

◆ calcTransform()

void Kinoko::Field::ObjectBase::calcTransform ( )
protected0x80821640

Definition at line 113 of file ObjectBase.cc.

◆ CheckPointAgainstLineSegment()

f32 Kinoko::Field::ObjectBase::CheckPointAgainstLineSegment ( const EGG::Vector3f & point,
const EGG::Vector3f & a,
const EGG::Vector3f & b )
staticnodiscardprotected0x806B38A8

Calculates on what side of line segment ab point lies.

Definition at line 192 of file ObjectBase.cc.

◆ createCollision()

virtual void Kinoko::Field::ObjectBase::createCollision ( )
pure virtual

◆ disableCollision()

virtual void Kinoko::Field::ObjectBase::disableCollision ( ) const
inlinevirtual0x80821DEC

Definition at line 79 of file ObjectBase.hh.

◆ enableCollision()

virtual void Kinoko::Field::ObjectBase::enableCollision ( ) const
inlinevirtual0x80821E00

Definition at line 84 of file ObjectBase.hh.

◆ getCollisionRadius()

virtual f32 Kinoko::Field::ObjectBase::getCollisionRadius ( ) const
inlinenodiscardvirtual0x8080BDC0

◆ getKclName()

const char * Kinoko::Field::ObjectBase::getKclName ( ) const
nodiscardvirtual0x806806DC

Reimplemented in Kinoko::Field::ObjectKinokoUd.

Definition at line 105 of file ObjectBase.cc.

◆ getName()

const char * Kinoko::Field::ObjectBase::getName ( ) const
nodiscardvirtual0x80680784

Definition at line 97 of file ObjectBase.cc.

◆ getPosition()

virtual const EGG::Vector3f & Kinoko::Field::ObjectBase::getPosition ( ) const
inlinenodiscardvirtual0x80681598

Definition at line 98 of file ObjectBase.hh.

◆ getResources()

const char * Kinoko::Field::ObjectBase::getResources ( ) const
nodiscardvirtual0x80680730

Definition at line 49 of file ObjectBase.cc.

◆ getUnit()

virtual const BoxColUnit * Kinoko::Field::ObjectBase::getUnit ( ) const
inlinevirtual0x80680618

Definition at line 89 of file ObjectBase.hh.

◆ id()

virtual ObjectId Kinoko::Field::ObjectBase::id ( ) const
inlinenodiscardvirtual0x80572574

Definition at line 108 of file ObjectBase.hh.

◆ init()

virtual void Kinoko::Field::ObjectBase::init ( )
inlinevirtual

Reimplemented in Kinoko::Field::ObjectCowHerd, and Kinoko::Field::ObjectHeyhoShipManager.

Definition at line 43 of file ObjectBase.hh.

◆ Interpolate()

EGG::Vector3f Kinoko::Field::ObjectBase::Interpolate ( f32 t,
const EGG::Vector3f & v0,
const EGG::Vector3f & v1 )
inlinestaticnodiscardprotected0x8086C098

Definition at line 210 of file ObjectBase.hh.

◆ linkAnims()

void Kinoko::Field::ObjectBase::linkAnims ( const std::span< const char * > & names,
const std::span< Render::AnmType > types )
protected0x80820EB8

Definition at line 133 of file ObjectBase.cc.

◆ loadAnims()

virtual void Kinoko::Field::ObjectBase::loadAnims ( )
inlinevirtual

Reimplemented in Kinoko::Field::ObjectPenguinS.

Definition at line 49 of file ObjectBase.hh.

◆ loadFlags()

virtual LoadFlags Kinoko::Field::ObjectBase::loadFlags ( ) const
inlinenodiscardvirtual0x806BF434

Returns a bitmask indicating which lifecycle hooks should be called for the object.

Returns
No flags set by default

In Kinoko, the only effective behavior of this bitmask is to determine whether calc() should be called. The other bits are unused.

Reimplemented in Kinoko::Field::ObjectAmi, Kinoko::Field::ObjectAurora, Kinoko::Field::ObjectBasabasa, Kinoko::Field::ObjectBasabasaDummy, Kinoko::Field::ObjectBelt, Kinoko::Field::ObjectBird, Kinoko::Field::ObjectBirdLeader, Kinoko::Field::ObjectBoble, Kinoko::Field::ObjectBreakable, Kinoko::Field::ObjectBulldozer, Kinoko::Field::ObjectCarA, Kinoko::Field::ObjectCarTGE, Kinoko::Field::ObjectChoropu, Kinoko::Field::ObjectChoropuGround, Kinoko::Field::ObjectChoropuHoll, Kinoko::Field::ObjectCowFollower, Kinoko::Field::ObjectCowHerd, Kinoko::Field::ObjectCowLeader, Kinoko::Field::ObjectCrab, Kinoko::Field::ObjectCrane, Kinoko::Field::ObjectDokan, Kinoko::Field::ObjectDossun, Kinoko::Field::ObjectDossunTsuibiHolder, Kinoko::Field::ObjectEscalator, Kinoko::Field::ObjectEscalatorGroup, Kinoko::Field::ObjectFireball, Kinoko::Field::ObjectFirebar, Kinoko::Field::ObjectFireRing, Kinoko::Field::ObjectFireSnake, Kinoko::Field::ObjectFireSnakeKid, Kinoko::Field::ObjectFlamePole, Kinoko::Field::ObjectFlamePoleFoot, Kinoko::Field::ObjectFlamePoleV, Kinoko::Field::ObjectHanachan, Kinoko::Field::ObjectHanachanPart, Kinoko::Field::ObjectHeyho, Kinoko::Field::ObjectHeyhoBall, Kinoko::Field::ObjectHeyhoShip, Kinoko::Field::ObjectHighwayManager, Kinoko::Field::ObjectItemboxLine, Kinoko::Field::ObjectItemboxPress, Kinoko::Field::ObjectKinoko, Kinoko::Field::ObjectKoopaBall, Kinoko::Field::ObjectKoopaFigure64, Kinoko::Field::ObjectKuribo, Kinoko::Field::ObjectObakeManager, Kinoko::Field::ObjectPakkunF, Kinoko::Field::ObjectParasolR, Kinoko::Field::ObjectPenguin, Kinoko::Field::ObjectPillar, Kinoko::Field::ObjectPoihanaBase, Kinoko::Field::ObjectPress, Kinoko::Field::ObjectPressSenko, Kinoko::Field::ObjectPropeller, Kinoko::Field::ObjectPsea, Kinoko::Field::ObjectPylon, Kinoko::Field::ObjectRock, Kinoko::Field::ObjectSanbo, Kinoko::Field::ObjectSandcone, Kinoko::Field::ObjectShip64, Kinoko::Field::ObjectSniper, Kinoko::Field::ObjectSunDS, Kinoko::Field::ObjectTownBridge, Kinoko::Field::ObjectTruckWagon, Kinoko::Field::ObjectTruckWagonCart, Kinoko::Field::ObjectTuribashi, Kinoko::Field::ObjectTwistedWay, Kinoko::Field::ObjectVolcanoBall, Kinoko::Field::ObjectVolcanoBallLauncher, Kinoko::Field::ObjectVolcanoPiece, Kinoko::Field::ObjectVolcanoRock, Kinoko::Field::ObjectWanwan, Kinoko::Field::ObjectWanwanPile, Kinoko::Field::ObjectWLWallGC, Kinoko::Field::ObjectWoodboxW, and Kinoko::Field::ObjectWoodboxWSub.

Definition at line 61 of file ObjectBase.hh.

◆ loadGraphics()

void Kinoko::Field::ObjectBase::loadGraphics ( )
virtual0x8081FD10

Definition at line 57 of file ObjectBase.cc.

◆ loadRail()

void Kinoko::Field::ObjectBase::loadRail ( )
virtual0x80820980

Reimplemented in Kinoko::Field::ObjectBird.

Definition at line 75 of file ObjectBase.cc.

◆ OrthonormalBasis()

EGG::Matrix34f Kinoko::Field::ObjectBase::OrthonormalBasis ( const EGG::Vector3f & v)
staticnodiscardprotected0x806B3CA4

Definition at line 227 of file ObjectBase.cc.

◆ pos()

const EGG::Vector3f & Kinoko::Field::ObjectBase::pos ( ) const
inlinenodiscard

Definition at line 167 of file ObjectBase.hh.

◆ railInterpolator()

const RailInterpolator * Kinoko::Field::ObjectBase::railInterpolator ( ) const
inlinenodiscard

Definition at line 93 of file ObjectBase.hh.

◆ resize()

virtual void Kinoko::Field::ObjectBase::resize ( f32 radius,
f32 maxSpeed )
inlinevirtual0x80821DB8

Definition at line 69 of file ObjectBase.hh.

◆ resolvePendingRotation()

void Kinoko::Field::ObjectBase::resolvePendingRotation ( )
private

Computes the rotation columns of m_transform from the PendingRotation, if any.

This produces the same rotation as computing it immediately, since the rotation only depends on the saved up and tangent vectors, and all other writes to m_transform before this point either only touch the translation column or discard the pending rotation.

Definition at line 172 of file ObjectBase.cc.

◆ rot()

const EGG::Vector3f & Kinoko::Field::ObjectBase::rot ( ) const
inlinenodiscard

Definition at line 175 of file ObjectBase.hh.

◆ RotateAxisAngle()

EGG::Vector3f Kinoko::Field::ObjectBase::RotateAxisAngle ( f32 angle,
const EGG::Vector3f & axis,
const EGG::Vector3f & v1 )
staticnodiscardprotected0x806B3AC4

Definition at line 207 of file ObjectBase.cc.

◆ RotateXZByYaw()

EGG::Vector3f Kinoko::Field::ObjectBase::RotateXZByYaw ( f32 angle,
const EGG::Vector3f & v )
staticnodiscardprotected0x806B3900

Rotates a vector around the Y-axis and returns the XZ-plane portion of the vector.

Definition at line 199 of file ObjectBase.cc.

◆ scale()

const EGG::Vector3f & Kinoko::Field::ObjectBase::scale ( ) const
inlinenodiscard

Definition at line 171 of file ObjectBase.hh.

◆ setMatrixFromOrthonormalBasisAndPos()

void Kinoko::Field::ObjectBase::setMatrixFromOrthonormalBasisAndPos ( const EGG::Vector3f & v)
protected0x808218B0

Definition at line 159 of file ObjectBase.cc.

◆ setMatrixTangentTo()

void Kinoko::Field::ObjectBase::setMatrixTangentTo ( const EGG::Vector3f & up,
const EGG::Vector3f & tangent )
protected0x80821910

Definition at line 147 of file ObjectBase.cc.

◆ setPos()

void Kinoko::Field::ObjectBase::setPos ( const EGG::Vector3f & pos)
inline

Definition at line 112 of file ObjectBase.hh.

◆ setRot()

void Kinoko::Field::ObjectBase::setRot ( const EGG::Vector3f & rot)
inline

Definition at line 137 of file ObjectBase.hh.

◆ setRotNoFlag()

void Kinoko::Field::ObjectBase::setRotNoFlag ( const EGG::Vector3f & rot)
inline

Definition at line 142 of file ObjectBase.hh.

◆ SetRotTangentHorizontal()

void Kinoko::Field::ObjectBase::SetRotTangentHorizontal ( EGG::Matrix34f & mat,
const EGG::Vector3f & up,
const EGG::Vector3f & tangent )
staticprotected0x806B41E0

Definition at line 216 of file ObjectBase.cc.

◆ setScale() [1/2]

void Kinoko::Field::ObjectBase::setScale ( const EGG::Vector3f & scale)
inline

Definition at line 127 of file ObjectBase.hh.

◆ setScale() [2/2]

void Kinoko::Field::ObjectBase::setScale ( f32 scale)
inline

Definition at line 132 of file ObjectBase.hh.

◆ setTransform()

void Kinoko::Field::ObjectBase::setTransform ( const EGG::Matrix34f & mat)
inline0x806C296C

Definition at line 159 of file ObjectBase.hh.

◆ subPos()

void Kinoko::Field::ObjectBase::subPos ( const EGG::Vector3f & v)
inline

Definition at line 122 of file ObjectBase.hh.

◆ subRot()

void Kinoko::Field::ObjectBase::subRot ( const EGG::Vector3f & v)
inline

Definition at line 152 of file ObjectBase.hh.

◆ transform()

const EGG::Matrix34f & Kinoko::Field::ObjectBase::transform ( )
inlinenodiscard

Definition at line 179 of file ObjectBase.hh.

◆ unregisterCollision()

virtual void Kinoko::Field::ObjectBase::unregisterCollision ( )
inlinevirtual0x80821DD8

Definition at line 74 of file ObjectBase.hh.

Member Data Documentation

◆ m_boxColUnit

BoxColUnit* Kinoko::Field::ObjectBase::m_boxColUnit
protected

Definition at line 219 of file ObjectBase.hh.

◆ m_drawMdl

Render::DrawMdl* Kinoko::Field::ObjectBase::m_drawMdl
protected

Definition at line 215 of file ObjectBase.hh.

◆ m_flags

Flags Kinoko::Field::ObjectBase::m_flags
private

Definition at line 235 of file ObjectBase.hh.

◆ m_id

ObjectId Kinoko::Field::ObjectBase::m_id
protected

Definition at line 217 of file ObjectBase.hh.

◆ m_mapObj

const System::MapdataGeoObj* Kinoko::Field::ObjectBase::m_mapObj
protected

Definition at line 220 of file ObjectBase.hh.

◆ m_pendingRot

PendingRotation Kinoko::Field::ObjectBase::m_pendingRot
private

Rotation of m_transform yet to be computed.

Definition at line 242 of file ObjectBase.hh.

◆ m_pendingWork0

EGG::Vector3f Kinoko::Field::ObjectBase::m_pendingWork0
private

Up/forward vector depending on the PendingRotation type.

Definition at line 243 of file ObjectBase.hh.

◆ m_pendingWork1

EGG::Vector3f Kinoko::Field::ObjectBase::m_pendingWork1
private

Tangent vector of the PendingRotation.

Definition at line 244 of file ObjectBase.hh.

◆ m_pos

EGG::Vector3f Kinoko::Field::ObjectBase::m_pos
private

Definition at line 236 of file ObjectBase.hh.

◆ m_railInterpolator

RailInterpolator* Kinoko::Field::ObjectBase::m_railInterpolator
protected

Definition at line 218 of file ObjectBase.hh.

◆ m_resFile

Abstract::g3d::ResFile* Kinoko::Field::ObjectBase::m_resFile
protected

Definition at line 216 of file ObjectBase.hh.

◆ m_rot

EGG::Vector3f Kinoko::Field::ObjectBase::m_rot
private

Definition at line 238 of file ObjectBase.hh.

◆ m_rotLock

bool Kinoko::Field::ObjectBase::m_rotLock
private

Definition at line 239 of file ObjectBase.hh.

◆ m_scale

EGG::Vector3f Kinoko::Field::ObjectBase::m_scale
private

Definition at line 237 of file ObjectBase.hh.

◆ m_transform

EGG::Matrix34f Kinoko::Field::ObjectBase::m_transform
private

Definition at line 240 of file ObjectBase.hh.