Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
light.h
Go to the documentation of this file.
1 // light [ligh] - Tag Definition //
3 // -------- //
4 // Author: haloman30 //
5 // Revision: 1 //
6 // -------- //
7 // Part of the Blamite Game Engine //
8 // Copyright (c) Elaztek Studios 2013 - 2023 //
10 
11 
12 #pragma once
13 
14 #include <string>
18 
19 #ifndef BLAM
20 #define BLAM
21 #endif
22 
23 
24 
25 #pragma pack(push, 1)
26 struct light
27 {
28  //LIGHT
29 
31  //SHAPE
32  /*shape of the light*/
36  TAG_ENUM(shape,
37  {
38  directional,
39  point,
40  spotlight,
41  virtual_point,
42  area_cheap,
43  area_pbr,
44  });
45 
47  //COLOR
48  /*color and intensity of the light*/
51  //CULLING
52  /*determines how the light is rendered when the camera is close or far from the light*/
58  TAG_BLOCK(spotlight_settings,
59  {
60  //SHAPE
61  /*the shape of the spotlight*/
62  real inner_angle;
63  real outer_angle;
64  //FALLOFF
65  /*the falloff of the spotlight*/
66  real falloff;
68  });
69  //ATTENUATION
70  /*Controls how light diminishes with distance.
71 
72  Of the two blocks listed below, only one will be used based on the 'attenuation method' value:
73  * simple - The 'simple attenuation' block is used.
74  * complex - The 'complex attenuation' block is used.
75 
76  Only the first entry of a block will be used. Any other entries are ignored.*/
77  TAG_ENUM(attenuation_method,
78  {
79  simple,
80  complex,
81  });
82 
83  TAG_BLOCK(simple_attenuation,
84  {
85  real radius;
86  real luminance_threshold;
87  });
88  TAG_BLOCK(complex_attenuation,
89  {
90  real range;
91  real constant;
92  real linear;
93  real quadratic;
94  });
95 };
96 #pragma pack(pop)
97 
99 {
100 public:
102  {
103  class_name_long = "light";
104  class_name_short = "ligh";
105  version = 1;
106 
107  revisions = {
108  {1, "haloman30", "Initial implementation."},
109 
110  };
111 
112  tag_size = 158;
113 
114  fields =
115  {
116  new CommentField("LIGHT",
117  ""),
118  new Bitfield16Field("flags", "",
119  {
120  "casts shadows",
121  "double sided",
122  "fields can be overridden by instances",
123  }),
124  new CommentField("SHAPE",
125  "shape of the light"),
126  new Enum32Field("shape", "The shape/type of the light source.",
127  {
128  "directional",
129  "point",
130  "spotlight",
131  "virtual point",
132  "area (cheap)",
133  "area (pbr)",
134  }),
135  new RealField("power scale", "The relative power scale of the light."),
136  new CommentField("COLOR",
137  "color and intensity of the light"),
138  new ColorField("diffuse color", ""),
139  new ColorField("specular color", ""),
140  new CommentField("CULLING",
141  "determines how the light is rendered when the camera is close or far from the light"),
142  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."),
143  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."),
144  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."),
145  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."),
146  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."),
147  new BlockField(16, "spotlight settings", "",
148  {
149  new CommentField("SHAPE",
150  "the shape of the spotlight"),
151  new RealField("inner angle", ""),
152  new RealField("outer angle", ""),
153  new CommentField("FALLOFF",
154  "the falloff of the spotlight"),
155  new RealField("falloff", ""),
156  new RealField("near clip distance", ""),
157  }),
158  new CommentField("ATTENUATION",
159  "Controls how light diminishes with distance.\n"
160  "\n"
161  "Of the two blocks listed below, only one will be used based on the 'attenuation method' value:\n"
162  "* simple - The 'simple attenuation' block is used.\n"
163  "* complex - The 'complex attenuation' block is used.\n"
164  "\n"
165  "Only the first entry of a block will be used. Any other entries are ignored."),
166  new Enum32Field("attenuation method", "",
167  {
168  "simple",
169  "complex",
170  }),
171  new BlockField(16, "simple attenuation", "",
172  {
173  new RealField("radius", ""),
174  new RealField("luminance threshold", ""),
175  }),
176  new BlockField(16, "complex attenuation", "",
177  {
178  new RealField("range", ""),
179  new RealField("constant", ""),
180  new RealField("linear", ""),
181  new RealField("quadratic", ""),
182  }),
183 
184  };
185  }
186 };
187 
188 namespace Blam::Content::Tags
189 {
190  BLAM light* GetLightTag(std::string tag_path);
191 }
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:196
RealField
Class representing a real tag field.
Definition: real.h:16
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:359
light::near_clip_distance
real near_clip_distance
The near clip distance of the light. If the camera is this close to the light, shadows will stop bein...
Definition: light.h:54
light::TAG_ENUM
TAG_ENUM(shape, { directional, point, spotlight, virtual_point, area_cheap, area_pbr, })
The shape/type of the light source.
light::far_clip_distance
real far_clip_distance
The far clip distance of the light. If the camera is at least this far from the light,...
Definition: light.h:55
Bitfield16Field
Class representing a bitfield16 tag field.
Definition: bitfield.h:44
light::near_shadow_distance
real near_shadow_distance
The near shadow distance of the light. If the camera is this close to the light, shadows will no long...
Definition: light.h:56
light::TAG_BLOCK
TAG_BLOCK(spotlight_settings, { real inner_angle;real outer_angle;real falloff;real near_clip_distance;})
bitmap_filtering_mode::point
@ point
Enum32Field
Definition: enum.h:46
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:138
light.h
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: tags.h:137
light
Definition: light.h:26
light::flags
bitfield16 flags
Definition: light.h:30
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:135
LightTagClass
Definition: light.h:98
light::diffuse_color
color diffuse_color
Definition: light.h:49
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:136
light::power_scale
real power_scale
The relative power scale of the light.
Definition: light.h:46
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:134
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:355
Blam::Content::Tags::GetTagData
BLAM BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: tags.cpp:80
bitmap_filtering_mode::linear
@ linear
fields.h
bitfield16
Typedef for a bitfield16 field, used in tag data definitions.
Definition: tags.h:290
BLAM
#define BLAM
Definition: light.h:20
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:139
ColorField
Class representing a color tag field.
Definition: color.h:19
LightTagClass::LightTagClass
LightTagClass()
Definition: light.h:101
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:71
light::specular_color
color specular_color
Definition: light.h:50
tagclass.h
tags.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:68
CommentField
Class representing a comment field.
Definition: comment.h:29
BlockField
Class representing a tag block field, also sometimes referred to as a struct or reflexive in the modd...
Definition: block.h:21
Blam::Content::Tags::GetLightTag
BLAM light * GetLightTag(std::string tag_path)
Definition: light.cpp:16
light::maximum_distance
real maximum_distance
The maximum distance that this light will be visible. If the camera is further than this distance awa...
Definition: light.h:53
BlamTagClass
Class representing a tag class.
Definition: tags.h:131
light::far_shadow_distance
real far_shadow_distance
The far shadow distance of the light. If the camera is this far from the light, shadows will no longe...
Definition: light.h:57