Elaztek Developer Hub
Blamite Game Engine - blam!  00453.06.08.26.0624.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: 2 //
6 // -------- //
7 // Part of the Blamite Game Engine //
8 // Copyright (c) Elaztek Studios 2013 - 2023 //
10 
11 
12 #pragma once
13 
14 #include <string>
15 #include <blam/api/v1/types/tags.h>
17 
18 #ifndef BLAM
19 #define BLAM
20 #endif
21 
22 #define tag_ligh "ligh"
23 
24 
25 
26 #pragma pack(push, 1)
27 struct light
28 {
30  {
31  bool casts_shadows : 1;
32  bool double_sided : 1;
34  bool unused3 : 1;
35  bool unused4 : 1;
36  bool unused5 : 1;
37  bool unused6 : 1;
38  bool unused7 : 1;
39  bool unused8 : 1;
40  bool unused9 : 1;
41  bool unused10 : 1;
42  bool unused11 : 1;
43  bool unused12 : 1;
44  bool unused13 : 1;
45  bool unused14 : 1;
46  bool unused15 : 1;
47  };
48 
54  TAG_ENUM(shape,
55  {
56  directional,
57  point,
58  spotlight,
59  virtual_point,
60  area_cheap,
61  area_pbr,
62  });
63 
72  TAG_BLOCK(spotlight_settings,
73  {
74  real inner_angle;
75  real outer_angle;
76  real falloff;
78  });
79  TAG_ENUM(attenuation_method,
80  {
81  simple,
82  complex,
83  });
84 
85  TAG_BLOCK(simple_attenuation,
86  {
87  real radius;
88  real luminance_threshold;
89  });
90  TAG_BLOCK(complex_attenuation,
91  {
92  real range;
93  real constant;
94  real linear;
95  real quadratic;
96  });
97 };
98 #pragma pack(pop)
99 
101 {
102 public:
104  {
105  class_name_long = "light";
106  class_name_short = "ligh";
107  version = 2;
108 
109  revisions = {
110  {1, "haloman30", "Initial implementation."},
111  {2, "haloman30", "* Added priority field"},
112 
113  };
114 
115  tag_size = 142;
116 
117  fields =
118  {
119  new CommentField("LIGHT",
120  ""),
121  new Bitfield16Field("flags", "",
122  {
123  "casts shadows",
124  "double sided",
125  "fields can be overridden by instances",
126  }),
127  new Int32Field("priority", ""),
128  new CommentField("SHAPE",
129  "shape of the light"),
130  new Enum32Field("shape", "The shape/type of the light source.",
131  {
132  "directional",
133  "point",
134  "spotlight",
135  "virtual point",
136  "area (cheap)",
137  "area (pbr)",
138  }),
139  new RealField("power scale", "The relative power scale of the light."),
140  new CommentField("COLOR",
141  "color and intensity of the light"),
142  new ColorField("diffuse color", ""),
143  new ColorField("specular color", ""),
144  new CommentField("CULLING",
145  "determines how the light is rendered when the camera is close or far from the light"),
146  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."),
147  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."),
148  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."),
149  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."),
150  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."),
151  new BlockField(16, "spotlight settings", "",
152  {
153  new CommentField("SHAPE",
154  "the shape of the spotlight"),
155  new RealField("inner angle", ""),
156  new RealField("outer angle", ""),
157  new CommentField("FALLOFF",
158  "the falloff of the spotlight"),
159  new RealField("falloff", ""),
160  new RealField("near clip distance", ""),
161  }),
162  new CommentField("ATTENUATION",
163  "Controls how light diminishes with distance.\n"
164  "\n"
165  "Of the two blocks listed below, only one will be used based on the 'attenuation method' value:\n"
166  "* simple - The 'simple attenuation' block is used.\n"
167  "* complex - The 'complex attenuation' block is used.\n"
168  "\n"
169  "Only the first entry of a block will be used. Any other entries are ignored."),
170  new Enum32Field("attenuation method", "",
171  {
172  "simple",
173  "complex",
174  }),
175  new BlockField(8, "simple attenuation", "",
176  {
177  new RealField("radius", ""),
178  new RealField("luminance threshold", ""),
179  }),
180  new BlockField(16, "complex attenuation", "",
181  {
182  new RealField("range", ""),
183  new RealField("constant", ""),
184  new RealField("linear", ""),
185  new RealField("quadratic", ""),
186  }),
187 
188  };
189  }
190 };
191 
192 namespace Blam::Content::Tags
193 {
194  BLAM light* GetLightTag(std::string tag_path);
195 }
variable_type::int
@ int
light::bitfield16_flags
Definition: light.h:29
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:181
RealField
Class representing a real tag field.
Definition: real.h:16
light::bitfield16_flags::unused12
bool unused12
Definition: light.h:43
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
Blam::Globals::GlobalExists
BLAM bool GlobalExists(std::string id)
Determines whether or not a global exists.
Definition: globals.cpp:27
globals
Definition: globals.h:27
Real
@ Real
Definition: globals.h:25
String
@ String
Represents a std::string.
Definition: globals.h:29
light::bitfield16_flags::double_sided
bool double_sided
Definition: light.h:32
Long
@ Long
Represents a long.
Definition: globals.h:27
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:447
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:68
logger.h
Blam::Globals::UpdateGlobal
BLAM BlamGlobalUpdateResult UpdateGlobal(std::string name, std::string new_value)
Updates the value of a String global.
Definition: globals.cpp:589
BlamGlobalUpdateResult::InvalidArgs
@ InvalidArgs
The provided arguments were invalid.
Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:24
light::TAG_ENUM
TAG_ENUM(shape, { directional, point, spotlight, virtual_point, area_cheap, area_pbr, })
The shape/type of the light source.
BlamEngineGlobal::name
std::string name
The name of the global.
Definition: globals.h:47
Blam::Globals
Namespace containing functions relating to game engine globals.
Definition: globals.h:23
light::bitfield16_flags::unused3
bool unused3
Definition: light.h:34
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:69
Blam::Globals::LoadGlobalsFromFile
BLAM bool LoadGlobalsFromFile()
Loads any globals from #GVARS_FILE.
Definition: globals.cpp:202
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:403
BlamEngineGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: globals.h:56
BlamGlobalUpdateResult::OutOfBounds
@ OutOfBounds
The provided value was too small or too large for the globals' data type.
Int
@ Int
Represents an int.
Definition: globals.h:30
light::bitfield16_flags::unused7
bool unused7
Definition: light.h:38
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:70
light::bitfield16_flags::unused10
bool unused10
Definition: light.h:41
light::TAG_BLOCK
TAG_BLOCK(spotlight_settings, { real inner_angle;real outer_angle;real falloff;real near_clip_distance;})
bitmap_filtering_mode::point
@ point
light::bitfield16_flags::unused8
bool unused8
Definition: light.h:39
BlamGlobalUpdateResult::InvalidType
@ InvalidType
The provided value was of an invalid type.
Blam::Globals::GetGlobalAsColor
BLAM BlamColor * GetGlobalAsColor(std::string name)
Retrieves a global's value as a BlamColor.
Definition: globals.cpp:415
BlamEngineGlobal::info
std::string info
An optional description of the global.
Definition: globals.h:48
Enum32Field
Definition: enum.h:45
Blam::API::v1::Tags::GetTagData
BLAM_EXT_API BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: api.cpp:208
BlamGlobalUpdateResult
BlamGlobalUpdateResult
Enumerator for the result of a global update attempt.
Definition: globals.h:9
BlamTagClass::fields
std::vector< BlamTagClassField * > fields
A series of tag fields that store the layout of the tag.
Definition: tags.h:209
GLOBALS_FILE
#define GLOBALS_FILE
The file to read globals from.
Definition: globals.h:12
BlamEngineGlobal::type
BlamGlobalType type
The type of the global.
Definition: globals.h:46
light.h
tag_ligh
#define tag_ligh
Definition: light.h:22
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:208
int32_t
int int32_t
Definition: stdint.h:13
BlamGlobalUpdateResult::GlobalIsProtected
@ GlobalIsProtected
The specified global is protected and cannot be modified during runtime.
light
Definition: light.h:27
plugins.h
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:206
LightTagClass
Definition: light.h:100
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:34
BlamGlobalType
BlamGlobalType
Enumerator for the type of global variable.
Definition: globals.h:22
light::diffuse_color
color diffuse_color
Definition: light.h:65
light::flags
bitfield16_flags flags
Bitfield data for flags. See #bitfield16_flags for details.
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:207
BlamEngineGlobal
Structure containing data for a game engine global.
Definition: globals.h:44
globals.h
light::power_scale
real power_scale
The relative power scale of the light.
Definition: light.h:64
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:205
Blam::Globals::RegisterGlobal
BLAM void RegisterGlobal(BlamEngineGlobal var)
Registers a new engine global.
Definition: globals.cpp:61
Blam::Globals::GetGlobalAsShort
BLAM short * GetGlobalAsShort(std::string name)
Retrieves a global's value as a short.
Definition: globals.cpp:367
BlamEngineDataFolder::Resources
@ Resources
Directory containing other resources and data, usually string tables and globals. Defaults to ....
real
float real
Typedef for a 'real', aka a float.
Definition: tags.h:443
BlamEngineGlobal::short_value
short short_value
The short value of the global.
Definition: globals.h:57
BlamEngineGlobal::read_only
bool read_only
Whether or not the global is protected from modification.
Definition: globals.h:50
light::bitfield16_flags::fields_can_be_overridden_by_instances
bool fields_can_be_overridden_by_instances
Definition: light.h:33
bitmap_filtering_mode::linear
@ linear
Blam::Globals::GetGlobalTypeLabel
BLAM std::string GetGlobalTypeLabel(BlamGlobalType type)
Retrieves a string representation of a global's type, for use in UI.
Definition: globals.cpp:40
light::bitfield16_flags::unused11
bool unused11
Definition: light.h:42
Blam::Globals::GetGlobal
BLAM BlamEngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:189
BlamEngineGlobal::color_value
BlamColor color_value
The color value of the global.
Definition: globals.h:61
globals
std::map< std::string, BlamEngineGlobal > globals
The list of loaded globals.
Definition: globals.cpp:20
value
Offset font vertically by altering the io Font DisplayOffset value
Definition: README.txt:67
Short
@ Short
!< Represents a float.
Definition: globals.h:26
Blam::Globals::GetGlobalAsLong
BLAM long * GetGlobalAsLong(std::string name)
Retrieves a global's value as a long.
Definition: globals.cpp:379
Int32Field
Class representing an int32 tag field.
Definition: int.h:46
light::bitfield16_flags::unused14
bool unused14
Definition: light.h:45
Blam::Content::Tags::GetGlobalsTag
BLAM globals * GetGlobalsTag(std::string tag_path)
Definition: globals.cpp:16
BlamGlobalUpdateResult::UnknownGlobal
@ UnknownGlobal
The specified global does not exist.
BLAM
#define BLAM
Definition: light.h:19
light::bitfield16_flags::unused6
bool unused6
Definition: light.h:37
light::bitfield16_flags::unused9
bool unused9
Definition: light.h:40
light::bitfield16_flags::unused5
bool unused5
Definition: light.h:36
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:210
BlamEngineGlobal::int_value
int int_value
The int value of the global.
Definition: globals.h:59
ColorField
Class representing a color tag field.
Definition: color.h:19
globals.h
light::bitfield16_flags::casts_shadows
bool casts_shadows
Definition: light.h:31
BlamGlobalUpdateResult::Ok
@ Ok
The global was updated successfully.
LightTagClass::LightTagClass
LightTagClass()
Definition: light.h:103
Blam::Globals::GetGlobalAsString
BLAM std::string * GetGlobalAsString(std::string name)
Retrieves a global's value as a string.
Definition: globals.cpp:355
BlamTagData::address
void * address
The address pointing to the start of the tag's data.
Definition: tags.h:132
tag_matg
#define tag_matg
Definition: globals.h:22
light::specular_color
color specular_color
Definition: light.h:66
config.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
Blam::Globals::UpdateGlobalWrap
BLAM BlamGlobalUpdateResult UpdateGlobalWrap(std::string name, std::string new_value)
Updates a global's raw value.
Definition: globals.cpp:431
BlamEngineGlobal::float_value
float float_value
The float value of the global.
Definition: globals.h:60
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:19
light::priority
int32_t priority
Definition: light.h:50
Blam::Content::Tags::GetLightTag
BLAM light * GetLightTag(std::string tag_path)
Definition: light.cpp:16
BlamEngineGlobal::value_raw
std::string value_raw
The raw value of the global as a string.
Definition: globals.h:49
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:67
Blam::Globals::GetGlobalAsBoolean
BLAM bool * GetGlobalAsBoolean(std::string name)
Retrieves a global's value as a boolean.
Definition: globals.cpp:343
BlamTagClass
Class representing a tag class.
Definition: tags.h:202
Color
@ Color
Represents a BlamColor. See #BlamColor for details.
Definition: globals.h:31
light::bitfield16_flags::unused13
bool unused13
Definition: light.h:44
Blam::Globals::GetGlobalsList
BLAM std::map< std::string, BlamEngineGlobal > * GetGlobalsList()
Retrieves the list of loaded globals.
Definition: globals.cpp:22
light::bitfield16_flags::unused4
bool unused4
Definition: light.h:35
BlamEngineGlobal::long_value
long long_value
The long value of the global.
Definition: globals.h:58
api.h
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:71
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:146
Blam::Globals::GetGlobalAsInteger
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:391
light::bitfield16_flags::unused15
bool unused15
Definition: light.h:46