Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Light.inl
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_LIGHT_COMPONENT_INL_
34#define DVD_LIGHT_COMPONENT_INL_
35
36namespace Divide
37{
38 inline void Light::getDiffuseColour( FColour3& colourOut ) const noexcept { Util::ToFloatColour( _colour.rgb, colourOut ); }
39
40 inline FColour3 Light::getDiffuseColour() const noexcept { return Util::ToFloatColour( _colour.rgb ); }
41
42 inline void Light::setDiffuseColour( const FColour3& newDiffuseColour ) noexcept { setDiffuseColour( Util::ToByteColour( newDiffuseColour ) ); }
43
44 inline void Light::toggleEnabled() noexcept { enabled( !enabled() ); }
45
46 inline const LightType& Light::getLightType() const noexcept { return _type; }
47
48 inline F32 Light::distanceSquared( const vec3<F32>& pos ) const noexcept { return positionCache().distanceSquared( pos ); }
49
50 inline const Light::ShadowProperties& Light::getShadowProperties() const noexcept { return _shadowProperties; }
51
52 inline const mat4<F32>& Light::getShadowVPMatrix( const U8 index ) const noexcept { assert( index < 6 ); return _shadowProperties._lightVP[index]; }
53
54 inline F32 Light::getShadowFloatValues( const U8 index ) const noexcept { assert( index < 6 ); return _shadowProperties._lightPosition[index].w; }
55
56 inline const vec4<F32>& Light::getShadowLightPos( const U8 index ) const noexcept { assert( index < 6 ); return _shadowProperties._lightPosition[index]; }
57
58 inline void Light::setShadowVPMatrix( const U8 index, const mat4<F32>& newValue ) noexcept { assert( index < 6 ); _shadowProperties._lightVP[index].set( newValue ); _shadowProperties._dirty = true; }
59
60 inline void Light::setShadowFloatValue( const U8 index, const F32 newValue ) noexcept { assert( index < 6 ); _shadowProperties._lightPosition[index].w = newValue; _shadowProperties._dirty = true; }
61
62 inline void Light::setShadowLightPos( const U8 index, const vec3<F32>& newValue ) noexcept { _shadowProperties._lightPosition[index].xyz = newValue; _shadowProperties._dirty = true; }
63
64 inline void Light::setShadowArrayOffset( const U16 offset ) noexcept {
65 if ( getShadowArrayOffset() != offset )
66 {
67 _shadowProperties._lightDetails.y = offset == U16_MAX ? -1.f : to_F32( offset );
68 _shadowProperties._dirty = true;
69 }
70 }
71
72 inline void Light::cleanShadowProperties() noexcept
73 {
75 staticShadowsDirty( false );
76 dynamicShadowsDirty( false );
77 }
78
79 inline U16 Light::getShadowArrayOffset() const noexcept
80 {
82 {
83 return U16_MAX;
84 }
85
87 }
88
89} //namespace Divide
90
91#endif //DVD_LIGHT_COMPONENT_INL_
ShadowProperties _shadowProperties
Definition: Light.h:141
F32 distanceSquared(const vec3< F32 > &pos) const noexcept
Get the distance squared from this light to the specified position.
Definition: Light.inl:48
void setDiffuseColour(const UColour3 &newDiffuseColour) noexcept
Definition: Light.cpp:212
const ShadowProperties & getShadowProperties() const noexcept
Definition: Light.inl:50
const LightType & getLightType() const noexcept
Get the light type. (see LightType enum)
Definition: Light.inl:46
const vec4< F32 > & getShadowLightPos(const U8 index) const noexcept
Definition: Light.inl:56
void toggleEnabled() noexcept
Light state (on/off)
Definition: Light.inl:44
void setShadowFloatValue(const U8 index, const F32 newValue) noexcept
Definition: Light.inl:60
LightType _type
Definition: Light.h:143
void cleanShadowProperties() noexcept
Definition: Light.inl:72
void setShadowLightPos(const U8 index, const vec3< F32 > &newValue) noexcept
Definition: Light.inl:62
F32 getShadowFloatValues(const U8 index) const noexcept
Definition: Light.inl:54
void setShadowVPMatrix(const U8 index, const mat4< F32 > &newValue) noexcept
Definition: Light.inl:58
FColour3 getDiffuseColour() const noexcept
Definition: Light.inl:40
UColour4 _colour
Definition: Light.h:142
const mat4< F32 > & getShadowVPMatrix(const U8 index) const noexcept
Definition: Light.inl:52
void setShadowArrayOffset(const U16 offset) noexcept
Definition: Light.inl:64
U16 getShadowArrayOffset() const noexcept
Definition: Light.inl:79
vec3< T > rgb
Definition: MathVectors.h:1378
UColour4 ToByteColour(const FColour4 &floatColour) noexcept
Definition: MathHelper.cpp:256
FColour4 ToFloatColour(const UColour4 &byteColour) noexcept
Definition: MathHelper.cpp:268
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr U16 to_U16(const T value)
uint8_t U8
constexpr F32 to_F32(const T value)
constexpr U16 U16_MAX
uint16_t U16
LightType
The different types of lights supported.