38 static constexpr int kNoBar = 100000000;
88 void SetMesh(std::unique_ptr<RndMesh> pMesh) {
89 mMesh = std::move(pMesh);
99 static bool sKeepMeshes;
101 std::unique_ptr<RndMesh> mMesh;
154 return mBaseSections;
159 return mBaseSections;
179 mSections[nSection] = section;
184 mSections = sections;
197 void SetMesh(std::unique_ptr<RndMesh> pMesh) {
198 mMesh = std::move(pMesh);
203 return mCheckpointMat;
212 mCheckpointMat = pMat;
245 mHighlighted = bHighlighted;
273 mPickable = bPickable;
287 mTransparent = bTransparent;
292 return mStartSection;
301 mStartSection = nSection;
305 std::vector<CrossSectionXfm> mBaseSections;
306 std::vector<CrossSectionXfm> mSections;
307 std::unique_ptr<RndMesh> mMesh;
362 mOverlayMode = nMode;
402 unsigned char mPlayers;
457 void Update(
float flTick,
float flDeltaTicks);
538 return mActivatorPosition;
572 mMoveTime = flMoveTime;
585 float mActivatorPosition;
595 std::unique_ptr<TableLinInterpolator> mCamCurve;
596 std::unique_ptr<TableLinInterpolator> mMoveCurve;
621 void *
operator new(
size_t nSize) {
622 return PoolMemAlloc(
static_cast<int>(nSize),
"Tunnel", 0);
630 void operator delete(
void *pBlock) {
667 bool Init(
const std::vector<std::pair<Vector2, Vector2>> *pEdges,
674 const std::vector<Color> *pColors,
687 void Poll(
float flTick,
float flDeltaTicks);
932 std::vector<CrossSectionXfm> *
GetSections(
int nTrack,
int nBar,
bool bDirty);
1014 const Color *pColor);
1146 mShowPanels = bShow;
1151 return mBarsPerTick;
1156 return mSectionsPerBar;
1166 return mMinFirstBar;
1175 mMinFirstBar = nBar;
1204 return mTrackGeometry[nTrack];
1219 std::unique_ptr<TnlPath> mPath;
1222 float mCamMoveSpeed;
1229 int mSectionsPerBar;
1233 std::vector<int> mBarRing;
1234 std::vector<RndMat *> mBarMats;
1235 std::vector<MeshHolder> mMeshes;
1236 std::vector<PanelData> mPanels;
1237 std::vector<TrackData> mTracks;
1238 std::vector<RndMat *> mBarValues;
1240 std::vector<std::unique_ptr<RndMat>> mPassMats;
1242 std::vector<std::unique_ptr<RndMatAnim>> mPassAnims;
1243 unsigned char mReservedC4[0xc];
1247 Color mPassLightColors[2];
1248 int mBarValuesDirty;
1250 std::vector<RndMat *> mPanelMats;
1251 std::vector<Vector3> mTrackOffsets;
1252 std::vector<bool> mTrackOffsetChanged;
1253 std::vector<TrackGeometry> mTrackGeometry;
1255 std::vector<Player> mPlayers;
1258 static constexpr int kDefaultMatThreshold = -16;
1262 kSourceMeshOpaque = 0,
1263 kSourceMeshTransparent = 1,
1264 kSourceMeshCount = 2,
1275 void Clear(
bool bClear);
1283 void RebuildPanels();
1301 void BuildSourceMeshes();
1320 std::unique_ptr<RndMesh>
1321 BuildPanelMesh(
float flWidth,
int nLevel, Vector3 *pExtent,
bool bSolid);
1342 void BuildTrackGeometry();
1373 void DrawBarValues(
int nFirstBar,
int nEndBar,
bool bWriteDepth);
1384 void DrawCheckpoints(
int nFirstBar,
int nEndBar);
1398 void DrawPass(RndMat *pMat,
int nFirstBar,
int nEndBar, PassColor nColor);
1409 PanelData *FindPanel(
int nTrack,
int nBar);
Reference-counted array of script data nodes.
Definition dataarray.h:20
Rotation quaternion, stored as the vector part followed by the scalar part.
Definition quaternion.h:19
Animation of a material's colours, alpha, and texture stages by keys.
Definition rndmatanim.h:19
Surface description: blending, lighting colours, culling, and a list of texture stages.
Definition rndmat.h:20
Triangle mesh with a material.
Definition rndmesh.h:31
Animation of a transformable's local transform by rotation, translation, and scale keys.
Definition rndtransanim.h:20
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
Owner of a mesh the panels are built from, 4 bytes.
Definition tnlgeom.h:59
MeshHolder & operator=(MeshHolder &&)=default
Take over the mesh of another holder.
RndMesh * GetMesh() const
Definition tnlgeom.h:79
MeshHolder()=default
Construct a holder with no mesh.
~MeshHolder()
Delete the mesh unless sKeepMeshes is set.
MeshHolder(MeshHolder &&)=default
Take over the mesh of another holder.
void SetMesh(std::unique_ptr< RndMesh > pMesh)
Replace the mesh.
Definition tnlgeom.h:88
One built bar of one track, 0xd0 bytes.
Definition tnlgeom.h:105
char GetStartSection() const
Definition tnlgeom.h:291
const std::vector< CrossSectionXfm > & GetBaseSections() const
Definition tnlgeom.h:158
void SetSection(int nSection, const CrossSectionXfm §ion)
Replace one section as drawn.
Definition tnlgeom.h:178
Color & GetColor()
Definition tnlgeom.h:216
const Color & GetColor() const
Definition tnlgeom.h:221
RndMesh * GetMesh() const
Definition tnlgeom.h:188
void SetHighlighted(char bHighlighted)
Set whether the panel is drawn highlighted.
Definition tnlgeom.h:244
int GetPickable() const
Definition tnlgeom.h:263
void SetStartSection(char nSection)
Set the first section Rebuild() moves along.
Definition tnlgeom.h:300
void SetTransparent(char bTransparent)
Set whether the panel does not write depth.
Definition tnlgeom.h:286
void UpdateTriangles()
Rebuild the two triangles of the panel that a pick tests.
std::vector< CrossSectionXfm > & GetBaseSections()
Definition tnlgeom.h:153
RndMat * GetCheckpointMat() const
Definition tnlgeom.h:202
void SetCheckpointMat(RndMat *pMat)
Set the checkpoint material of the panel.
Definition tnlgeom.h:211
const std::vector< CrossSectionXfm > & GetSections() const
Definition tnlgeom.h:168
void SetDirty(int bDirty)
Set whether the mesh needs Rebuild().
Definition tnlgeom.h:258
PanelData(PanelData &&)=default
Take over the mesh and the sections of another panel.
void SetMesh(std::unique_ptr< RndMesh > pMesh)
Replace the mesh of the panel.
Definition tnlgeom.h:197
bool Hit(const Segment *pSegment) const
Report whether a segment strikes the panel.
void SetSections(const std::vector< CrossSectionXfm > §ions)
Definition tnlgeom.h:183
std::vector< CrossSectionXfm > & GetSections()
Definition tnlgeom.h:163
PanelData & operator=(PanelData &&)=default
Take over the mesh and the sections of another panel.
void SetPickable(int bPickable)
Set whether Hit() tests the panel.
Definition tnlgeom.h:272
int GetDirty() const
Definition tnlgeom.h:249
char GetHighlighted() const
Definition tnlgeom.h:235
void SetColor(const Color &color)
Set the colour of the panel.
Definition tnlgeom.h:230
PanelData()
Construct a white, transparent, unpickable panel with no mesh that needs a rebuild.
char GetTransparent() const
Definition tnlgeom.h:277
void Rebuild(const MeshHolder *pSource, const Vector3 *pOffset, int nRows)
Rebuild the vertices of the mesh from the sections of the panel and a source mesh.
The place of a player in the tunnel, 0x38 bytes.
Definition tnlgeom.h:406
void PlaceActivator(const Transform *pXfm)
Place the view of the activator, if there is one.
Player(Player &&)=default
Take over the curves of another player.
void SetCamSlide(RndTransformable *pSlide)
Set the transformable the camera of the player slides.
void SetHoldCam(int bHold)
Set whether the camera stops following the player.
Definition tnlgeom.h:527
RndView * GetActivator() const
Definition tnlgeom.h:547
void LeaveTrack()
Take the player off the record of the players of its track.
void Update(float flTick, float flDeltaTicks)
Move the player along its curves.
void SetTrack(char nTrack)
Move the player to a track, along curves when the geometry animates moves.
float GetTrailTicks() const
Definition tnlgeom.h:542
void Init(TnlGeom *pGeom, char nIndex)
Attach the player to the geometry.
void SetMoveTime(float flMoveTime)
Set the multiple of the length of a move.
Definition tnlgeom.h:571
RndTransformable * GetCamSlide() const
Definition tnlgeom.h:513
float GetVelocity() const
Definition tnlgeom.h:557
char GetTrack() const
Definition tnlgeom.h:532
float GetCamPosition() const
Definition tnlgeom.h:576
float GetMoveTime() const
Definition tnlgeom.h:562
void SetActivatorPosition(float flPosition)
Set the position of the activator of the player.
int GetHoldCam() const
Definition tnlgeom.h:518
float GetActivatorPosition() const
Definition tnlgeom.h:537
Player()
Construct a player on track 0.
void Reset()
Put the player at its track at once.
Player & operator=(Player &&)=default
Take over the curves of another player.
float GetPosition() const
Definition tnlgeom.h:552
~Player()
Delete the curves of the player.
void SetActivator(RndView *pView)
Set the view of the activator of the player.
RndMat * GetOverlayMat() const
Definition tnlgeom.h:338
void Clear()
Clear the overlay and the players of the track.
void SetPlayers(unsigned char nPlayers)
Set the players on the track.
Definition tnlgeom.h:394
void SetOverlayMode(int nMode)
Set how the overlay is drawn.
Definition tnlgeom.h:361
int GetOverlayMode() const
Definition tnlgeom.h:352
Color & GetColor()
Definition tnlgeom.h:366
const Color & GetColor() const
Definition tnlgeom.h:371
TrackData()
Construct the state of a track.
void SetColor(const Color &color)
Set the colour of the panels of the track.
Definition tnlgeom.h:380
void SetOverlayMat(RndMat *pMat)
Set the material drawn over the track.
Definition tnlgeom.h:347
unsigned char GetPlayers() const
Definition tnlgeom.h:385
void BlendTrack(Transform *pXfm, bool bSmoothBasis, float flTrack, float flTick, float flLateral)
Work out the transform of a cell at a fractional track, blending the transforms of the two nearest tr...
PanelData * GetPanel(int nTrack, int nBar)
Report a built panel.
void RestoreSections(int nTrack, int nBar)
Put the sections of a built panel back as the bar was built.
~TnlGeom()
Destroy the geometry.
int GetMinFirstBar() const
Definition tnlgeom.h:1165
void SetPanelMat(RndMat *pMat, int nKind)
Set the material of a kind of panel, or the default material.
void DrawPanelsMultiplayer()
Draw as DrawPanels() does, as the tunnel does in a game of several players with the Game rule set.
TnlGeom()
Construct an empty geometry.
float MoveLength(float flFrom, float flTo) const
Report the length of a move between two tracks.
void DrawOverlays()
Draw the bars of the ring before the song with the bar values, the overlays of the tracks,...
void DrawPanels()
Rebuild the dirty panels, then draw the built bars from mBarsBehind before the end of the ring back t...
void SetAllPanelColors(const Color *pColor, bool bHighlighted)
Set the colour of every built panel.
void BuildBars()
Build the bars of the ring that are not built yet.
void SetMinFirstBar(int nBar)
Set the least bar Poll() starts the ring at.
Definition tnlgeom.h:1174
void SetPanelColor(int nTrack, int nBar, const Color *pColor, bool bHighlighted)
Set the colour of a built panel.
int GetNumTracks() const
Definition tnlgeom.h:1193
void CellXfm(int nTrack, Transform *pXfm, bool bSmoothBasis, bool bTrackOffset, float flTick, float flLateral)
Work out the transform of a cell of a track.
int GetNumBars() const
Definition tnlgeom.h:1126
void TrackXfm(int nTrack, Transform *pXfm, bool bSmoothBasis, float flTick, float flLateral)
Work out the transform of a cell of a track without the offset of the track.
const TrackGeometry & GetTrackGeometry(int nTrack) const
Report the flat cross section of a track.
Definition tnlgeom.h:1203
void SetTrackColor(int nTrack, const Color *pColor)
Set the colour of the panels of a track.
static constexpr int kRingMask
Bars of the ring of built panels a bar index selects with its low bits.
Definition tnlgeom.h:35
static constexpr int kNoBar
The bar a slot of the ring holds when no bar is built in it.
Definition tnlgeom.h:38
void PathXfm(Transform *pXfm, float flTick)
Work out the transform of the path of the tunnel at a tick.
void SetTrackOverlay(int nTrack, RndMat *pMat, int nMode)
Set the material drawn over a track.
Player * GetPlayer(int nPlayer)
Report the place of a player.
bool Pick(const Segment *pSegment, int *pnTrack, int *pnBar)
Find the built panel a segment strikes first.
float BuiltEndTick() const
Report the tick a little before the end of the built bars.
int GetBarsBehind() const
Definition tnlgeom.h:1131
void LoadConfig(DataArray *pConfig, DataArray *pDefaults, int nOption)
Load the settings of the geometry.
int GetShowPanels() const
Definition tnlgeom.h:1136
bool Init(const std::vector< std::pair< Vector2, Vector2 > > *pEdges, int nNumBars, int nDetail, int nBarsBehind, float flSlabDepth, float flSlabAngle, RndTransAnim *pPath, const std::vector< Color > *pColors, RndMat *pPanelMat, RndMatAnim *pPanelAnim)
Set up the tracks from the edges of the cross section, and the passes of the standard panel from a ma...
void SetPath(RndTransAnim *pAnim)
Replace the path at once with an animation that starts at frame 0.
void BlendCell(Transform *pXfm, bool bSmoothBasis, bool bTrackOffset, float flTrack, float flTick, float flLateral)
Work out the transform of a cell at a fractional track, blending the two nearest tracks.
void BlendPath(RndTransAnim *pAnim, int bLoop, int bUseTime, float flLength, float flStart, float flFrame, float flLoopStart, float flLoopEnd)
Blend the path to a new animation.
void SetMoveLength(float flLength)
Set the ticks of a move of a player to the next track.
void ResetPanels()
Put every panel back in its first state, white and transparent, and mark every slot of the ring as no...
void SetBarValue(int nBar, RndMat *pMat)
Set the checkpoint material of a built bar in mBarValues.
Color * GetTrackColor(int nTrack)
Report the colour of the panels of a track.
std::vector< CrossSectionXfm > * GetSections(int nTrack, int nBar, bool bDirty)
Report the sections of a built panel.
void SetTrackOffset(int nTrack, const Vector3 *pOffset)
Set the offset of a track, which CellXfm() adds in the basis of the cell.
void PlaceCell(int nTrack, Transform *pXfm, bool bSmoothBasis, bool bTrackOffset, float flTick, float flLateral, float flRaise)
Work out the transform of a cell, sunk below the surface of the track.
void SetPanelStartSection(int nTrack, int nBar, char nSection)
Set the first section of a built panel the mesh moves along.
Color * GetPanelColor(int nTrack, int nBar)
Report the colour of a built panel.
float GetBarsPerTick() const
Definition tnlgeom.h:1150
void BuildBar(int nBar)
Build the cross sections of one bar on every track along the path, and give the slot of the bar its m...
int GetSectionsPerBar() const
Definition tnlgeom.h:1155
void Poll(float flTick, float flDeltaTicks)
Advance the geometry to a tick, building the bars ahead and moving the players and their activators.
void SetEndBar(int nBar)
Set the first bar that is never built.
Definition tnlgeom.h:1188
void SetPanelState(int nTrack, int nBar, char bTransparent, RndMat *pCheckpointMat, int bPickable, bool bHighlighted, const Color *pColor)
Set the state of a built panel.
void ResetPlayers()
Put every player at its track at once.
int GetEndBar() const
Definition tnlgeom.h:1179
int GetFirstBar() const
Definition tnlgeom.h:1160
void SetShowPanels(int bShow)
Set whether the panels show.
Definition tnlgeom.h:1145
void SetNumPlayers(int nPlayers)
Set the number of players, attaching each to the geometry with its index.
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
Linear colour with four float components.
Definition color.h:12
Two points that fix a line or a segment.
Definition plane.h:39
One cross section of a panel, 0x70 bytes.
Definition tnlgeom.h:41
Transform mXfm
Definition tnlgeom.h:42
Vector3 mCellBasis[3]
Definition tnlgeom.h:43
The flat cross section of one track, 0xa0 bytes.
Definition tnlgeom.h:47
float mLeftZ
Definition tnlgeom.h:49
Vector3 mBasis[3]
Definition tnlgeom.h:52
float mRightX
Definition tnlgeom.h:50
Quat mRotation
Definition tnlgeom.h:55
float mLeftX
Definition tnlgeom.h:48
Vector3 mCenter
Definition tnlgeom.h:53
float mRightZ
Definition tnlgeom.h:51
Transform mXfm
Definition tnlgeom.h:54
Triangle stored as a corner, the two edges leaving it, and its normal.
Definition triangle.h:37
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14