Claude Chappe' Curse - A C Game
Logo Institut d'Informatique Claude Chappe Logo Université de Le Mans Logo Raeptor Production
 
Loading...
Searching...
No Matches
DirectionalLight Class Reference

Represents a directional light source. More...

#include <lighting.h>

Inheritance diagram for DirectionalLight:
Collaboration diagram for DirectionalLight:

Public Member Functions

void constructor (float r, float g, float b, float bias, float size, float constant, float linear, float quadratic)
 Constructor for the directional light class.
 
void update (vec3 pos, vec3 rot, vec3 scale, double delta, u8 *lightsCount)
 Updates the state of a directional light.
 
void get_settings_data (void ***ptr, int *length)
 Retrieves the settings data for the directional light.
 
void load (FILE *file)
 Loads data from a file.
 
void save (FILE *file)
 Saves the current state of the directional light to a file.
 
void configure_lighting (Camera *c, WorldShaders *shaders, DepthMap *depthMap, u8 *lightsCount)
 Configures the directional lighting for the specified camera.
 
- Public Member Functions inherited from Light
void init_light ()
 Initializes the light object.
 
void is_gui_element (bool *result)
 Determines if the current object is a GUI element.
 
void render (mat4 modelMatrix, Shader activeShader)
 Renders the light using the provided model matrix and active shader.
 
void init_vao ()
 Initializes the Vertex Array Object (VAO) for the light class.
 
void configure_lighting (WorldShaders *shaders, mat4 lightView, mat4 lightProjection, int storageBufferIndex, DepthMap *depthMap)
 Configures the lighting for the scene.
 
- Public Member Functions inherited from Node
void constructor ()
 Constructor for the Node class.
 
void initialize_node ()
 Initializes a node.
 
void get_glow_shader (Shader *shader)
 Retrieves the glow shader.
 
void get_settings_data (void ***ptr, int *length)
 Retrieves settings data.
 
void load ()
 Loads the necessary resources or data for the node.
 
void save (FILE *file)
 Saves the current state to the specified file.
 
void prepare_render (mat4 modelMatrix, Shader activeShader)
 Renders a node using the specified model matrix and shader.
 
void render ()
 Renders the node.
 
void update_global_position (vec3 pos, vec3 rot, vec3 scale)
 Updates the global position of a node.
 
void update (vec3 pos, vec3 rot, vec3 scale)
 Updates the position, rotation, and scale of a node.
 
void on_resize ()
 Handles the resize event for the node.
 
void free ()
 Frees the resources allocated by the object.
 
void is_cshape (bool *cshape)
 Checks if the current shape is a custom shape.
 
void is_body (bool *body)
 Sets the body status of the node.
 
void is_area (bool *area)
 Checks if the current node is within a specified area.
 
void is_render_target (bool *render_target)
 Sets the render target status.
 
void is_gui_element (bool *result)
 Determines if the current node is a GUI element.
 
void add_child (Node *child)
 Adds a child node to a parent node.
 
void add_child_and_realloc (Node *child)
 Adds a child node to a parent node and reallocates memory if necessary.
 
void remove_child (Node *child)
 Removes a child node from a parent node.
 
void remove_child_and_realloc (Node *child)
 Removes a child node from a parent node and reallocates memory if necessary.
 
void remove_child_and_free (Node *child)
 Removes a child node from a parent node and frees the memory of the child node.
 
void remove_child_and_free_and_realloc (Node *child)
 Removes a child node from a parent node, frees the memory of the child node, and reallocates memory if necessary.
 
int index_of_child (Node *child)
 Retrieves the index of a child node in a parent node's children array.
 
void print (int level)
 Prints the details of a node at a specified level of indentation.
 
void emit_ready (...)
 Emits the 'ready' signal for the node.
 
void emit_update (...)
 Emits an update event for the node.
 
void emit_signal (...)
 Emits a signal if the node has a script and the script has a signal handler.
 

Public Attributes

vec3 color
 
float bias
 
float size
 
float constant
 
float linear
 
float quadratic
 
- Public Attributes inherited from Node
void * object
 
struct Node ** children
 
struct Nodeparent
 
u16 length
 
u8 type
 
u8 flags
 
vec3 pos
 
