resonance 1.0.1
Loading...
Searching...
No Matches
light.h
Go to the documentation of this file.
1#pragma once
2
3#include "math/color.h"
4#include "os/hxstr.h"
5#include "rnd/transformable.h"
6
7namespace Rnd {
8class Dbg;
9class Object;
10class Stream;
11} // namespace Rnd
12
13namespace Rnd {
14
41class Light : public Transformable {
42public:
51
64 explicit Light(const HxStr &name);
65
70 virtual ~Light();
71
80 static void *operator new(size_t nSize);
81
89 static void operator delete(void *pBlock);
90
103 virtual void SetColors(const Color &ambient, const Color &diffuse, const Color &specular);
104
114 virtual void SetType(Type type);
115
125 virtual void SetRange(float flRange);
126
137 virtual void SetAngles(float flInner, float flOuter);
138
151 virtual void SetAttenuation(float flConstant, float flLinear, float flQuadratic);
152
165 virtual void SyncLight();
166
177 virtual const HxStr &ClassName() const;
178
189 virtual void DumpText(Dbg &sink);
190
201 virtual void Save(Stream &stream);
202
215 virtual void Replace(Object *pFrom, Object *pTo);
216
229 virtual void Copy(const Object *pSource, unsigned nFlags);
230
242 virtual void Load(Stream &stream);
243
244 // Declared in recovered offset order, with the access specifiers interleaved. Each member that
245 // remains public is read directly by Rnd::PsEnviron::DrawShowing() while it builds the light
246 // records, and the image exposes no accessor for it.
247
250
253
264
265private:
266 float mInnerAngle; // +0xe0
267 float mOuterAngle; // +0xe4
268
269public:
271 float mRange;
272
273private:
274 float mConstantAtten; // +0xec
275 float mLinearAtten; // +0xf0
276 float mQuadraticAtten; // +0xf4
277
278public:
281
282private:
283 // A reserved run records a span that has not been recovered and is not a field. This one is
284 // either such a field or the alignment the virtual base subobject at 0x100 is placed on.
285 unsigned char mReservedfc[0x04];
286};
287
295
306Light *NewLight(const HxStr &name);
307
316extern Light *(*g_pfnNewLight)(const HxStr &name);
317
329
341
352
353} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Light in a scene.
Definition light.h:41
virtual void SetColors(const Color &ambient, const Color &diffuse, const Color &specular)
Set all three colours at once.
Color mAmbient
Light every vertex receives from this light regardless of its normal.
Definition light.h:252
Type
Which lighting model a light applies.
Definition light.h:50
@ kLightTypeSpot
Definition light.h:50
@ kLightTypeDirectional
Definition light.h:50
@ kLightTypePoint
Definition light.h:50
virtual void SetAngles(float flInner, float flOuter)
Set the two cone angles of a spot light.
Color mSpecular
Highlight colour the light contributes.
Definition light.h:263
Type mType
Which lighting model this light applies.
Definition light.h:280
Light(const HxStr &name)
Construct a white directional light.
virtual void Load(Stream &stream)
Replace the three colours, the six scalars, and the type from stream.
virtual void SetAttenuation(float flConstant, float flLinear, float flQuadratic)
Set the three attenuation terms of a point light.
virtual void DumpText(Dbg &sink)
Write a description of this light to sink.
virtual void SetType(Type type)
Set which lighting model this light applies.
Color mDiffuse
Light a vertex receives in proportion to its normal.
Definition light.h:249
virtual void SyncLight()
Hook run after the whole state of the light changes at once.
float mRange
Distance a point light illuminates over.
Definition light.h:271
virtual void SetRange(float flRange)
Set the distance a point light illuminates over.
virtual void Replace(Object *pFrom, Object *pTo)
Retarget the references of the base at pTo.
virtual const HxStr & ClassName() const
Report the class key a .rnd file writes for a light.
virtual void Save(Stream &stream)
Write the revision, the base, the three colours, the six scalars, and the type to stream.
virtual ~Light()
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy the three colours, the six scalars, and the type from pSource.
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
Transformable()
Construct a dirty transformable with identity transforms and no children.
The rendering engine.
Definition animhelper.h:3
void RegisterLightClass()
Point g_pfnNewLight at NewLight() and register the "Light" class with Rnd::Manager.
Light * NewLight(const HxStr &name)
Allocate and construct a light.
HxStr g_lightClassName
Registered class name of Rnd::Light, the string "Light".
Object * CreateRegisteredLight(const HxStr &name)
Build a light for the registered "Light" class by calling through g_pfnNewLight.
Light * NewLightThroughHook(const HxStr &name)
Build a light through the creator hook.
Linear colour with four float components.
Definition color.h:10