wavelength 1.0.0
Loading...
Searching...
No Matches
tnlfire.h
Go to the documentation of this file.
1#pragma once
2
3#include <list>
4#include <memory>
5#include <vector>
6
7#include "gfx/gfxtunnel.h"
8#include "math/color.h"
9#include "math/transform.h"
10#include "math/vector2.h"
11#include "math/vector3.h"
12#include "rnd/rndmat.h"
13#include "rnd/rndmesh.h"
14#include "rnd/rndmultimesh.h"
15#include "rnd/rndparticlesys.h"
16#include "rnd/rndtransanim.h"
17#include "rnd/rndview.h"
18
28class TnlFire {
29public:
37 class Emitter {
38 public:
46
54
64 void Init(RndParticleSys *pSys, GfxTunnel *pTunnel);
65
76 void SetColor(const Color *pColor);
77
85 void Rotate(const Vector3 *pBasis);
86
93 void Start();
94
101 void Stop();
102
103 private:
104 RndParticleSys *mSys;
105 float mEmitRateLow;
106 float mEmitRateHigh;
107 alignas(16) Vector3 mForce;
108 };
109
117 public:
121 ChunkModel() : mWeight(0.0f), mMultiMesh(nullptr), mTransAnim(nullptr), mMesh(nullptr) {
122 }
123
125 ChunkModel(ChunkModel &&) noexcept = default;
126
134
143
144 float mWeight;
145 std::unique_ptr<RndMultiMesh> mMultiMesh;
148 };
149
156 class Chunk {
157 public:
162
176 void Spawn(ChunkModel *pModel,
177 int bAuto,
178 int nTrack,
179 const Transform *pCellXfm,
180 const Transform *pBlendXfm,
181 std::list<Transform> *pFreeXfms,
182 float flTick);
183
191 void Reset(std::list<Transform> *pFreeXfms);
192
201 bool Update(float flTicks);
202
203 private:
204 std::list<Transform>::iterator mInstance;
205 ChunkModel *mModel;
206 alignas(16) Vector3 mVelocity;
207 alignas(16) Transform mXfm;
208 float mStartTick;
209 float mEndTick;
210 };
211
218
220 static constexpr int kChunkPlayer = -1;
221
235 TnlFire(const char *pszName, int nPlayer, GfxTunnel *pTunnel, bool bChunks);
236
245 static void Disable(const char *pszName, RndView *pParent);
246
267 bool Start(int nPlayer,
268 int nTrack,
269 int bAuto,
270 const Color *pInnerColor,
271 const Color *pOuterColor,
272 const Color *pTrackColor,
273 const std::vector<float> *pGemTicks,
274 float flTick,
275 float flStartTick,
276 float flEndTick);
277
285 void Reset(bool bClearChunks);
286
295 float StartTick(int nPlayer) const;
296
306 void Update(float flTicks, float flTime);
307
315 void Draw();
316
323 static float sCaptureSpeed;
324
331 static float sAutoCaptureSpeed;
332
339 static float sPanelSize;
340
347 static int sMaxChunks;
348
355 static float sChunkYDisplace;
356
364 static int sChunksLit;
365
372 static std::vector<Vector3> sChunkScales;
373
380
388
395
403
411
418
419private:
420 std::list<Chunk> mFreeChunks;
421 std::list<Chunk> mChunks;
422 std::vector<ChunkModel> mModels;
423 float mTotalWeight;
424 std::list<Transform> mFreeXfms;
425 RndMat *mMat;
426 GfxTunnel *mTunnel;
427 RndView *mView;
428 alignas(16) Emitter mInner;
429 Emitter mOuter;
430 float mStartTick;
431 float mEndTick;
432 float mSpeed;
433 Vector2 mInterval;
434 int mTrack;
435 alignas(16) Color mTrackColor;
436 std::vector<float> mGemTicks;
437 float mTick;
438 float mNextChunkTick;
439 int mActive;
440 int mAuto;
441 int mPlayer;
442};
Tunnel of tracks the players fly down, with the gems, the cameras of the players, and the effects dra...
Definition gfxtunnel.h:58
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
Mesh drawn once at each of a list of transforms.
Definition rndmultimesh.h:17
Emitter that spawns, moves, and fades a population of particles.
Definition rndparticlesys.h:69
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
A kind of chunk, a mesh and the animation it tumbles by, drawn as many instances.
Definition tnlfire.h:116
RndMesh * mMesh
Definition tnlfire.h:147
std::unique_ptr< RndMultiMesh > mMultiMesh
Definition tnlfire.h:145
ChunkModel()
Make a model with no mesh.
Definition tnlfire.h:121
void CreateMultiMesh()
Create the instanced mesh that draws the chunks of the model, named for the address of the model.
RndTransAnim * mTransAnim
Definition tnlfire.h:146
ChunkModel(ChunkModel &&) noexcept=default
Move a model.
float mWeight
Definition tnlfire.h:144
void Spawn(ChunkModel *pModel, int bAuto, int nTrack, const Transform *pCellXfm, const Transform *pBlendXfm, std::list< Transform > *pFreeXfms, float flTick)
Launch the chunk from a cell of a track with a random velocity and life.
Chunk()
Make an idle chunk.
void Reset(std::list< Transform > *pFreeXfms)
Give the instance back to the pool of transforms and make the chunk idle.
bool Update(float flTicks)
Move the chunk under the world force and place its instance with its animation.
The flames of one particle system, scaled, coloured, and turned on and off by the fire.
Definition tnlfire.h:37
~Emitter()
Give the system back its saved emission rates and force.
void Start()
Free the particles of the system and restart its emission at the saved rates.
void Rotate(const Vector3 *pBasis)
Turn the saved force by a basis and give it to the system.
void Init(RndParticleSys *pSys, GfxTunnel *pTunnel)
Take a system, save its emission rates and its scaled force, scale its emission box,...
void Stop()
Stop the emission of the system.
Emitter()
Make an emitter of no system.
void SetColor(const Color *pColor)
Colour the flames.
static constexpr int kChunkPlayer
The value of mPlayer of the fire that throws chunks.
Definition tnlfire.h:220
void Draw()
Draw the flying chunks in the colour of the track.
static int sMaxChunks
The chunks of a fire, capture_max_chunks.
Definition tnlfire.h:347
TnlFire(const char *pszName, int nPlayer, GfxTunnel *pTunnel, bool bChunks)
Find the view and particle systems of a fire by name and, when asked, load the models and fill the po...
static Vector3 sAutoCaptureVelocity[kRangeCount]
The range of the velocity of a chunk of an automatic capture, in the basis of the cell,...
Definition tnlfire.h:410
static float sChunkYDisplace
The height above the cell a chunk starts at, capture_chunk_y_displace.
Definition tnlfire.h:355
static std::vector< Vector3 > sChunkScales
The scale of the basis of a chunk on each track.
Definition tnlfire.h:372
float StartTick(int nPlayer) const
Report the first tick of the fire of a player.
void Reset(bool bClearChunks)
Stop the flames and the fire.
static Vector2 sCaptureInterval
The shortest and the longest ticks between chunks of a capture, capture_chunk_interval.
Definition tnlfire.h:379
void Update(float flTicks, float flTime)
Move the chunks, move the head of the fire, throw the chunks of the gems it passes,...
static Vector3 sCaptureVelocity[kRangeCount]
The range of the velocity of a chunk of a capture, in the basis of the cell, capture_chunk_initial_ve...
Definition tnlfire.h:402
static Vector2 sAutoCaptureInterval
The shortest and the longest ticks between chunks of an automatic capture, autocapture_chunk_interval...
Definition tnlfire.h:387
static int sChunksLit
Whether the chunks are lit, capture_chunks_lit.
Definition tnlfire.h:364
static Vector2 sChunkLifespan
The shortest and the longest ticks a chunk flies, capture_chunk_lifespan.
Definition tnlfire.h:417
static float sPanelSize
The size of a panel, the scale of the flames.
Definition tnlfire.h:339
static void Disable(const char *pszName, RndView *pParent)
Take the view of an unused fire out of a view and empty its particle system.
Range
The ends of the ranges of sCaptureVelocity and sAutoCaptureVelocity.
Definition tnlfire.h:213
@ kRangeCount
Definition tnlfire.h:216
@ kRangeMax
Definition tnlfire.h:215
@ kRangeMin
Definition tnlfire.h:214
bool Start(int nPlayer, int nTrack, int bAuto, const Color *pInnerColor, const Color *pOuterColor, const Color *pTrackColor, const std::vector< float > *pGemTicks, float flTick, float flStartTick, float flEndTick)
Start the fire on a track, unless it burns or another fire's chunks still fly.
static float sCaptureSpeed
The ticks the head moves for each tick of a capture, track_capture_speed.
Definition tnlfire.h:323
static float sAutoCaptureSpeed
The ticks the head moves for each tick of an automatic capture, track_autocapture_speed.
Definition tnlfire.h:331
static Vector3 sChunkForce
The change of velocity of a chunk per tick, capture_chunk_world_force.
Definition tnlfire.h:394
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