vec3 rot
 
vec3 scale
 
vec3 globalPos
 
vec3 globalRot
 
vec3 globalScale
 
Behaviorbehavior
 
BehaviorAttributeattribute
 
u8 attributes_count
 
Shader shader
 

Additional Inherited Members

- Static Public Attributes inherited from Light
static VBO vbo = 0
 Static variable representing the Vertex Buffer Object (VBO) for the light class.
 
static VAO vao = 0
 Static variable representing the Vertex Array Object (VAO) for the light class.
 
static Shader billboardShader = 0
 Static variable representing the shader program used for rendering billboard lights.
 
static TextureMap lightPointTexture = 0
 Static variable representing the texture map for point lights.
 
static TextureMap directionalLightTexture = 0
 Static variable representing the texture map for directional lights.
 
- Static Public Attributes inherited from Node
static Shader glowShader = 0
 A static Shader variable used for glow effect.
 

Detailed Description

Represents a directional light source.

A directional light emits light in a specific direction, similar to sunlight. This structure contains the properties of a directional light, including ambient, diffuse, and specular components, as well as attenuation factors.

Member Function Documentation

◆ constructor()

void DirectionalLight::constructor ( float  r,
float  g,
float  b,
float  bias,
float  size,
float  constant,
float  linear,
float  quadratic 
)
inline

Constructor for the directional light class.

This function initializes a directional light with the specified parameters.

Parameters
rRed component of the light color.
gGreen component of the light color.
bBlue component of the light color.
biasBias value for the light.
sizeSize of the light.
constantConstant attenuation factor.
linearLinear attenuation factor.
quadraticQuadratic attenuation factor.

◆ update()

void DirectionalLight::update ( vec3  pos,
vec3  rot,
vec3  scale,
double  delta,
u8 lightsCount 
)
inline

Updates the state of a directional light.

This function updates the position, rotation, and scale of a directional light based on the given delta time and updates the count of active lights.

Parameters
posVec3 structure representing the position of the light.
rotVec3 structure representing the rotation of the light.
scaleVec3 structure representing the scale of the light.
deltaThe time delta used for updating the light's state.
lightsCountPointer to an unsigned 8-bit integer representing the count of active lights.

◆ get_settings_data()

void DirectionalLight::get_settings_data ( void ***  ptr,
int *  length 
)
inline

Retrieves the settings data for the directional light.

This function populates the provided pointer with the settings data and sets the length of the data.

Parameters
[out]ptrA pointer to a pointer to a pointer where the settings data will be stored. The function will allocate memory for the settings data and set this pointer to point to the allocated memory.
[out]lengthA pointer to an integer where the length of the settings data will be stored. The function will set this integer to the length of the settings data.

◆ load()

void DirectionalLight::load ( FILE *  file)
inline

Loads data from a file.

This function reads data from the given file and loads it into the appropriate structures or variables. The file pointer must be valid and opened in the appropriate mode for reading.

Parameters
fileA pointer to the FILE object that identifies the file to read from.

◆ save()

void DirectionalLight::save ( FILE *  file)
inline

Saves the current state of the directional light to a file.

This function writes the current state of the directional light object to the specified file.

Parameters
fileA pointer to the FILE object where the state will be saved.

◆ configure_lighting()

void DirectionalLight::configure_lighting ( Camera c,
WorldShaders shaders,
DepthMap depthMap,
u8 lightsCount 
)
inline

Configures the directional lighting for the specified camera.

This function configures the directional lighting for the specified camera.

Parameters
cThe camera for which the directional lighting is to be configured.
shadersThe shaders to be used for rendering.
lightsCountThe count of lights in the scene.
Note
This function is called by the render loop to configure the lighting for the specified camera.

Member Data Documentation

◆ color

vec3 DirectionalLight::color

Color component of the light.

◆ bias

float DirectionalLight::bias

Bias factor for the light.

◆ size

float DirectionalLight::size

Size factor for the light.

◆ constant

float DirectionalLight::constant

Constant attenuation factor for the light.

◆ linear

float DirectionalLight::linear

Linear attenuation factor for the light.

◆ quadratic

float DirectionalLight::quadratic

Quadratic attenuation factor for the light.


The documentation for this class was generated from the following files: