resonance 1.0.1
Loading...
Searching...
No Matches
tnlutil.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstring>
4
5#include "app/tunnelcache.h"
6#include "math/color.h"
7#include "math/transform.h"
8#include "os/hxstr.h"
9#include "rnd/transformable.h"
10#include "rnd/tunnel.h"
11
28
41
54
67
76inline void PadTransformRows(Transform &xfm) {
77 xfm.mBasisX.w = 1.0f;
78 xfm.mBasisY.w = 1.0f;
79 xfm.mBasisZ.w = 1.0f;
80 xfm.mTranslation.w = 1.0f;
81}
82
95inline void PlaceOnPath(Rnd::Transformable &trans, float flFrame) {
96 Transform xfm;
98 GetCachedTunnelObject()->GetPathXfm(&xfm, flFrame);
99 std::memcpy(trans.mLocalXfm, &xfm, sizeof(trans.mLocalXfm));
100 trans.mDirty = 1;
101 trans.UpdateWorldXfm(nullptr, 0); // Yes, the binary discards the result.
102}
103
117inline void PlaceOnRing(Rnd::Transformable &trans, int nRing, float flFrame, float flBlend) {
118 constexpr float kRingTangentScale = 0.97f;
119 Transform xfm;
120 PadTransformRows(xfm);
122 nRing, &xfm, flFrame, flBlend, kRingTangentScale);
123 std::memcpy(trans.mLocalXfm, &xfm, sizeof(trans.mLocalXfm));
124 trans.mDirty = 1;
125 trans.UpdateWorldXfm(nullptr, 0); // Yes, the binary discards the result.
126}
127
137extern int g_nAppTunnelTutorial;
138
148extern float g_flTunnelBrightness;
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Mix-in for an object with a local and a world transform.
Definition transformable.h:38
float mLocalXfm[kXfmRowCount][kXfmRowFloatCount]
Transform this object is positioned by, before the parent transform is applied.
Definition transformable.h:299
virtual int UpdateWorldXfm(Transformable *pParent, int nForce)
Compose mWorldXfm from mLocalXfm and the parent's world transform.
int mDirty
Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed.
Definition transformable.h:325
void GetPathXfm(Transform *pOut, float flFrame)
Evaluate the path at a frame.
void ProjectSectionToCameraSpace(int nRing, Transform *pOut, float flAnimFrame, float flRingBlend, float flTangentScale)
Build the frame of a point on one ring at a path frame, with the ring pushed outwards.
Linear colour with four float components.
Definition color.h:10
Affine transform stored as three basis rows and a translation row.
Definition transform.h:14
Vector3 mTranslation
Definition transform.h:18
Vector3 mBasisZ
Definition transform.h:17
Vector3 mBasisY
Definition transform.h:16
Vector3 mBasisX
Definition transform.h:15
float w
Definition vector3.h:16
void PlaceOnRing(Rnd::Transformable &trans, int nRing, float flFrame, float flBlend)
Move a transformable onto one ring of the tunnel at one frame, pushed outwards by 0....
Definition tnlutil.h:117
int g_nAppTunnelTutorial
Non-zero when AppTunnel was constructed for a tutorial level, from configuration code 0x3a1.
void PlaceOnPath(Rnd::Transformable &trans, float flFrame)
Move a transformable to the tunnel path transform at one frame.
Definition tnlutil.h:95
float g_flTunnelBrightness
The brightness the lane floor colours are scaled by.
Color TnlColorFromName(const HxStr &name)
Map a player colour name to the colour the tunnel draws that player in.
int TnlColorIndexFromName(HxStr name)
Map a player colour name to its index.
void PadTransformRows(Transform &xfm)
Set the padding word of every row of a transform to 1.
Definition tnlutil.h:76
Color TnlLaneColorFromName(HxStr name)
Map a player colour name to the lane floor colour, scaled by g_flTunnelBrightness.
Color TnlDimColorFromName(HxStr name)
Map a player colour name to a darker form of TnlColorFromName().
Rnd::Tunnel * GetCachedTunnelObject()
Report the tunnel CacheTunnelObjectByName() last recorded.