wavelength 1.0.0
Loading...
Searching...
No Matches
ship.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/gfxutil.h"
8#include "gfx/particlearm.h"
9#include "gfx/playercamfx.h"
10#include "math/color.h"
11#include "math/transform.h"
12#include "math/vector2.h"
13#include "math/vector3.h"
14#include "rnd/rndanimatable.h"
15#include "rnd/rndblur.h"
16#include "rnd/rndenviron.h"
17#include "rnd/rndline.h"
18#include "rnd/rndmat.h"
19#include "rnd/rndmesh.h"
20#include "rnd/rndparticlesys.h"
21#include "rnd/rndtext.h"
22#include "rnd/rndtransanim.h"
24#include "rnd/rndview.h"
25#include "script/dataarray.h"
26
27// The beams and the flight point back at the ship that owns them.
28class Beam;
29class ShipFlyIn;
30template <bool bArg>
31class BeamPool;
32
41class Ship {
42public:
44 static constexpr int kNumArms = 3;
45
47 static constexpr int kNumMultiOffsets = 2;
48
50 static constexpr int kNumBeamEnds = 2;
51
60
67
73 struct BeamData {
75 signed char mSlot;
76 signed char mTrack;
77 };
78
89 Ship(const char *pszColor, int nPlayer);
90
98
108 static void LoadConfig(DataArray *pConfig, DataArray *pDefaults, bool bReload);
109
117 void SetMultiplier(int nMultiplier);
118
125 void Reset();
126
136 void SetEnergy(float fEnergy, int nZone, float fZoneFraction);
137
147 void Fire(int nSlot, signed char nTrack, bool bHit);
148
158 void SetTrack(int nTrack, int nTrackType, int nInstrument);
159
169 void SetShown(bool bShown);
170
178 void SetHidden(bool bHidden);
179
188 void SetOverride(const float (*pXfm)[kTransformRowFloatCount], float fBlend);
189
198 void StartBump(bool bVictim, int nTrack);
199
208 void Poll(float fTicks, float fTimeDelta);
209
217
224 static void DrawShared();
225
232 void DrawTrack();
233
241
248 void DrawArrow();
249
257 void ScaleArms(float fScale);
258
267 void ScaleArm(int nArm, float fScale);
268
271 return sWinFlyOff;
272 }
273
276 return sBeamView.get();
277 }
278
280 RndView *GetView() const {
281 return mView;
282 }
283
286 return mScratchRibbon;
287 }
288
290 unsigned char GetFlags() const {
291 return mFlags;
292 }
293
295 float GetBumpStart() const {
296 return mBumpStart;
297 }
298
304 void SetArrowAspect(float fAspect) {
305 mArrowAspect = fAspect;
306 }
307
313 void SetSpread(float fSpread) {
314 mSpread = fSpread;
315 }
316
317private:
319 static Vector3 sOffset;
321 static Vector3 sMultiOffsets[kNumMultiOffsets];
323 static Vector3 sPivot;
325 static Vector3 sOffsetPivot;
327 static Vector3 sMultiOffsetPivots[kNumMultiOffsets];
329 static Color sTrackLabelPitchColor;
331 static Vector3 sIntroPos;
333 static std::vector<FloatKey> sIntroTrodeSizeMult;
335 static std::vector<FloatKey> sFireTrodeSizeMult;
337 static float sViewDistance;
339 static float sFireOffset;
341 static float sFireScale;
344 static float sFireTrodeEnd;
346 static float sTilt;
348 static float sScale;
350 static float sBankSpring;
352 static float sBankDamper;
354 static float sBankMagnitude;
356 static float sBankForce;
359 static int sMoveMissBeams[kNumBeamEnds];
361 static int sMoveHitBeams[kNumBeamEnds];
364 static int sMoveHit2Beams[kNumBeamEnds];
366 static float sSputterForce;
368 static float sBumpHeightAccel;
370 static float sBumpAttackTime;
372 static float sBumpShipMoveSlowdown;
375 static float sCrippledCamJiggleProbability;
377 static float sCrippledCamJiggle;
379 static float sIntroEndTick;
381 static float sIntroBlendEndTick;
384 static float sIntroTrodeEnd;
386 static std::unique_ptr<BeamPool<false>> sMissBeams;
388 static std::unique_ptr<BeamPool<false>> sHitBeams;
390 static std::unique_ptr<BeamPool<false>> sHit2Beams;
393 static std::unique_ptr<RndView> sBeamView;
395 static RndEnviron *sEnviron;
397 static RndView *sLoadingView;
399 static RndTransAnim *sWinFlyOff;
401 static RndAnimatable *sAllAnim;
403 static RndAnimatable *sIntroAnim;
406 static RndMesh *sArrowMesh;
407
416 static void ConfigureCrippler(RndParticleSys *pSys, int nPlayer);
417
426 static void ConfigureArm(RndParticleSys *pSys, int nPlayer);
427
441 void AddBeam(std::list<BeamData> *pList,
442 BeamPool<false> *pPool,
443 signed char nSlot,
444 signed char nTrack,
445 float fTick,
446 float fStart,
447 float fEnd);
448
455 void ClearBeams();
456
469 void UpdateBeams(std::list<BeamData> *pList,
470 BeamPool<false> *pPool,
471 const float (*pXfm)[kTransformRowFloatCount],
472 const Color *pColor,
473 bool bMoveStart,
474 bool bMoveEnd);
475
483 void PollBump(float fTimeDelta);
484
493 void PollCrippler(float fTimeDelta, bool bCrippled);
494
504 inline void
505 PollSoloIntro(float fTick, PlayerCamFX *pCamFX, float (*pXfm)[kTransformRowFloatCount]);
506
516 inline void PollIntro(float fTick, PlayerCamFX *pCamFX, float (*pXfm)[kTransformRowFloatCount]);
517
518 RndView *mView;
519 RndMesh *mMesh;
520 std::unique_ptr<RndView> mPsAnim;
521 std::unique_ptr<RndView> mBackPsAnim;
522 RndView *mFxView;
523 RndMat *mMat;
524 RndMat *mLeaderMat;
525 RndText *mName;
526 RndLine *mScratchRibbon;
527 int mPlayer;
528 RndTransAnim *mIntroFlyIn;
529 RndTransAnim *mIntro;
530 float mStartMs;
531 float mFireTimes[kNumArms];
532 RndAnimatable *mArmAnims[kNumArms];
533 RndTransformable *mArmXfms[kNumArms];
534 ParticleArm mArms[kNumArms];
535 RndMesh *mTrodes[kNumArms];
536 ParticleArm mThruster;
537 RndParticleSys *mThruster2;
538 RndParticleSys *mThruster3;
539 // +0x9c is not yet identified.
541 Color mArmColors[kNumArms][kNumArmColors];
542 RndMat *mTrodeMats[kNumArms];
543 float mTrodeSize;
544 float mArmSizeLow;
545 float mArmSizeHigh;
546 std::list<BeamData> mMissBeams;
547 std::list<BeamData> mHitBeams;
548 std::list<BeamData> mHit2Beams;
549 Vector2 mScreenPos;
550 Color mColor;
551 float mSpread;
552 float mArrowAspect;
553 int mHasOverride;
554 int mIntroActive;
555 float mOverrideBlend;
557 Transform mXfm;
558 int mShown;
559 int mHidden;
560 int mMulti;
561 unsigned char mFlags;
562 signed char mAttackTrack;
563 float mAttackTime;
564 RndView *mBumperAttack;
565 RndBlur *mBumperBlur;
566 float mBumpStart;
567 float mBumpEnd;
568 RndTransAnim *mBumperFly;
569 float mBumpHeight;
570 float mBumpVel;
571 RndParticleSys *mCripplerPs;
572 float mCripplerTime;
573 RndParticleSys *mBumperPs;
574 float mBumperTime;
575 float mArrowStart;
576 std::unique_ptr<RndAnimatable::SecondOrder> mBank;
577 std::unique_ptr<ShipFlyIn> mFlyIn;
578};
Pool of the beams of one family, which share a look and draw under one parent.
Definition beampool.h:17
Beam a ship fires at a gem, a line that two waves ripple along.
Definition beam.h:20
Reference-counted array of script data nodes.
Definition dataarray.h:20
Particle system that hangs from a transform and is drawn as a reflection of it.
Definition particlearm.h:12
The camera of the tunnel.
Definition playercamfx.h:25
Mix-in for an object driven by a frame.
Definition rndanimatable.h:16
Motion trail that draws a mesh or a text again at the transforms it recently occupied.
Definition rndblur.h:21
Lighting and fog environment, made current for the drawables after it when it is drawn.
Definition rndenviron.h:18
Line through points, drawn as a ribbon of constant screen width that faces the camera.
Definition rndline.h:26
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
Emitter that spawns, moves, and fades a population of particles.
Definition rndparticlesys.h:69
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
Animation of a transformable's local transform by rotation, translation, and scale keys.
Definition rndtransanim.h:20
Mix-in for an object with a local transform and a world transform derived from its parent's.
Definition rndtransformable.h:17
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
Flight of the ship of the tutorial onto the tracks, ship tutorial fly-in.tnm.
Definition shipflyin.h:14
static RndTransAnim * GetWinFlyOff()
Definition ship.h:270
RndLine * GetScratchRibbon() const
Definition ship.h:285
static RndView * GetBeamView()
Definition ship.h:275
void SetShown(bool bShown)
Show or hide the ship.
void SetMultiplier(int nMultiplier)
Give the ship its leader material while the streak multiplier is above 1.
void ScaleArms(float fScale)
Scale the arms and the trodes.
~Ship()
Destroy the ship, the views it created, and every object the ships share.
void Fire(int nSlot, signed char nTrack, bool bHit)
Fire the ship at a gem.
static void DrawShared()
Draw the environment every ship shares.
float GetBumpStart() const
Definition ship.h:295
void Poll(float fTicks, float fTimeDelta)
Place the ship on the tracks and advance its effects.
static void LoadConfig(DataArray *pConfig, DataArray *pDefaults, bool bReload)
Read the configuration every ship shares, and pass it on to the beam pools that exist.
ArmColor
The colours of the particles of an arm, indexing mArmColors.
Definition ship.h:53
@ kArmColorStartHigh
Definition ship.h:55
@ kArmColorEndHigh
Definition ship.h:57
@ kArmColorEndLow
Definition ship.h:56
@ kNumArmColors
Definition ship.h:58
@ kArmColorStartLow
Definition ship.h:54
void UpdateTransform()
Place the ship for the intro and the outro of the play field.
RndView * GetView() const
Definition ship.h:280
static constexpr int kNumMultiOffsets
The two configured offsets of a ship of a game of several players.
Definition ship.h:47
static constexpr int kNumBeamEnds
The two ends of a beam, 0 at the ship and 1 at the gem.
Definition ship.h:50
void DrawEffects()
Draw the trodes, the arms, and the attack of a bumper.
static constexpr int kNumArms
The number of arms, one for each gem button.
Definition ship.h:44
void SetEnergy(float fEnergy, int nZone, float fZoneFraction)
Colour the arms for the zone of the energy, or make them sputter when it runs out.
void DrawTrack()
Draw the ship on its track and record where it lies on the screen.
unsigned char GetFlags() const
Definition ship.h:290
void SetArrowAspect(float fAspect)
Set the slope of the edge arrow.
Definition ship.h:304
void DrawArrow()
Draw the arrow at the edge of the screen that points at a ship off the screen.
Ship(const char *pszColor, int nPlayer)
Build the ship of a player from the scene objects of its colour.
void SetOverride(const float(*pXfm)[kTransformRowFloatCount], float fBlend)
Blend the ship towards a fixed transform, or stop blending.
Flag
The bits of mFlags.
Definition ship.h:62
@ kFlagAttacking
Definition ship.h:63
@ kFlagBumped
Definition ship.h:64
@ kFlagBumpReverse
Definition ship.h:65
void StartBump(bool bVictim, int nTrack)
Start the move of the ship of a bump.
void ScaleArm(int nArm, float fScale)
Scale one arm and its trode.
void SetHidden(bool bHidden)
Hide the ship regardless of SetShown(), or stop hiding it, and end its beams.
void SetSpread(float fSpread)
Set how far apart the ships of a shared screen fly.
Definition ship.h:313
void Reset()
Return the ship to its state at the start of a song.
void SetTrack(int nTrack, int nTrackType, int nInstrument)
Move the ship to a track, which ends its beams.
Linear colour with four float components.
Definition color.h:12
One beam a ship fired.
Definition ship.h:73
Beam * mBeam
Definition ship.h:74
signed char mSlot
Definition ship.h:75
signed char mTrack
Definition ship.h:76
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
constexpr int kTransformRowFloatCount
Floats in a row of a transform held as a bare array, x, y, z, and padding.
Definition transform.h:29