wavelength 1.0.0
Loading...
Searching...
No Matches
rndenviron.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <list>
5
6#include "math/color.h"
7#include "os/binstream.h"
8#include "os/mem.h"
9#include "os/prnstream.h"
10#include "rnd/rnddrawable.h"
11#include "rnd/rndlight.h"
12
18class RndEnviron : public RndDrawable {
19public:
30
32 static constexpr int kCopyKeepLights = 1;
33
41 explicit RndEnviron(const char *pszName);
42
49 ~RndEnviron() override;
50
57 void *operator new(size_t nSize) {
58 return PoolMemAlloc(static_cast<int>(nSize), "Environ", 0);
59 }
60
66 void operator delete(void *pBlock) {
67 PoolMemFree(pBlock);
68 }
69
79 void ListDrawObjects(std::list<RndObject *> &objects) override;
80
88 int DrawShowing() override {
89 sCurrent = this;
90 return 1;
91 }
92
100 void DumpText(PrnStream &stream) override;
101
109 void Save(BinStream &stream) override;
110
121 void Replace(RndObject *pFrom, RndObject *pTo) override;
122
130 const char *ClassName() const override {
131 return sClassName;
132 }
133
142 void Copy(const RndObject *pSource, int nFlags) override;
143
151 void Load(BinStream &stream) override;
152
160 void AddLight(RndLight *pLight);
161
170 static void CreateDefault();
171
180 static RndObject *New(const char *pszName) {
181 return new RndEnviron(pszName);
182 }
183
190 static const char *sClassName;
191
199
207
214 static int sRev;
215
217 const Color &GetAmbientColor() const {
218 return mAmbientColor;
219 }
220
222 void SetAmbientColor(const Color &color) {
223 mAmbientColor = color;
224 }
225
227 const Color &GetFogColor() const {
228 return mFogColor;
229 }
230
232 void SetFogColor(const Color &color) {
233 mFogColor = color;
234 }
235
237 float GetFogDensity() const {
238 return mFogDensity;
239 }
240
242 void SetFogDensity(float fFogDensity) {
243 mFogDensity = fFogDensity;
244 }
245
247 float GetFogEnd() const {
248 return mFogEnd;
249 }
250
252 void SetFogEnd(float fFogEnd) {
253 mFogEnd = fFogEnd;
254 }
255
257 float GetFogStart() const {
258 return mFogStart;
259 }
260
262 void SetFogStart(float fFogStart) {
263 mFogStart = fFogStart;
264 }
265
267 const std::list<RndLight *> &GetLights() const {
268 return mLights;
269 }
270
272 std::list<RndLight *> &GetLights() {
273 return mLights;
274 }
275
276protected:
286
296
297 std::list<RndLight *> mLights;
298
300
301 float mFogStart;
302
303 float mFogEnd;
304
306
308
310};
311
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
RndDrawable()
Construct a showing drawable without a highlight or children.
Definition rnddrawable.h:23
static const char * sClassName
The class name a .rnd file writes, Environ.
Definition rndenviron.h:190
std::list< RndLight * > mLights
Definition rndenviron.h:297
RndEnviron(const char *pszName)
Construct an environment without lights, with a black ambient colour and no white fog.
void SetFogDensity(float fFogDensity)
Definition rndenviron.h:242
const char * ClassName() const override
Report the class name.
Definition rndenviron.h:130
const Color & GetAmbientColor() const
Definition rndenviron.h:217
int mFogMode
Definition rndenviron.h:309
static int sRev
The format version Save() writes and Load() accepts.
Definition rndenviron.h:214
static RndEnviron * sCurrent
The environment drawn last.
Definition rndenviron.h:198
float mFogEnd
Definition rndenviron.h:303
std::list< RndLight * > & GetLights()
Definition rndenviron.h:272
FogMode
The fog modes.
Definition rndenviron.h:21
@ kFogVertLinear
Definition rndenviron.h:25
@ kFogVertExp2
Definition rndenviron.h:24
@ kFogVertExp
Definition rndenviron.h:23
@ kFogPixelExp2
Definition rndenviron.h:27
@ kFogPixelLinear
Definition rndenviron.h:28
@ kFogPixelExp
Definition rndenviron.h:26
@ kFogNone
Definition rndenviron.h:22
void Copy(const RndObject *pSource, int nFlags) override
Copy another environment and its base.
int DrawShowing() override
Make the environment current.
Definition rndenviron.h:88
void ListDrawObjects(std::list< RndObject * > &objects) override
Add the lights to a list.
void SetFogEnd(float fFogEnd)
Definition rndenviron.h:252
const std::list< RndLight * > & GetLights() const
Definition rndenviron.h:267
float GetFogDensity() const
Definition rndenviron.h:237
float mFogStart
Definition rndenviron.h:301
void ReleaseRefs()
Drop the references on the lights.
void DumpText(PrnStream &stream) override
Write a description of the environment and its base.
void SetAmbientColor(const Color &color)
Definition rndenviron.h:222
const Color & GetFogColor() const
Definition rndenviron.h:227
float GetFogStart() const
Definition rndenviron.h:257
float mFogDensity
Definition rndenviron.h:305
void Save(BinStream &stream) override
Write the environment and its base.
static RndObject * New(const char *pszName)
Create an environment.
Definition rndenviron.h:180
float GetFogEnd() const
Definition rndenviron.h:247
~RndEnviron() override
Drop the references on the lights.
static RndEnviron * sDefault
The environment CreateDefault() made.
Definition rndenviron.h:206
Color mFogColor
Definition rndenviron.h:307
static constexpr int kCopyKeepLights
The bit of the Copy() flags that keeps the lights rather than copying the source's.
Definition rndenviron.h:32
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a referenced light with another.
void AddLight(RndLight *pLight)
Add a light, or report one already among the lights.
void Load(BinStream &stream) override
Read what Save() wrote.
Color mAmbientColor
Definition rndenviron.h:299
static void CreateDefault()
Create the default environment and add it to the default camera.
void SetFogStart(float fFogStart)
Definition rndenviron.h:262
void AcquireRefs()
Take references on the lights.
void SetFogColor(const Color &color)
Definition rndenviron.h:232
Light, placed by its transform.
Definition rndlight.h:16
RndObject(const char *pszName)
Construct an object and register it under a name.
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
PrnStream & operator<<(PrnStream &stream, RndEnviron::FogMode eMode)
Write the name of a fog mode.
Linear colour with four float components.
Definition color.h:12