Former-commit-id: a6c2075cfbfd0eccf2b77def71c0d42684bed590 [formerly 36ece2bc6a148bde6cacf45084821d20edcd115e] [formerly 4a6988792ec026e65be6850c46dfe8ddda92a885 [formerly fd3f4f975de5c427f3adc98b220446fd255be396]] Former-commit-id: c87fdc9483202842267c60eff3d619f0df2963bf [formerly ee35202f1b2df7ca20da5b6d8b13147f2b92c933] Former-commit-id: dad5de1b00bb4413f7aa191ca06b7d43b659f32a
168 lines
4.2 KiB
C++
168 lines
4.2 KiB
C++
// Copyright (C) 2015 Jérôme Leclercq
|
|
// This file is part of the "Nazara Development Kit"
|
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
|
|
|
namespace Ndk
|
|
{
|
|
/*!
|
|
* \brief Constructs a RenderSystem object by copy semantic
|
|
*
|
|
* \param renderSystem RenderSystem to copy
|
|
*/
|
|
|
|
inline RenderSystem::RenderSystem(const RenderSystem& renderSystem) :
|
|
System(renderSystem)
|
|
{
|
|
}
|
|
|
|
/*!
|
|
* \brief Changes the render technique used for the system
|
|
* \return A reference to the render technique type
|
|
*/
|
|
|
|
template<typename T>
|
|
inline T& RenderSystem::ChangeRenderTechnique()
|
|
{
|
|
static_assert(std::is_base_of<Nz::AbstractRenderTechnique, T>::value, "RenderTechnique is not a subtype of AbstractRenderTechnique");
|
|
return static_cast<T&>(ChangeRenderTechnique(std::make_unique<T>()));
|
|
}
|
|
|
|
/*!
|
|
* \brief Changes the render technique used for the system
|
|
* \return A reference to the abstract render technique
|
|
*
|
|
* \param renderTechnique Render technique to use
|
|
*/
|
|
|
|
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
|
|
{
|
|
m_renderTechnique = std::move(renderTechnique);
|
|
return *m_renderTechnique.get();
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the background used for rendering
|
|
* \return A reference to the background
|
|
*/
|
|
|
|
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const
|
|
{
|
|
return m_background;
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the coordinates matrix used for rendering
|
|
* \return A constant reference to the matrix of coordinates
|
|
*/
|
|
|
|
inline const Nz::Matrix4f& RenderSystem::GetCoordinateSystemMatrix() const
|
|
{
|
|
return m_coordinateSystemMatrix;
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the "forward" global direction
|
|
* \return The forward direction, by default, it's -UnitZ() (Right hand coordinates)
|
|
*/
|
|
|
|
inline Nz::Vector3f RenderSystem::GetGlobalForward() const
|
|
{
|
|
return Nz::Vector3f(-m_coordinateSystemMatrix.m13, -m_coordinateSystemMatrix.m23, -m_coordinateSystemMatrix.m33);
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the "right" global direction
|
|
* \return The right direction, by default, it's UnitX() (Right hand coordinates)
|
|
*/
|
|
|
|
inline Nz::Vector3f RenderSystem::GetGlobalRight() const
|
|
{
|
|
return Nz::Vector3f(m_coordinateSystemMatrix.m11, m_coordinateSystemMatrix.m21, m_coordinateSystemMatrix.m31);
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the "up" global direction
|
|
* \return The up direction, by default, it's UnitY() (Right hand coordinates)
|
|
*/
|
|
|
|
inline Nz::Vector3f RenderSystem::GetGlobalUp() const
|
|
{
|
|
return Nz::Vector3f(m_coordinateSystemMatrix.m12, m_coordinateSystemMatrix.m22, m_coordinateSystemMatrix.m32);
|
|
}
|
|
|
|
/*!
|
|
* \brief Gets the render technique used for rendering
|
|
* \return A reference to the abstract render technique being used
|
|
*/
|
|
|
|
inline Nz::AbstractRenderTechnique& RenderSystem::GetRenderTechnique() const
|
|
{
|
|
return *m_renderTechnique.get();
|
|
}
|
|
|
|
/*!
|
|
* \brief Sets the background used for rendering
|
|
*
|
|
* \param background A reference to the background
|
|
*/
|
|
|
|
inline void RenderSystem::SetDefaultBackground(Nz::BackgroundRef background)
|
|
{
|
|
m_background = std::move(background);
|
|
}
|
|
|
|
/*!
|
|
* \brief Sets the "forward" global direction
|
|
*
|
|
* \param direction The new forward direction
|
|
*/
|
|
|
|
inline void RenderSystem::SetGlobalForward(const Nz::Vector3f& direction)
|
|
{
|
|
m_coordinateSystemMatrix.m13 = -direction.x;
|
|
m_coordinateSystemMatrix.m23 = -direction.y;
|
|
m_coordinateSystemMatrix.m33 = -direction.z;
|
|
|
|
InvalidateCoordinateSystem();
|
|
}
|
|
|
|
/*!
|
|
* \brief Sets the "right" global direction
|
|
*
|
|
* \param direction The new right direction
|
|
*/
|
|
|
|
inline void RenderSystem::SetGlobalRight(const Nz::Vector3f& direction)
|
|
{
|
|
m_coordinateSystemMatrix.m11 = direction.x;
|
|
m_coordinateSystemMatrix.m21 = direction.y;
|
|
m_coordinateSystemMatrix.m31 = direction.z;
|
|
|
|
InvalidateCoordinateSystem();
|
|
}
|
|
|
|
/*!
|
|
* \brief Sets the "up" global direction
|
|
*
|
|
* \param direction The new up direction
|
|
*/
|
|
|
|
inline void RenderSystem::SetGlobalUp(const Nz::Vector3f& direction)
|
|
{
|
|
m_coordinateSystemMatrix.m12 = direction.x;
|
|
m_coordinateSystemMatrix.m22 = direction.y;
|
|
m_coordinateSystemMatrix.m32 = direction.z;
|
|
|
|
InvalidateCoordinateSystem();
|
|
}
|
|
|
|
/*!
|
|
* \brief Invalidates the matrix of coordinates for the system
|
|
*/
|
|
|
|
inline void RenderSystem::InvalidateCoordinateSystem()
|
|
{
|
|
m_coordinateSystemInvalidated = true;
|
|
}
|
|
}
|