wavelength 1.0.0
Loading...
Searching...
No Matches
key.h File Reference
#include <vector>
#include "math/color.h"
#include "math/quaternion.h"
#include "math/transform.h"
#include "math/vector2.h"
#include "math/vector3.h"
#include "os/binstream.h"
#include "os/prnstream.h"
Include dependency graph for key.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Key< T >
 One keyframe of an animation channel, a value at a frame. More...

Functions

template<typename T>
int AtFrame (const std::vector< Key< T > > &keys, float fFrame, const Key< T > *&pPrev, const Key< T > *&pNext, float &fRatio)
 Find the keys around a frame.
void Interp (const Vector3 &a, const Vector3 &b, float fRatio, Vector3 &out)
 Blend two vectors, taking either end exactly at a position of 0 or 1.
void Interp (const Vector2 &a, const Vector2 &b, float fRatio, Vector2 &out)
 Blend two two-component vectors, taking either end exactly at a position of 0 or 1.
void Interp (const Color &a, const Color &b, float fRatio, Color &out)
 Blend two colours.
void Interp (float fA, float fB, float fRatio, float &fOut)
 Blend two floats.
template<typename T>
void Interp (T *pA, T *pB, float fRatio, T *&pOut)
 Take the first of two pointers, which do not blend.
template<typename T>
void InterpKeys (const std::vector< Key< T > > &keys, float fFrame, T &out)
 Interpolate keys at a frame.
template<typename T>
float FirstFrame (const std::vector< Key< T > > &keys)
 Report the frame of the first key, or 0 for no keys.
template<typename T>
float LastFrame (const std::vector< Key< T > > &keys)
 Report the frame of the last key, or 0 for no keys.
void WriteKeyValue (BinStream &stream, float fValue)
 Write a float key value.
void WriteKeyValue (BinStream &stream, const Vector3 &v)
 Write a vector key value as three floats.
void WriteKeyValue (BinStream &stream, const Vector2 &v)
 Write a two-component vector key value as two floats.
void WriteKeyValue (BinStream &stream, const Quat &quat)
 Write a quaternion key value as four floats.
void WriteKeyValue (BinStream &stream, const Color &color)
 Write a colour key value as four floats.
void ReadKeyValue (BinStream &stream, float &fValue)
 Read a float key value.
void ReadKeyValue (BinStream &stream, Vector3 &v)
 Read a vector key value as three floats.
void ReadKeyValue (BinStream &stream, Vector2 &v)
 Read a two-component vector key value as two floats.
void ReadKeyValue (BinStream &stream, Quat &quat)
 Read a quaternion key value as four floats.
void ReadKeyValue (BinStream &stream, Color &color)
 Read a colour key value as four floats.
template<typename T>
void WriteKeyValue (BinStream &stream, const std::vector< T > &values)
 Write a list key value as its count followed by each value.
template<typename T>
void ReadKeyValue (BinStream &stream, std::vector< T > &values)
 Read a list key value the list key value writer wrote.
template<typename T>
BinStream & operator<< (BinStream &stream, const Key< T > &key)
 Write a key as its value followed by its frame.
template<typename T>
BinStream & operator>> (BinStream &stream, Key< T > &key)
 Read a key the key writer wrote.
template<typename T>
PrnStream & operator<< (PrnStream &stream, const Key< T > &key)
 Write a key as its frame and its value.

Function Documentation

◆ AtFrame()

template<typename T>
int AtFrame ( const std::vector< Key< T > > & keys,
float fFrame,
const Key< T > *& pPrev,
const Key< T > *& pNext,
float & fRatio )

Find the keys around a frame.

An empty list yields null keys. A frame at or before the first key yields the first key twice, and one at or after the last key yields the last key twice. A frame between keys yields the keys on either side by binary search, with the position between them, unless a key lies exactly on the frame, which is then yielded twice. Every inline expansion in the program follows this order of tests.

Template Parameters
TThe type of the values.
Parameters
keysThe keys, in frame order.
fFrameThe frame.
pPrevReceives the key at or before the frame, or null.
pNextReceives the key at or after the frame, or null.
fRatioReceives the position of the frame between the two keys, from 0 to 1. It is unset for an empty list.
Returns
The index of pNext. For a frame past the last key it is the key count, less one when the frame is exactly the last key's.

◆ Interp() [1/5]

void Interp ( const Vector3 & a,
const Vector3 & b,
float fRatio,
Vector3 & out )
inline

Blend two vectors, taking either end exactly at a position of 0 or 1.

Between the ends the fourth word comes from the second vector.

Parameters
aThe value at 0.
bThe value at 1.
fRatioThe position.
outReceives the blend.

◆ Interp() [2/5]

void Interp ( const Vector2 & a,
const Vector2 & b,
float fRatio,
Vector2 & out )
inline

Blend two two-component vectors, taking either end exactly at a position of 0 or 1.

Parameters
aThe value at 0.
bThe value at 1.
fRatioThe position.
outReceives the blend.

◆ Interp() [3/5]

void Interp ( const Color & a,
const Color & b,
float fRatio,
Color & out )
inline

Blend two colours.

Parameters
aThe value at 0.
bThe value at 1.
fRatioThe position.
outReceives the blend.

◆ Interp() [4/5]

void Interp ( float fA,
float fB,
float fRatio,
float & fOut )
inline

Blend two floats.

Parameters
fAThe value at 0.
fBThe value at 1.
fRatioThe position.
fOutReceives the blend.

◆ Interp() [5/5]

template<typename T>
void Interp ( T * pA,
T * pB,
float fRatio,
T *& pOut )

Take the first of two pointers, which do not blend.

The addresses are of the RndTex instance.

Template Parameters
TThe type pointed at.
Parameters
pAThe value at 0.
pBThe value at 1. The routine ignores it.
fRatioThe position. The routine ignores it.
pOutReceives pA.
Ghidra address:
NTSC-U/C: 0x00232058
Ghidra address:
PAL: 0x0023ac20

◆ InterpKeys()

template<typename T>
void InterpKeys ( const std::vector< Key< T > > & keys,
float fFrame,
T & out )

Interpolate keys at a frame.

Nothing is written for no keys.

Template Parameters
TThe type of the values.
Parameters
keysThe keys.
fFrameThe frame.
outReceives the value.

◆ FirstFrame()

template<typename T>
float FirstFrame ( const std::vector< Key< T > > & keys)

Report the frame of the first key, or 0 for no keys.

Template Parameters
TThe type of the values.
Parameters
keysThe keys.
Returns
The frame.

◆ LastFrame()

template<typename T>
float LastFrame ( const std::vector< Key< T > > & keys)

Report the frame of the last key, or 0 for no keys.

Template Parameters
TThe type of the values.
Parameters
keysThe keys.
Returns
The frame.

◆ WriteKeyValue() [1/6]

void WriteKeyValue ( BinStream & stream,
float fValue )
inline

Write a float key value.

Parameters
streamThe stream to write to.
fValueThe value.

◆ WriteKeyValue() [2/6]

void WriteKeyValue ( BinStream & stream,
const Vector3 & v )
inline

Write a vector key value as three floats.

Parameters
streamThe stream to write to.
vThe value.

◆ WriteKeyValue() [3/6]

void WriteKeyValue ( BinStream & stream,
const Vector2 & v )
inline

Write a two-component vector key value as two floats.

Parameters
streamThe stream to write to.
vThe value.

◆ WriteKeyValue() [4/6]

void WriteKeyValue ( BinStream & stream,
const Quat & quat )
inline

Write a quaternion key value as four floats.

Parameters
streamThe stream to write to.
quatThe value.

◆ WriteKeyValue() [5/6]

void WriteKeyValue ( BinStream & stream,
const Color & color )
inline

Write a colour key value as four floats.

Parameters
streamThe stream to write to.
colorThe value.

◆ ReadKeyValue() [1/6]

void ReadKeyValue ( BinStream & stream,
float & fValue )
inline

Read a float key value.

Parameters
streamThe stream to read from.
fValueReceives the value.

◆ ReadKeyValue() [2/6]

void ReadKeyValue ( BinStream & stream,
Vector3 & v )
inline

Read a vector key value as three floats.

Parameters
streamThe stream to read from.
vReceives the value.

◆ ReadKeyValue() [3/6]

void ReadKeyValue ( BinStream & stream,
Vector2 & v )
inline

Read a two-component vector key value as two floats.

Parameters
streamThe stream to read from.
vReceives the value.

◆ ReadKeyValue() [4/6]

void ReadKeyValue ( BinStream & stream,
Quat & quat )
inline

Read a quaternion key value as four floats.

Parameters
streamThe stream to read from.
quatReceives the value.

◆ ReadKeyValue() [5/6]

void ReadKeyValue ( BinStream & stream,
Color & color )
inline

Read a colour key value as four floats.

Parameters
streamThe stream to read from.
colorReceives the value.

◆ WriteKeyValue() [6/6]

template<typename T>
void WriteKeyValue ( BinStream & stream,
const std::vector< T > & values )

Write a list key value as its count followed by each value.

