diff --git a/Game.cpp b/Game.cpp index 90429e5..89b3d7e 100644 --- a/Game.cpp +++ b/Game.cpp @@ -120,52 +120,13 @@ void Game::LoadLighting() { ambient = XMFLOAT3(0.1f, 0.1f, 0.15f); - Light directionalLight0 = {}; - directionalLight0.Type = LIGHT_TYPE_DIRECTIONAL; - directionalLight0.Direction = XMFLOAT3(1, 0.5f, 0.5f); - directionalLight0.Color = XMFLOAT3(1, 1, 1); - directionalLight0.Intensity = 0.5f; - - Light directionalLight1 = {}; - directionalLight1.Type = LIGHT_TYPE_DIRECTIONAL; - directionalLight1.Direction = XMFLOAT3(-0.25f, -1, 0.75f); - directionalLight1.Color = XMFLOAT3(1, 1, 1); - directionalLight1.Intensity = 0.5f; - - Light directionalLight2 = {}; - directionalLight2.Type = LIGHT_TYPE_DIRECTIONAL; - directionalLight2.Direction = XMFLOAT3(-1, 1, -0.5f); - directionalLight2.Color = XMFLOAT3(1, 1, 1); - directionalLight2.Intensity = 0.5f; - - Light pointLight0 = {}; - pointLight0.Type = LIGHT_TYPE_POINT; - pointLight0.Position = XMFLOAT3(-1.5f, 0, 0); - pointLight0.Color = XMFLOAT3(1, 1, 1); - pointLight0.Intensity = 0.5f; - pointLight0.Range = 10; - - Light pointLight1 = {}; - pointLight1.Type = LIGHT_TYPE_POINT; - pointLight1.Position = XMFLOAT3(1.5f, 0, 0); - pointLight1.Color = XMFLOAT3(1, 1, 1); - pointLight1.Intensity = 0.25f; - pointLight1.Range = 10; - - Light pointLight2 = {}; - pointLight2.Type = LIGHT_TYPE_POINT; - pointLight2.Position = XMFLOAT3(0, 2, 0); - pointLight2.Color = XMFLOAT3(1, 0, 0); - pointLight2.Intensity = 0.25f; - pointLight2.Range = 10; - lights = { - directionalLight0, - directionalLight1, - directionalLight2, - pointLight0, - pointLight1, - pointLight2, + Light::Directional(XMFLOAT3(1, 0.5f, 0.5f), XMFLOAT3(1, 1, 1), 0.5f), + Light::Directional(XMFLOAT3(-0.25f, -1, 0.75f), XMFLOAT3(1, 1, 1), 0.5f), + Light::Directional(XMFLOAT3(-1, 1, -0.5f), XMFLOAT3(1, 1, 1), 0.5f), + Light::Point(XMFLOAT3(-1.5f, 0, 0), XMFLOAT3(1, 1, 1), 0.5f, 10), + Light::Point(XMFLOAT3(1.5f, 0, 0), XMFLOAT3(1, 1, 1), 0.25f, 10), + Light::Point(XMFLOAT3(0, 2, 0), XMFLOAT3(1, 0, 0), 0.25f, 10), }; } diff --git a/Lights.h b/Lights.h index 546f6f6..8762f66 100644 --- a/Lights.h +++ b/Lights.h @@ -2,9 +2,9 @@ #include -#define LIGHT_TYPE_DIRECTIONAL 0 -#define LIGHT_TYPE_POINT 1 -#define LIGHT_TYPE_SPOT 2 +constexpr auto LIGHT_TYPE_DIRECTIONAL = 0; +constexpr auto LIGHT_TYPE_POINT = 1; +constexpr auto LIGHT_TYPE_SPOT = 2; struct Light { @@ -16,4 +16,25 @@ struct Light DirectX::XMFLOAT3 Color; float SpotFalloff; DirectX::XMFLOAT3 Padding; + + static Light Directional(DirectX::XMFLOAT3 _direction, DirectX::XMFLOAT3 _color, float _intensity) + { + Light light = {}; + light.Type = LIGHT_TYPE_DIRECTIONAL; + light.Direction = _direction; + light.Color = _color; + light.Intensity = _intensity; + return light; + }; + + static Light Point(DirectX::XMFLOAT3 _position, DirectX::XMFLOAT3 _color, float _intensity, float _range) + { + Light light = {}; + light.Type = LIGHT_TYPE_POINT; + light.Position = _position; + light.Color = _color; + light.Intensity = _intensity; + light.Range = _range; + return light; + }; };