/
lightmaterialdecoration.h
115 lines (98 loc) · 3.92 KB
/
lightmaterialdecoration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/** @file materiallightdecoration.h Logical material, light decoration.
*
* @authors Copyright © 2011-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef CLIENT_RESOURCE_MATERIALLIGHTDECORATION_H
#define CLIENT_RESOURCE_MATERIALLIGHTDECORATION_H
#ifndef __CLIENT__
# error "LightMaterialDecoration only exists in the Client"
#endif
#include <de/string.h>
#include <doomsday/defs/ded.h>
#include <doomsday/defs/dedtypes.h>
#include "render/r_main.h" // LightRange
#include "resource/clienttexture.h"
#include "resource/clientmaterial.h"
/**
* @ingroup resource
*/
class LightMaterialDecoration : public ClientMaterial::Decoration
{
public:
/**
* Stages describe light change animations.
*/
class AnimationStage : public Stage
{
public:
de::Vec2f origin; ///< Position in material space.
float elevation; ///< Distance from the surface.
de::Vec3f color; ///< Light color.
float radius; ///< Dynamic light radius (-1 = no light).
float haloRadius; ///< Halo radius (zero = no halo).
LightRange lightLevels; ///< Fade by sector lightlevel.
ClientTexture *tex;
ClientTexture *floorTex;
ClientTexture *ceilTex;
ClientTexture *flareTex;
int sysFlareIdx; ///< @todo Remove me
public:
AnimationStage(int tics, float variance, const de::Vec2f &origin, float elevation,
const de::Vec3f &color, float radius, float haloRadius,
const LightRange &lightLevels, ClientTexture *ceilingTexture,
ClientTexture *floorTexture, ClientTexture *texture,
ClientTexture *flareTexture, int sysFlareIdx = -1);
AnimationStage(const AnimationStage &other);
virtual ~AnimationStage() {}
/**
* Construct a new AnimationStage from the given @a stageDef.
*/
static AnimationStage *fromDef(const de::Record &stageDef);
de::String description() const;
};
public:
LightMaterialDecoration(const de::Vec2i &patternSkip = de::Vec2i(),
const de::Vec2i &patternOffset = de::Vec2i(),
bool useInterpolation = true);
virtual ~LightMaterialDecoration();
/**
* Construct a new material decoration from the specified definition.
*/
static LightMaterialDecoration *fromDef(const de::Record &decorationDef);
de::String describe() const;
/**
* Add a new animation stage to the material light decoration.
*
* @param stage New stage to add (a copy is made).
*
* @return Index of the newly added stage (0 based).
*/
int addStage(const AnimationStage &stage);
/**
* Lookup an AnimationStage by it's unique @a index.
*
* @param index Index of the AnimationStage to lookup. Will be cycled into valid range.
*/
AnimationStage &stage(int index) const;
/**
* Returns @c true if interpolation should be used with this decoration.
*/
bool useInterpolation() const;
private:
bool _useInterpolation;
};
#endif // CLIENT_RESOURCE_MATERIALLIGHTDECORATION_H