resonance 1.0.1
Loading...
Searching...
No Matches
string.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "math/color.h"
6#include "math/vector2.h"
7#include "math/vector3.h"
8#include "os/hxstr.h"
9#include "rnd/collideable.h"
10#include "rnd/drawable.h"
11#include "rnd/transformable.h"
12
13namespace Rnd {
14class Dbg;
15class Mat;
16class Mesh;
17class Object;
18class Stream;
19struct MeshVert;
20} // namespace Rnd
21
22namespace Rnd {
23
58class String : public Drawable, public Transformable, public Collideable {
59public:
90
102 explicit String(const HxStr &name);
103
110 virtual ~String();
111
128 void SetNumPoints(int nCount);
129
137 int NumPoints() const;
138
151 void SetPointPos(int nIndex, const Vector3 &pos);
152
165 Vector3 *GetPointPos(int nIndex);
166
178 void SetPointColor(int nIndex, const Color &color);
179
190 Color *PointColor(int nIndex);
191
202 void SetMat(Mat *pMat);
203
213 Mat *GetMat() const;
214
222 float GetWidth() const;
223
233 void SetWidth(float flWidth) {
234 mWidth = flWidth;
235 }
236
244 void SetFoldAngle(float flAngle);
245
253 float GetFoldAngle() const;
254
265 void SetHasCaps(int nHasCaps);
266
274 int GetHasCaps() const;
275
285 void SetLinePairs(int nLinePairs);
286
294 int GetLinePairs() const;
295
306 virtual void SetHighlight(int nHighlight);
307
321 virtual void FindCollisions(const Segment &ray, std::list<Collision> &collisions);
322
333 virtual void DumpText(Dbg &sink);
334
342 virtual void Save(Stream &stream);
343
355 virtual void Replace(Object *pFrom, Object *pTo);
356
367 virtual const HxStr &ClassName() const;
368
380 virtual void Copy(const Object *pSource, unsigned nFlags);
381
393 virtual void Load(Stream &stream);
394
403 static String *New(const HxStr &name);
404
416 static Object *NewObject(const HxStr &name);
417
428 static void Init();
429
430protected:
451 virtual int DrawShowing();
452
453private:
460 struct VertexSlot {
461 int mMode; // +0x00 One of the kVertexSlot values below.
462 MeshVert *mpVert; // +0x04 First of the two or four vertices.
463 };
464
465 // A point that is neither end of a run governs two vertices, and a cap point governs four.
466 enum { kVertexSlotBody = 0, kVertexSlotStartCap = 1, kVertexSlotEndCap = 2 };
467
474 void ResolvePointVertexSlot(unsigned nIndex, VertexSlot &slot);
475
486 void CreateMesh();
487
496 void DeleteMesh();
497
509 void EmitRibbonVerts(Point *pFirst, Point *pLast);
510
511 // Declared in recovered offset order. Every member is private, because the image supplies an
512 // accessor for each field anything outside the class reads.
513
514 // Material a load or a copy supplied. SetMat() bypasses it and writes straight to the mesh,
515 // so it records only what CreateMesh() is to apply.
516 Mat *mpMat; // +0xe0
517 float mWidth; // +0xe4
518 std::vector<Point> mPoints; // +0xe8
519 // The mesh this string owns and submits. CreateMesh() builds it and DeleteMesh() releases it.
520 Mesh *mpMesh; // +0xf4
521 int mHasCaps; // +0xf8
522 int mLinePairs; // +0xfc
523 float mFoldAngle; // +0x100
524 // Cosine of mFoldAngle, refreshed by SetFoldAngle() and by CreateMesh(). Both call the cosine
525 // routine at 0x00559638, whose small-angle path runs the cosine kernel.
526 float mFoldCos; // +0x104
527 // +0x108 through +0x10f is alignment padding ahead of the Rnd::Object virtual base at +0x110.
528};
529
536extern HxStr g_stringClassName;
537
538} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Collideable()
Construct a collideable with no children.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Drawable()
Construct a visible drawable with no children.
Surface description a Rnd::Mesh draws with.
Definition mat.h:36
Indexed triangle mesh with one material.
Definition mesh.h:46
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
void SetMat(Mat *pMat)
Set the material the ribbon draws with.
void SetPointPos(int nIndex, const Vector3 &pos)
Move one point.
void SetLinePairs(int nLinePairs)
Set whether consecutive points form independent segments rather than one continuous ribbon.
virtual void SetHighlight(int nHighlight)
Pass the highlight treatment to the owned mesh.
static void Init()
Register the class key with Rnd::TheManager.
float GetFoldAngle() const
Report the bend the ribbon folds at.
virtual ~String()
Release the owned mesh and the point vector.
void SetNumPoints(int nCount)
Resize the ribbon to nCount points and rebuild the mesh around it.
virtual const HxStr & ClassName() const
Report the class key a .rnd file writes for a ribbon.
void SetFoldAngle(float flAngle)
Set the bend the ribbon folds at and cache its cosine.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy the state of pSource into this ribbon.
virtual void DumpText(Dbg &sink)
Write a description of this ribbon to sink.
static String * New(const HxStr &name)
Build a ribbon the class registry vends.
virtual int DrawShowing()
Project every point and redraw the owned mesh through it.
int NumPoints() const
Report how many points the ribbon runs through.
static Object * NewObject(const HxStr &name)
Build a ribbon for the class registry.
void SetWidth(float flWidth)
Set the width of the ribbon in screen units.
Definition string.h:233
void SetPointColor(int nIndex, const Color &color)
Set the colour of one point and of the mesh vertices it governs.
virtual void FindCollisions(const Segment &ray, std::list< Collision > &collisions)
Test a ray against the owned mesh and report the intersections as this object.
virtual void Replace(Object *pFrom, Object *pTo)
Repoint the base subobjects when an object they address is replaced.
int GetLinePairs() const
Report the line-pair flag.
String(const HxStr &name)
Construct an empty ribbon and its mesh.
void SetHasCaps(int nHasCaps)
Set whether the ribbon ends in a pair of tapering caps.
Vector3 * GetPointPos(int nIndex)
Report the address of the position of one point.
Mat * GetMat() const
Report the material the ribbon draws with.
virtual void Load(Stream &stream)
Read this ribbon's serialised form from stream.
int GetHasCaps() const
Report the cap flag.
Color * PointColor(int nIndex)
Report the address of the colour of one point.
float GetWidth() const
Report the width of the ribbon in screen units.
virtual void Save(Stream &stream)
Write this ribbon's serialised form to stream.
Transformable()
Construct a dirty transformable with identity transforms and no children.
The rendering engine.
Definition animhelper.h:3
HxStr g_stringClassName
Class key a .rnd file writes for a ribbon.
Linear colour with four float components.
Definition color.h:10
One vertex of a Rnd::Mesh.
Definition meshvert.h:22
Line segment a collision query is run along.
Definition collideable.h:22
Vector3 mCamPos
Definition string.h:83
Point()
Construct a point at the origin, coloured white.
Color mColor
Definition string.h:82
Vector2 mDir
Definition string.h:85
int mClipped
Definition string.h:87
int mReserved4c
Definition string.h:88
Vector2 mScreen
Definition string.h:84
Vector2 mNormal
Definition string.h:86
Vector3 mPos
Definition string.h:81
Two-component vector, used for texture coordinates.
Definition vector2.h:10
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:12