From f01eec9ffeedf66ebdaf662ec9e831c9c6cd845f Mon Sep 17 00:00:00 2001 From: Eduard Mandy Date: Tue, 26 Nov 2024 22:49:06 +0100 Subject: [PATCH] #5 29.2 Implementing Textures Add ConstantColor class. --- CMakeLists.txt | 2 ++ src/Textures/ConstantColor.cpp | 17 +++++++++++++++++ src/Textures/ConstantColor.h | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 src/Textures/ConstantColor.cpp create mode 100644 src/Textures/ConstantColor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bbf07f2..4a9fe03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,8 @@ set (SOURCE_SCENEBUILDERS set (SOURCE_TEXTURES src/Textures/Checker3D.cpp src/Textures/Checker3D.h + src/Textures/ConstantColor.cpp + src/Textures/ConstantColor.h src/Textures/Texture.cpp src/Textures/Texture.h ) diff --git a/src/Textures/ConstantColor.cpp b/src/Textures/ConstantColor.cpp new file mode 100644 index 0000000..546d085 --- /dev/null +++ b/src/Textures/ConstantColor.cpp @@ -0,0 +1,17 @@ +// Copyright (C) Kevin Suffern 2000-2007. +// This C++ code is for non-commercial purposes only. +// This C++ code is licensed under the GNU General Public License Version 2. +// See the file COPYING.txt for the full license. + +// Copyright notice for changes since the originally published version: +// Copyright (C) Eduárd Mándy 2019-2021 +// Though this C++ code was change in a large measure it still has the original copyright notice. +// This C++ code is for non-commercial purposes only. +// This C++ code is licensed under the GNU General Public License Version 2. +// See the file COPYING.txt for the full license. + +#include "ConstantColor.h" + +RGBColor ConstantColor::get_color(const ShadeRec& sr) const { + return color; +} diff --git a/src/Textures/ConstantColor.h b/src/Textures/ConstantColor.h new file mode 100644 index 0000000..f6f1709 --- /dev/null +++ b/src/Textures/ConstantColor.h @@ -0,0 +1,33 @@ +// Copyright (C) Kevin Suffern 2000-2007. +// This C++ code is for non-commercial purposes only. +// This C++ code is licensed under the GNU General Public License Version 2. +// See the file COPYING.txt for the full license. + +// Copyright notice for changes since the originally published version: +// Copyright (C) Eduárd Mándy 2019-2021 +// Though this C++ code was change in a large measure it still has the original copyright notice. +// This C++ code is for non-commercial purposes only. +// This C++ code is licensed under the GNU General Public License Version 2. +// See the file COPYING.txt for the full license. + +#ifndef __CONSTANTCOLOR__ +#define __CONSTANTCOLOR__ + +#include "Texture.h" +#include "../Utilities/RGBColor.h" + +class ConstantColor : public Texture { +public: + + void set_color(const RGBColor& c); + + RGBColor get_color(const ShadeRec& sr) const override; + +private: + + RGBColor color = RGBColor::white; +}; + +inline void ConstantColor::set_color(const RGBColor &c) { color = c; } + +#endif