Elaztek Developer Hub
Blamite Game Engine - blam!  00368.02.12.23.1347.blamite
The core library for the Blamite Game Engine.
light.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #ifndef BLAM
7 #define BLAM
8 #endif
9 
10 namespace Blam::Content::Tags
11 {
12 #pragma pack(push, 1)
13 
19  struct light
20  {
22 
23  // SHAPE
24  TAG_ENUM(shape,
25  {
26  directional,
27  point,
28  spotlight,
29  virtual_point,
30  area_cheap,
31  area_pbr
32  });
36 
37  // COLOR
40 
41  // CULLING
47 
48  TAG_BLOCK(spotlight_settings,
49  {
50  // SHAPE
51  real spotlight_inner_angle;
52  real spotlight_outer_angle;
53 
54  // FALLOFF
55  real spotlight_falloff;
56  real spotlight_near_clip_distance;
57  });
58 
59  // ATTENUATION
60  TAG_ENUM(attenuation_method,
61  {
62  simple,
63  complex
64  });
65 
66  TAG_BLOCK(simple_attenuation,
67  {
68  real radius;
69  real luminance_threshold;
70  });
71 
72  TAG_BLOCK(attenuation,
73  {
74  real range;
75  real constant;
76  real linear;
77  real quadratic;
78  });
79  };
80 #pragma pack(pop)
81 
82  namespace Classes
83  {
84  class LightTagClass : public BlamTagClass
85  {
86  public:
88  {
89  class_name_long = "light";
90  class_name_short = "ligh";
91  version = 2;
92 
93  revisions = {
94  {1, "haloman30", "Initial implementation."}
95  };
96 
97  tag_size = sizeof(light);
98 
99  fields =
100  {
101  new CommentField("LIGHT", ""),
102  new Bitfield16Field("flags", "",
103  {
104  "casts shadows",
105  "double sided",
106  "fields can be overridden by instances"
107  }),
108 
109  new CommentField("SHAPE", "shape of the light"),
110  new Enum32Field("shape", "The shape/type of the light source.",
111  {
112  "directional",
113  "point",
114  "spotlight",
115  "virtual point",
116  "area (cheap)",
117  "area (pbr)"
118  }),
119  new RealField("power scale", "The relative power scale of the light."),
120 
121 
122  new CommentField("COLOR", "color and intensity of the light"),
123  new ColorField("diffuse color" , ""),
124  new ColorField("specular color" , ""),
125 
126  //new CommentField("FALLOFF", "the falloff of the light"),
127  //new RealField("spotlight falloff", "The falloff between the inner and outer cones of the spotlight. Only applies if light shape is 'spotlight'."),
128 
129 
130  new CommentField("CULLING", "determines how the light is rendered when the camera is close or far from the light"),
131 
132  new RealField("maximum distance", "The maximum distance that this light will be visible. If the camera is further than this distance away from the light, then the light will no longer be rendered."),
133  new RealField("near clip distance", "The near clip distance of the light. If the camera is this close to the light, shadows will stop being rendered. Only applies when using texture shadows."),
134  new RealField("far clip distance", "The far clip distance of the light. If the camera is at least this far from the light, shadows will stop being rendered. Only applies when using texture shadows."),
135  new RealField("near shadow distance", "The near shadow distance of the light. If the camera is this close to the light, shadows will no longer be cast by this light source."),
136  new RealField("far shadow distance", "The far shadow distance of the light. If the camera is this far from the light, shadows will no longer be cast by this light source."),
137 
138  new BlockField(sizeof(light::spotlight_settings_entry), "spotlight settings", "",
139  {
140  new CommentField("SHAPE", "the shape of the spotlight"),
141  new RealField("inner angle", ""),
142  new RealField("outer angle", ""),
143 
144  new CommentField("FALLOFF", "the falloff of the spotlight"),
145  new RealField("falloff", ""),
146  new RealField("near clip distance", ""),
147  }),
148 
149  new CommentField("ATTENUATION", "Controls how light diminishes with distance."
150  "\n\nOf the two blocks listed below, only one will be used based on the 'attenuation method' value:"
151  "\n* simple - The 'simple attenuation' block is used."
152  "\n* complex - The 'complex attenuation' block is used."
153  "\n\nOnly the first entry of a block will be used. Any other entries are ignored."),
154 
155  new Enum32Field("attenuation method", "",
156  {
157  "simple",
158  "complex"
159  }),
160 
161  new BlockField(sizeof(light::spotlight_settings_entry), "simple attenuation", "",
162  {
163  new RealField("radius", ""),
164  new RealField("luminance threshold", ""),
165  }),
166 
167  new BlockField(sizeof(light::spotlight_settings_entry), "complex attenuation", "",
168  {
169  new RealField("range", ""),
170  new RealField("constant", ""),
171  new RealField("linear", ""),
172  new RealField("quadratic", ""),
173  }),
174  };
175  }
176  };
177  }
178 
179  BLAM light* GetLightTag(std::string tag_path);
180 }
Blam::Content::Tags::light::rect_size
vector2 rect_size
Definition: light.h:34
vector2
BlamVector2 vector2
Typedef for a vector2 field, used in tag definitions.
Definition: tags.h:316
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:151
RealField
Class representing a real tag field.
Definition: real.h:10
Blam::Content::Tags::light
Structure representing a Light tag.
Definition: light.h:19
Blam::Content::Tags::light::far_clip_distance
real far_clip_distance
Definition: light.h:44
Blam::Content::Tags::Classes::LightTagClass
Definition: light.h:84
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:319
Blam::Content::Tags::light::TAG_BLOCK
TAG_BLOCK(spotlight_settings, { real spotlight_inner_angle;real spotlight_outer_angle;real spotlight_falloff;real spotlight_near_clip_distance;})
Blam::Content::Tags::Classes::LightTagClass::LightTagClass
LightTagClass()
Definition: light.h:87
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:38
Blam::Content::Tags::light::maximum_distance
real maximum_distance
Definition: light.h:42
Blam::Content::Tags::light::direction
vector3 direction
Definition: light.h:35
Enum32Field
Definition: enum.h:40
Blam::Content::Tags::light::specular_color
color specular_color
Definition: light.h:39
Blam::Content::Tags::light::near_clip_distance
real near_clip_distance
Definition: light.h:43
BlamTagClass::revisions
std::vector< BlamTagClassRevision > revisions
List of all tag class revisions. Does not get written to tags, but is included in plugin files.
Definition: tagclass.h:49
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tagclass.h:47
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tagclass.h:48
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tagclass.h:46
Blam::Content::Tags::light::TAG_ENUM
TAG_ENUM(shape, { directional, point, spotlight, virtual_point, area_cheap, area_pbr })
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:315
Blam::Content::Tags::GetLightTag
BLAM light * GetLightTag(std::string tag_path)
Definition: light.cpp:5
fields.h
bitfield16
Typedef for a bitfield16 field, used in tag data definitions.
Definition: tags.h:250
BLAM
#define BLAM
Definition: light.h:7
vector3
BlamVector3 vector3
Typedef for a vector3 field, used in tag definitions.
Definition: tags.h:317
Blam::Content::Tags::light::far_shadow_distance
real far_shadow_distance
Definition: light.h:46
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tagclass.h:53
ColorField
Class representing a color tag field.
Definition: color.h:13
Blam::Content::Tags::light::near_shadow_distance
real near_shadow_distance
Definition: light.h:45
tagclass.h
Blam::Content::Tags::light::diffuse_color
color diffuse_color
Definition: light.h:38
Blam::Content::Tags::light::flags
bitfield16 flags
Definition: light.h:21
Blam::Content::Tags::light::power_scale
real power_scale
Definition: light.h:33
CommentField
Class representing a comment field.
Definition: comment.h:23
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:13
BlamTagClass
Class representing a tag class.
Definition: tagclass.h:43
BlamTagClass::fields
std::vector< BlamPluginField * > fields
A series of tag fields that store the layout of the tag.
Definition: tagclass.h:51