Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.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>
15 #include <blam/api/v1/types/tags.h>
17 
18 #ifndef BLAM
19 #define BLAM
20 #endif
21 
22 
23 
24 #pragma pack(push, 1)
25 struct light
26 {
27  //LIGHT
28 
30  //SHAPE
31  /*shape of the light*/
35  TAG_ENUM(shape,
36  {
37  directional,
38  point,
39  spotlight,
40  virtual_point,
41  area_cheap,
42  area_pbr,
43  });
44 
46  //COLOR
47  /*color and intensity of the light*/
50  //CULLING
51  /*determines how the light is rendered when the camera is close or far from the light*/
57  TAG_BLOCK(spotlight_settings,
58  {
59  //SHAPE
60  /*the shape of the spotlight*/
61  real inner_angle;
62  real outer_angle;
63  //FALLOFF
64  /*the falloff of the spotlight*/
65  real falloff;
67  });
68  //ATTENUATION
69  /*Controls how light diminishes with distance.
70 
71  Of the two blocks listed below, only one will be used based on the 'attenuation method' value:
72  * simple - The 'simple attenuation' block is used.
73  * complex - The 'complex attenuation' block is used.
74 
75  Only the first entry of a block will be used. Any other entries are ignored.*/
76  TAG_ENUM(attenuation_method,
77  {
78  simple,
79  complex,
80  });
81 
82  TAG_BLOCK(simple_attenuation,
83  {
84  real radius;
85  real luminance_threshold;
86  });
87  TAG_BLOCK(complex_attenuation,
88  {
89  real range;
90  real constant;
91  real linear;
92  real quadratic;
93  });
94 };
95 #pragma pack(pop)
96 
98 {
99 public:
101  {
102  class_name_long = "light";
103  class_name_short = "ligh";
104  version = 1;
105 
106  revisions = {
107  {1, "haloman30", "Initial implementation."},
108 
109  };
110 
111  tag_size = 158;
112 
113  fields =
114  {
115  new CommentField("LIGHT",
116  ""),
117  new Bitfield16Field("flags", "",
118  {
119  "casts shadows",
120  "double sided",
121  "fields can be overridden by instances",
122  }),
123  new CommentField("SHAPE",
124  "shape of the light"),
125  new Enum32Field("shape", "The shape/type of the light source.",
126  {
127  "directional",
128  "point",
129  "spotlight",
130  "virtual point",
131  "area (cheap)",
132  "area (pbr)",
133  }),
134  new RealField("power scale", "The relative power scale of the light."),
135  new CommentField("COLOR",
136  "color and intensity of the light"),
137  new ColorField("diffuse color", ""),
138  new ColorField("specular color", ""),
139  new CommentField("CULLING",
140  "determines how the light is rendered when the camera is close or far from the light"),
141  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."),
142  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."),
143  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."),
144  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."),
145  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."),
146  new BlockField(16, "spotlight settings", "",
147  {
148  new CommentField("SHAPE",
149  "the shape of the spotlight"),
150  new RealField("inner angle", ""),
151  new RealField("outer angle", ""),
152  new CommentField("FALLOFF",
153  "the falloff of the spotlight"),
154  new RealField("falloff", ""),
155  new RealField("near clip distance", ""),
156  }),
157  new CommentField("ATTENUATION",
158  "Controls how light diminishes with distance.\n"
159  "\n"
160  "Of the two blocks listed below, only one will be used based on the 'attenuation method' value:\n"
161  "* simple - The 'simple attenuation' block is used.\n"
162  "* complex - The 'complex attenuation' block is used.\n"
163  "\n"
164  "Only the first entry of a block will be used. Any other entries are ignored."),
165  new Enum32Field("attenuation method", "",
166  {
167  "simple",
168  "complex",
169  }),
170  new BlockField(16, "simple attenuation", "",
171  {
172  new RealField("radius", ""),
173  new RealField("luminance threshold", ""),
174  }),
175  new BlockField(16, "complex attenuation", "",
176  {
177  new RealField("range", ""),
178  new RealField("constant", ""),
179  new RealField("linear", ""),
180  new RealField("quadratic", ""),
181  }),
182 
183  };
184  }
185 };
186 
187 namespace Blam::Content::Tags
188 {
189  BLAM light* GetLightTag(std::string tag_path);
190 }
variable_type::int
@ int
Blam::Content::Tags
Namespace containing functions related to tag data.
Definition: bitmap.h:197
RealField
Class representing a real tag field.
Definition: real.h:16
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:25
Real
@ Real
Definition: globals.h:25
String
@ String
Represents a std::string.
Definition: globals.h:29
Long
@ Long
Represents a long.
Definition: globals.h:27
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:428
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:53
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:574
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::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:54
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
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:55
light::TAG_BLOCK
TAG_BLOCK(spotlight_settings, { real inner_angle;real outer_angle;real falloff;real near_clip_distance;})
bitmap_filtering_mode::point
@ point
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:46
Blam::API::v1::Tags::GetTagData
BLAM_EXT_API BlamTagData * GetTagData(std::string tag_path)
Retrieves information for a given tag.
Definition: api.cpp:197
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:200
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
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:199
BlamGlobalUpdateResult::GlobalIsProtected
@ GlobalIsProtected
The specified global is protected and cannot be modified during runtime.
light
Definition: light.h:25
plugins.h
light::flags
bitfield16 flags
Definition: light.h:29
BlamTagClass::class_name_short
std::string class_name_short
The short, 4-character name of the tag class.
Definition: tags.h:197
LightTagClass
Definition: light.h:97
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:48
BlamTagClass::version
int version
The tag class version. Should be incremented any time a tag class is modified whatsoever.
Definition: tags.h:198
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:45
BlamTagClass::class_name_long
std::string class_name_long
The longer class name. Typically shown alongside short name for user-friendliness.
Definition: tags.h:196
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:424
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
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
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
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
globals
std::map< std::string, BlamEngineGlobal > globals
The list of loaded globals.
Definition: globals.cpp:20
Blam::Content::Tags::GetGlobalsTag
BLAM globals * GetGlobalsTag(std::string tag_path)
Definition: globals.cpp:16
bitfield16
Typedef for a bitfield16 field, used in tag data definitions.
Definition: tags.h:359
BlamGlobalUpdateResult::UnknownGlobal
@ UnknownGlobal
The specified global does not exist.
BLAM
#define BLAM
Definition: light.h:19
BlamTagClass::tag_size
int tag_size
The size of the tag's data. Used on loading/writing tag files.
Definition: tags.h:201
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
BlamGlobalUpdateResult::Ok
@ Ok
The global was updated successfully.
LightTagClass::LightTagClass
LightTagClass()
Definition: light.h:100
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:130
light::specular_color
color specular_color
Definition: light.h:49
config.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:124
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
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:52
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:193
Color
@ Color
Represents a BlamColor. See #BlamColor for details.
Definition: globals.h:31
Blam::Globals::GetGlobalsList
BLAM std::map< std::string, BlamEngineGlobal > * GetGlobalsList()
Retrieves the list of loaded globals.
Definition: globals.cpp:22
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:56
Blam::Globals::GetGlobalAsInteger
BLAM int * GetGlobalAsInteger(std::string name)
Retrieves a global's value as an int.
Definition: globals.cpp:391