From b1a0552bf4dba462cd371ba369a40f4dcbf95a32 Mon Sep 17 00:00:00 2001 From: skyjake Date: Fri, 15 Nov 2013 19:53:53 +0200 Subject: [PATCH] Renderer: Added an interface for point light sources --- doomsday/client/client.pro | 1 + doomsday/client/include/render/ilightsource.h | 82 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 doomsday/client/include/render/ilightsource.h diff --git a/doomsday/client/client.pro b/doomsday/client/client.pro index ab76871ab2..3f87cb8e47 100644 --- a/doomsday/client/client.pro +++ b/doomsday/client/client.pro @@ -301,6 +301,7 @@ DENG_HEADERS += \ include/render/fx/postprocessing.h \ include/render/fx/vignette.h \ include/render/huecirclevisual.h \ + include/render/ilightsource.h \ include/render/lightdecoration.h \ include/render/lightgrid.h \ include/render/lumobj.h \ diff --git a/doomsday/client/include/render/ilightsource.h b/doomsday/client/include/render/ilightsource.h new file mode 100644 index 0000000000..51b40ece61 --- /dev/null +++ b/doomsday/client/include/render/ilightsource.h @@ -0,0 +1,82 @@ +/** @file ilightsource.h Interface for a light source. + * + * @authors Copyright (c) 2013 Jaakko Keränen + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#ifndef DENG_CLIENT_ILIGHTSOURCE_H +#define DENG_CLIENT_ILIGHTSOURCE_H + +#include +#include + +/** + * Interface for a light source. + * + * All sources of light should implement this interface. Through it, various + * parts of the rendering subsystem can know where and what kind of light this + * is. + * + * @ingroup render + */ +class ILightSource +{ +public: + typedef de::Vector3d Origin; + + /** + * Unique identifier of the source. This can be used to uniquely identify a + * source of light across multiple frames. + */ + typedef de::duint32 LightId; + + /** + * RGB color of the emitted light. + */ + typedef de::Vector3f Color; + +public: + virtual ~ILightSource() {} + + virtual LightId lightSourceId() const = 0; + + /** + * Returns the position of the light source, in map units. + */ + virtual Origin lightSourceOrigin() const = 0; + + /** + * Returns the radius of the emitter itself, in map units. A radius of + * zero would mean that the light emitter is an infinitely small point. + */ + virtual de::dfloat lightSourceRadius() const = 0; + + /** + * Returns the color of the emitted light. The intensity of the light must + * not be factored into the color values, but is instead returned separately + * by lightSourceIntensity(). + */ + virtual Color lightSourceColor() const = 0; + + /** + * Returns the intensity of the light. + * + * @param viewPoint World point from where the light is being observed. + * Intensity may vary based on direction. + */ + virtual de::dfloat lightSourceIntensity(de::Vector3d const &viewPoint) const = 0; +}; + +#endif // DENG_CLIENT_ILIGHTSOURCE_H