PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
directional_light_component.h
1#pragma once
2
3#include "pixelbullet/serialization/glm_node.h"
4
5namespace pixelbullet
6{
8{
9 bool enabled = true;
10 glm::vec3 color = glm::vec3(1.0f);
11 float intensity = 1.0f;
12 bool shadow_enabled = false;
13 float shadow_strength = 1.0f;
14 float shadow_bias = 0.0015f;
15 float shadow_normal_bias = 0.02f;
16 float shadow_distance = 24.0f;
17};
18
19inline Node& operator<<(Node& node, const DirectionalLightComponent& light)
20{
21 node["enabled"] << light.enabled;
22 node["color"] << light.color;
23 node["intensity"] << light.intensity;
24 node["shadowEnabled"] << light.shadow_enabled;
25 node["shadowStrength"] << light.shadow_strength;
26 node["shadowBias"] << light.shadow_bias;
27 node["shadowNormalBias"] << light.shadow_normal_bias;
28 node["shadowDistance"] << light.shadow_distance;
29 return node;
30}
31
32inline const Node& operator>>(const Node& node, DirectionalLightComponent& light)
33{
34 node["enabled"] >> light.enabled;
35 node["color"] >> light.color;
36 node["intensity"] >> light.intensity;
37 if (node.HasProperty("shadowEnabled"))
38 {
39 node["shadowEnabled"] >> light.shadow_enabled;
40 }
41 if (node.HasProperty("shadowStrength"))
42 {
43 node["shadowStrength"] >> light.shadow_strength;
44 }
45 if (node.HasProperty("shadowBias"))
46 {
47 node["shadowBias"] >> light.shadow_bias;
48 }
49 if (node.HasProperty("shadowNormalBias"))
50 {
51 node["shadowNormalBias"] >> light.shadow_normal_bias;
52 }
53 if (node.HasProperty("shadowDistance"))
54 {
55 node["shadowDistance"] >> light.shadow_distance;
56 }
57 return node;
58}
59} // namespace pixelbullet
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition directional_light_component.h:8