wavelength 1.0.0
Loading...
Searching...
No Matches
tnlsabretrail.h
Go to the documentation of this file.
1#pragma once
2
3#include "gfx/ship.h"
4#include "math/color.h"
5#include "math/interpolator.h"
6#include "math/transform.h"
7#include "math/vector2.h"
8#include "math/vector3.h"
9#include "rnd/rndline.h"
10#include "script/dataarray.h"
11
21public:
28
30 static constexpr int kFirstSegmentPoint = 2;
31
33 static constexpr int kNoHead = -4;
34
43 TnlSabreTrail(int nPlayer, Ship *pShip);
44
52
61 void LoadConfig(DataArray *pConfig, DataArray *pDefaults);
62
70 void AddSegment(const Vector3 *pPos);
71
78 void Start();
79
87 void Stop(bool bForce);
88
95 void Clear();
96
104 void SetShowing(bool bShowing);
105
114 void Scratch(float flTick, float flDuration);
115
123
132
142 void Update(float flBlend, const Transform &xfm, const Vector3 *pAxis);
143
153 static float SweepTarget(float flFrom, float flSweep);
154
164 static float Wobble(float flFrom, float flSweep);
165
172 static float sSampleFrequency;
173
180 static float sSampleDuration;
181
188
191 return mRibbon;
192 }
193
194private:
195 float mSweep;
196 float mNeedleLength;
197 unsigned char mReserved08[0x8]; // +0x08 to +0x0f are not yet identified.
198 Color mColor;
199 Color mPointColors[3];
200 RndLine *mRibbon;
201 Vector3 mRibbonOffset;
202 LinearInterpolator mNeedle;
203 int mState;
204 int mRestart;
205 int mSweeping;
206 int mNewSegment;
207 int mSampling;
208 int mStopPending;
209 float mSampleEnd;
210 int mNumPoints;
211 int mHead;
212};
Reference-counted array of script data nodes.
Definition dataarray.h:20
Straight-line interpolator.
Definition interpolator.h:99
Line through points, drawn as a ribbon of constant screen width that faces the camera.
Definition rndline.h:26
Ship of one player, which rides the tracks of the tunnel and fires beams at the gems.
Definition ship.h:41
void StartSample()
Start a sample, sweeps of the needle to random places for sSampleDuration ticks.
void SetShowing(bool bShowing)
Show or hide the ribbon.
void Clear()
Move every point of the ribbon to the origin.
float UpdateSample()
Advance the sample, starting the next sweep when one ends.
void Update(float flBlend, const Transform &xfm, const Vector3 *pAxis)
Place the needle at the ship and draw the segment the needle is in.
static constexpr int kNoHead
The value of mHead while no segment is drawn.
Definition tnlsabretrail.h:33
~TnlSabreTrail()
Destroy the trail.
static float SweepTarget(float flFrom, float flSweep)
Report the place a sweep ends at, the other side from the place it starts at.
static float Wobble(float flFrom, float flSweep)
Report the place a random sweep of a sample ends at, on the other side from where it starts.
void Scratch(float flTick, float flDuration)
Sweep the needle to the other side for a note of a scratch, unless a sample sweeps it.
static Vector2 sSampleSweepTicks
The shortest and the longest ticks of a sweep of a sample, sample_sweep_duration.
Definition tnlsabretrail.h:187
void Stop(bool bForce)
Stop drawing segments, or wait for the sample in progress to end.
void LoadConfig(DataArray *pConfig, DataArray *pDefaults)
Load the settings of the ribbon and of the sweeps of the needle, and make the ribbon blank.
static float sSampleDuration
The ticks of a sample, sample_duration.
Definition tnlsabretrail.h:180
TnlSabreTrail(int nPlayer, Ship *pShip)
Take the scratch ribbon of a ship and the colours of its points.
static float sSampleFrequency
The angle per tick of the envelope of a sample, sample_envelope_frequency.
Definition tnlsabretrail.h:172
void AddSegment(const Vector3 *pPos)
Start the next segment of the ribbon, wrapping back to the first one past the last.
State
The values of mState.
Definition tnlsabretrail.h:23
@ kStateDrawing
Definition tnlsabretrail.h:25
@ kStateHidden
Definition tnlsabretrail.h:24
@ kStateShown
Definition tnlsabretrail.h:26
void Start()
Start drawing segments.
RndLine * GetRibbon() const
Definition tnlsabretrail.h:190
static constexpr int kFirstSegmentPoint
The first point of the segments, after the two points of the needle.
Definition tnlsabretrail.h:30
Linear colour with four float components.
Definition color.h:12
Affine transform stored as three basis rows and a translation row.
Definition transform.h:18
Two-component vector, used for texture coordinates.
Definition vector2.h:12
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14