Documentation for module: Graphics

Former-commit-id: 1757c33318443aade1dc38e16d053240d7dc885c
This commit is contained in:
Gawaboumga
2016-05-30 14:21:36 +02:00
parent 7721fd2284
commit 2c941827ed
94 changed files with 4858 additions and 504 deletions

View File

@@ -7,6 +7,10 @@
namespace Nz
{
/*!
* \brief Constructs a Light object by default
*/
inline Light::Light(const Light& light) :
Renderable(light),
m_color(light.m_color),
@@ -28,6 +32,12 @@ namespace Nz
{
}
/*!
* \brief Enables shadow casting
*
* \param castShadows Should shadows be cast
*/
inline void Light::EnableShadowCasting(bool castShadows)
{
if (m_shadowCastingEnabled != castShadows)
@@ -37,72 +47,141 @@ namespace Nz
}
}
/*!
* \brief Ensures that the shadow map is up to date
*/
inline void Light::EnsureShadowMapUpdate() const
{
if (!m_shadowMapUpdated)
UpdateShadowMap();
}
/*!
* \brief Gets the ambient factor
* \return Current ambient factor
*/
inline float Light::GetAmbientFactor() const
{
return m_ambientFactor;
}
/*!
* \brief Gets the light attenuation (in 1 / R^2)
* \return Attenuation
*/
inline float Light::GetAttenuation() const
{
return m_attenuation;
}
/*!
* \brief Gets the color of the light
* \return Light color
*/
inline Color Light::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the diffuse factor
* \return Current diffuse factor
*/
inline float Light::GetDiffuseFactor() const
{
return m_diffuseFactor;
}
/*!
* \brief Gets the inner angle in spot light
* \return Inner angle
*/
inline float Light::GetInnerAngle() const
{
return m_innerAngle;
}
/*!
* \brief Gets the cosine inner angle in spot light
* \return Cosine inner angle
*/
inline float Light::GetInnerAngleCosine() const
{
return m_innerAngleCosine;
}
/*!
* \brief Gets the inverse of the radius
* \return Inverse of the radius
*/
inline float Light::GetInvRadius() const
{
return m_invRadius;
}
/*!
* \brief Gets the type of the light
* \return Light type
*/
inline LightType Light::GetLightType() const
{
return m_type;
}
/*!
* \brief Gets the outer angle in spot light
* \return Outer angle
*/
inline float Light::GetOuterAngle() const
{
return m_outerAngle;
}
/*!
* \brief Gets the cosine outer angle in spot light
* \return Cosine outer angle
*/
inline float Light::GetOuterAngleCosine() const
{
return m_outerAngleCosine;
}
/*!
* \brief Gets the tangent outer angle in spot light
* \return Tangent outer angle
*/
inline float Light::GetOuterAngleTangent() const
{
return m_outerAngleTangent;
}
/*!
* \brief Gets the radius of the light
* \return Light radius
*/
inline float Light::GetRadius() const
{
return m_radius;
}
/*!
* \brief Gets the shadow map
* \return Reference to the shadow map texture
*/
inline TextureRef Light::GetShadowMap() const
{
EnsureShadowMapUpdate();
@@ -110,47 +189,97 @@ namespace Nz
return m_shadowMap;
}
/*!
* \brief Gets the format of the shadow map
* \return Shadow map format
*/
inline PixelFormatType Light::GetShadowMapFormat() const
{
return m_shadowMapFormat;
}
/*!
* \brief Gets the size of the shadow map
* \return Shadow map size
*/
inline const Vector2ui& Light::GetShadowMapSize() const
{
return m_shadowMapSize;
}
/*!
* \brief Checks whether the shadow casting is enabled
* \return true If it is the case
*/
inline bool Light::IsShadowCastingEnabled() const
{
return m_shadowCastingEnabled;
}
/*!
* \brief Sets the ambient factor
*
* \param factor Ambient factor
*/
inline void Light::SetAmbientFactor(float factor)
{
m_ambientFactor = factor;
}
/*!
* \brief Sets the light attenuation (in 1 / R^2)
*
* \param attenuation Light attenuation
*/
inline void Light::SetAttenuation(float attenuation)
{
m_attenuation = attenuation;
}
/*!
* \brief Sets the color of the light
*
* \param color Light color
*/
inline void Light::SetColor(const Color& color)
{
m_color = color;
}
/*!
* \brief Sets the diffuse factor
*
* \param factor Diffuse factor
*/
inline void Light::SetDiffuseFactor(float factor)
{
m_diffuseFactor = factor;
}
/*!
* \brief Sets the inner angle in spot light
* \return innerAngle Inner angle
*/
inline void Light::SetInnerAngle(float innerAngle)
{
m_innerAngle = innerAngle;
m_innerAngleCosine = std::cos(DegreeToRadian(m_innerAngle));
}
/*!
* \brief Sets the type of light
*
* \param type Light type
*/
inline void Light::SetLightType(LightType type)
{
m_type = type;
@@ -158,6 +287,13 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the outer angle in spot light
* \return outerAngle Outer angle
*
* \remark Invalidates the bounding volume
*/
inline void Light::SetOuterAngle(float outerAngle)
{
m_outerAngle = outerAngle;
@@ -167,6 +303,13 @@ namespace Nz
InvalidateBoundingVolume();
}
/*!
* \brief Sets the radius of the light
* \return radius Light radius
*
* \remark Invalidates the bounding volume
*/
inline void Light::SetRadius(float radius)
{
m_radius = radius;
@@ -176,6 +319,15 @@ namespace Nz
InvalidateBoundingVolume();
}
/*!
* \brief Sets the shadow map format
*
* \param shadowFormat Shadow map format
*
* \remark Invalidates the shadow map
* \remark Produces a NazaraAssert if format is not a depth type
*/
inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat)
{
NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format");
@@ -185,6 +337,15 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the size of the shadow map
*
* \param size Shadow map size
*
* \remark Invalidates the shadow map
* \remark Produces a NazaraAssert if size is zero
*/
inline void Light::SetShadowMapSize(const Vector2ui& size)
{
NazaraAssert(size.x > 0 && size.y > 0, "Shadow map size must have a positive size");
@@ -194,6 +355,15 @@ namespace Nz
InvalidateShadowMap();
}
/*!
* \brief Sets the current light with the content of the other one
* \return A reference to this
*
* \param light The other Light
*
* \remark Invalidates the shadow map
*/
inline Light& Light::operator=(const Light& light)
{
Renderable::operator=(light);
@@ -218,6 +388,10 @@ namespace Nz
return *this;
}
/*!
* \brief Invalidates the shadow map
*/
inline void Light::InvalidateShadowMap()
{
m_shadowMapUpdated = false;