From bab7aaa2af99614ad930da6e7ccbbb09b238341a Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Tue, 26 Apr 2016 14:09:13 +0200 Subject: [PATCH] added LightClasses --- Weave/Graphix/Lights.h | 6 +++++ Weave/Graphix/Lights/AmbientLight.cpp | 10 +++++++ Weave/Graphix/Lights/AmbientLight.h | 19 +++++++++++++ Weave/Graphix/Lights/DirectionalLight.cpp | 24 +++++++++++++++++ Weave/Graphix/Lights/DirectionalLight.h | 21 +++++++++++++++ Weave/Graphix/Lights/Light.cpp | 31 +++++++++++++++++++++ Weave/Graphix/Lights/Light.h | 33 +++++++++++++++++++++++ Weave/Graphix/{ => Lights}/PointLight.cpp | 22 ++++----------- Weave/Graphix/Lights/PointLight.h | 20 ++++++++++++++ Weave/Graphix/PointLight.h | 20 -------------- Weave/Weave.vcxproj | 11 ++++++-- Weave/Weave.vcxproj.filters | 33 ++++++++++++++++++----- 12 files changed, 205 insertions(+), 45 deletions(-) create mode 100644 Weave/Graphix/Lights.h create mode 100644 Weave/Graphix/Lights/AmbientLight.cpp create mode 100644 Weave/Graphix/Lights/AmbientLight.h create mode 100644 Weave/Graphix/Lights/DirectionalLight.cpp create mode 100644 Weave/Graphix/Lights/DirectionalLight.h create mode 100644 Weave/Graphix/Lights/Light.cpp create mode 100644 Weave/Graphix/Lights/Light.h rename Weave/Graphix/{ => Lights}/PointLight.cpp (70%) create mode 100644 Weave/Graphix/Lights/PointLight.h delete mode 100644 Weave/Graphix/PointLight.h diff --git a/Weave/Graphix/Lights.h b/Weave/Graphix/Lights.h new file mode 100644 index 0000000..e9e924d --- /dev/null +++ b/Weave/Graphix/Lights.h @@ -0,0 +1,6 @@ +#pragma once + +#include "Lights\PointLight.h" +#include "Lights\DirectionalLight.h" +#include "Lights\AmbientLight.h" + diff --git a/Weave/Graphix/Lights/AmbientLight.cpp b/Weave/Graphix/Lights/AmbientLight.cpp new file mode 100644 index 0000000..444e80b --- /dev/null +++ b/Weave/Graphix/Lights/AmbientLight.cpp @@ -0,0 +1,10 @@ +#include "AmbientLight.h" + +AmbientLight::AmbientLight(const vec3 & _color) : + Light(_color) +{ +} + +AmbientLight::~AmbientLight() +{ +} diff --git a/Weave/Graphix/Lights/AmbientLight.h b/Weave/Graphix/Lights/AmbientLight.h new file mode 100644 index 0000000..f8301cf --- /dev/null +++ b/Weave/Graphix/Lights/AmbientLight.h @@ -0,0 +1,19 @@ +#pragma once + +#include "../../GLM.h" +#include "Light.h" + +class AmbientLight + : public Light +{ +public: + AmbientLight(const vec3& _color); + + virtual ~AmbientLight(); + + /*Change Light*/ + + +protected: + +}; \ No newline at end of file diff --git a/Weave/Graphix/Lights/DirectionalLight.cpp b/Weave/Graphix/Lights/DirectionalLight.cpp new file mode 100644 index 0000000..026cf2c --- /dev/null +++ b/Weave/Graphix/Lights/DirectionalLight.cpp @@ -0,0 +1,24 @@ +#include "DirectionalLight.h" + +DirectionalLight::DirectionalLight(const vec3& _position, const vec3& _color, const vec3& _direction) : + Light(_color), + position(_position), + direction(_direction) +{ + +} + +DirectionalLight::~DirectionalLight() +{ + +} + +void DirectionalLight::changePosition(const vec3& _position) +{ + position = _position; +} + +void DirectionalLight::changeDirection(const vec3& _direction) +{ + direction = _direction; +} \ No newline at end of file diff --git a/Weave/Graphix/Lights/DirectionalLight.h b/Weave/Graphix/Lights/DirectionalLight.h new file mode 100644 index 0000000..6447fe6 --- /dev/null +++ b/Weave/Graphix/Lights/DirectionalLight.h @@ -0,0 +1,21 @@ +#pragma once + +#include "../../GLM.h" +#include "Light.h" + +class DirectionalLight + : public Light +{ +public: + DirectionalLight(const vec3& _color, const vec3& _position, const vec3& _direction); + + virtual ~DirectionalLight(); + + /*Change Light*/ + virtual void changePosition(const vec3& position); + virtual void changeDirection(const vec3& direction); + +protected: + vec3 position; + vec3 direction; +}; \ No newline at end of file diff --git a/Weave/Graphix/Lights/Light.cpp b/Weave/Graphix/Lights/Light.cpp new file mode 100644 index 0000000..d170e36 --- /dev/null +++ b/Weave/Graphix/Lights/Light.cpp @@ -0,0 +1,31 @@ +#include "Light.h" + +Light::Light(const vec3 & _color) : color(_color) +{ +} + +Light::~Light() +{ +} + +void Light::switchLight(swLight _switch) +{ + switch (_switch) + { + default: + case SWITCH: + active = !active; + break; + case ON: + active = true; + break; + case OFF: + active = false; + break; + } +} + +void Light::changeColor(const vec3 & _color) +{ + color = _color; +} diff --git a/Weave/Graphix/Lights/Light.h b/Weave/Graphix/Lights/Light.h new file mode 100644 index 0000000..3a64e92 --- /dev/null +++ b/Weave/Graphix/Lights/Light.h @@ -0,0 +1,33 @@ +#pragma once + +#include "../../GLM.h" + + +enum swLight { + ON, + OFF, + SWITCH +}; + +class Light +{ +public: + Light(const vec3& _color); + + virtual ~Light(); + + virtual void switchLight(swLight = SWITCH); + + //Calculate DepthBuffers & CO + virtual void usePreProcess(); + + //Load light Position and DephBuffers + virtual void useFinalDraw(); //ID? for LightArrayPosition + + /*Change Light*/ + virtual void changeColor(const vec3& color); + +protected: + vec3 color; + bool active = true; +}; \ No newline at end of file diff --git a/Weave/Graphix/PointLight.cpp b/Weave/Graphix/Lights/PointLight.cpp similarity index 70% rename from Weave/Graphix/PointLight.cpp rename to Weave/Graphix/Lights/PointLight.cpp index 634f6bb..a042be5 100644 --- a/Weave/Graphix/PointLight.cpp +++ b/Weave/Graphix/Lights/PointLight.cpp @@ -1,5 +1,5 @@ #include "PointLight.h" -#include "Graphix.h" +#include "../Graphix.h" @@ -25,10 +25,9 @@ CameraDirection gCameraDirections[6] = -PointLight::PointLight(vec3& _position, vec3& _color) : - position(_position), - color(_color), - active(true) +PointLight::PointLight(const vec3& _position,const vec3& _color) : + Light(_color), + position(_position) { } @@ -38,18 +37,7 @@ PointLight::~PointLight() } -void PointLight::changeLight(vec3& _position, vec3& _color) +void PointLight::changePosition(const vec3& _position) { position = _position; - color = _color; } - -void PointLight::turnOn() -{ - active = true; -} - -void PointLight::turnOff() -{ - active = false; -} \ No newline at end of file diff --git a/Weave/Graphix/Lights/PointLight.h b/Weave/Graphix/Lights/PointLight.h new file mode 100644 index 0000000..8da6029 --- /dev/null +++ b/Weave/Graphix/Lights/PointLight.h @@ -0,0 +1,20 @@ +#pragma once + +#include "../../GLM.h" +#include "Light.h" + +class PointLight + : public Light +{ +public: + PointLight(const vec3& _position, const vec3& _color); + + virtual ~PointLight(); + + + /*Change Light*/ + virtual void changePosition(const vec3& position); + +protected: + vec3 position; +}; \ No newline at end of file diff --git a/Weave/Graphix/PointLight.h b/Weave/Graphix/PointLight.h deleted file mode 100644 index 17355a0..0000000 --- a/Weave/Graphix/PointLight.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "../GLM.h" - -class PointLight -{ -public: - PointLight(vec3& _position, vec3& _color); - - virtual ~PointLight(); - - void changeLight(vec3& _position, vec3& _color); - void turnOn(); - void turnOff(); - -protected: - vec3 position; - vec3 color; - bool active; -}; \ No newline at end of file diff --git a/Weave/Weave.vcxproj b/Weave/Weave.vcxproj index 82b6bd4..deb901f 100644 --- a/Weave/Weave.vcxproj +++ b/Weave/Weave.vcxproj @@ -97,6 +97,9 @@ + + + @@ -105,7 +108,7 @@ - + @@ -125,6 +128,10 @@ + + + + @@ -141,7 +148,7 @@ - + diff --git a/Weave/Weave.vcxproj.filters b/Weave/Weave.vcxproj.filters index e079ff4..cb0dc41 100644 --- a/Weave/Weave.vcxproj.filters +++ b/Weave/Weave.vcxproj.filters @@ -63,9 +63,6 @@ Source Files - - Source Files - Source Files @@ -105,6 +102,18 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + @@ -164,9 +173,6 @@ Header Files - - Header Files - Header Files @@ -212,5 +218,20 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file -- 2.47.3