| 1 | // tLight.h  |
| 2 | //  |
| 3 | // This file implements scene lights. It supports point, spot, directional, and ambient lights.  |
| 4 | //  |
| 5 | // Copyright (c) 2006, 2017 Tristan Grimmer.  |
| 6 | // Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby  |
| 7 | // granted, provided that the above copyright notice and this permission notice appear in all copies.  |
| 8 | //  |
| 9 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL  |
| 10 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,  |
| 11 | // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN  |
| 12 | // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR  |
| 13 | // PERFORMANCE OF THIS SOFTWARE.  |
| 14 |   |
| 15 | #pragma once  |
| 16 | #include "Scene/tObject.h"  |
| 17 | namespace tScene  |
| 18 | {  |
| 19 |   |
| 20 |   |
| 21 | class tLight : public tObject  |
| 22 | {  |
| 23 | public:  |
| 24 | tLight() { }  |
| 25 | tLight(const tChunk& chunk) { Load(chunk); }  |
| 26 | virtual ~tLight() { }  |
| 27 |   |
| 28 | void Save(tChunkWriter&) const;  |
| 29 | void Load(const tChunk&);  |
| 30 | void Clear();  |
| 31 | void Scale(float scale) /* Scaling affects the near and far attenuation. */ { AttenNearStart *= scale; AttenNearEnd *= scale; AttenFarStart *= scale; AttenFarEnd *= scale; }  |
| 32 |   |
| 33 | enum class tType  |
| 34 | {  |
| 35 | Point,  |
| 36 | Spot,  |
| 37 | Directional,  |
| 38 | Ambient  |
| 39 | };  |
| 40 |   |
| 41 | // State like the position and direction can be found in the transformation matrix of the light instance.  |
| 42 | tType Type = tType::Point;  |
| 43 | float AttenNearStart = 0.0f;  |
| 44 | float AttenNearEnd = 0.0f;  |
| 45 | float AttenFarStart = 0.0f;  |
| 46 | float AttenFarEnd = 0.0f;  |
| 47 | };  |
| 48 |   |
| 49 |   |
| 50 | }  |
| 51 | |