Each value type has its own instance, one address each.

Template Parameters
TThe type of the values.
Parameters
streamThe stream to write to.
valuesThe value.
Ghidra address:
NTSC-U/C: 0x0038bf40
Ghidra address:
PAL: 0x003fa648
Ghidra address:
NTSC-U/C: 0x0038c0e8
Ghidra address:
PAL: 0x003fa7f0
Ghidra address:
NTSC-U/C: 0x0038c278
Ghidra address:
PAL: 0x003fa980

◆ ReadKeyValue() [6/6]

template<typename T>
void ReadKeyValue ( BinStream & stream,
std::vector< T > & values )

Read a list key value the list key value writer wrote.

Each value type has its own instance, one address each.

Template Parameters
TThe type of the values.
Parameters
streamThe stream to read from.
valuesReceives the value.
Ghidra address:
NTSC-U/C: 0x0038c878
Ghidra address:
PAL: 0x003faf80
Ghidra address:
NTSC-U/C: 0x0038d080
Ghidra address:
PAL: 0x003fb788
Ghidra address:
NTSC-U/C: 0x0038d868
Ghidra address:
PAL: 0x003fbf70

◆ operator<<() [1/2]

template<typename T>
BinStream & operator<< ( BinStream & stream,
const Key< T > & key )

Write a key as its value followed by its frame.

Each value type has its own instance, one address each.

Template Parameters
TThe type of the value.
Parameters
streamThe stream to write to.
keyThe key.
Returns
The stream.
Ghidra address:
NTSC-U/C: 0x00387528
Ghidra address:
PAL: 0x003f5c30
Ghidra address:
NTSC-U/C: 0x00385478
Ghidra address:
PAL: 0x003f3b80
Ghidra address:
NTSC-U/C: 0x003855a8
Ghidra address:
PAL: 0x003f3cb0
Ghidra address:
NTSC-U/C: 0x00392128
Ghidra address:
PAL: 0x00400830
Ghidra address:
NTSC-U/C: 0x0038c000
Ghidra address:
PAL: 0x003fa708
Ghidra address:
NTSC-U/C: 0x0038c190
Ghidra address:
PAL: 0x003fa898
Ghidra address:
NTSC-U/C: 0x0038c350
Ghidra address:
PAL: 0x003faa58

◆ operator>>()

template<typename T>
BinStream & operator>> ( BinStream & stream,
Key< T > & key )

Read a key the key writer wrote.

Each value type has its own instance, one address each.

Template Parameters
TThe type of the value.
Parameters
streamThe stream to read from.
keyReceives the key.
Returns
The stream.
Ghidra address:
NTSC-U/C: 0x00387df8
Ghidra address:
PAL: 0x003f6500
Ghidra address:
NTSC-U/C: 0x00385b30
Ghidra address:
PAL: 0x003f4238
Ghidra address:
NTSC-U/C: 0x00386010
Ghidra address:
PAL: 0x003f4718
Ghidra address:
NTSC-U/C: 0x00392258
Ghidra address:
PAL: 0x00400960
Ghidra address:
NTSC-U/C: 0x0038c978
Ghidra address:
PAL: 0x003fb080
Ghidra address:
NTSC-U/C: 0x0038d170
Ghidra address:
PAL: 0x003fb878
Ghidra address:
NTSC-U/C: 0x0038d978
Ghidra address:
PAL: 0x003fc080

◆ operator<<() [2/2]

template<typename T>
PrnStream & operator<< ( PrnStream & stream,
const Key< T > & key )

Write a key as its frame and its value.

Each value type has its own instance, one address each.

Template Parameters
TThe type of the value.
Parameters
streamThe stream to write to.
keyThe key.
Returns
The stream.
Ghidra address:
NTSC-U/C: 0x00387288
Ghidra address:
PAL: 0x003f5990
Ghidra address:
NTSC-U/C: 0x00385140
Ghidra address:
PAL: 0x003f3848
Ghidra address:
NTSC-U/C: 0x00385290
Ghidra address:
PAL: 0x003f3998
Ghidra address:
NTSC-U/C: 0x003873d8
Ghidra address:
PAL: 0x003f5ae0
Ghidra address:
NTSC-U/C: 0x00391fd8
Ghidra address:
PAL: 0x004006e0
Ghidra address:
NTSC-U/C: 0x0038b940
Ghidra address:
PAL: 0x003fa048
Ghidra address:
NTSC-U/C: 0x0038bb88
Ghidra address:
PAL: 0x003fa290
Ghidra address:
NTSC-U/C: 0x0038bdd0
Ghidra address:
PAL: 0x003fa4d8