Graphics/Sprite: Allows to set sprite corner color

Former-commit-id: b9b49224a89e38b233b590d78fd58e702741190f [formerly a575b0a6a20f1e395c0d3722d0c718cf29ee3d10] [formerly 39ad76edf53946c635a2acdaf97e5112c4ecbce2 [formerly 3353bce80b26d16e82f580d7a7c86399f3cac387]]
Former-commit-id: aa828d49caa667f82916c37f36cc44493c2b4b35 [formerly a0f30d565da18350446bc028f54dbcbe9d26bfb9]
Former-commit-id: 56145df1ee427d56fd7a951278b99484e56400a8
This commit is contained in:
Lynix
2016-09-07 13:04:58 +02:00
parent 347a069728
commit 6f4542393b
3 changed files with 60 additions and 11 deletions

View File

@@ -18,6 +18,9 @@ namespace Nz
m_size(64.f, 64.f),
m_origin(Nz::Vector3f::Zero())
{
for (Color& color : m_cornerColor)
color = Color::White;
SetDefaultMaterial();
}
@@ -62,14 +65,35 @@ namespace Nz
/*!
* \brief Gets the color of the sprite
*
* This is the global color of the sprite, independent from corner colors
*
* \return Current color
*
* \see GetCornerColor
* \see SetColor
*/
inline const Color& Sprite::GetColor() const
{
return m_color;
}
/*!
* \brief Gets the color setup on a corner of the sprite
*
* \return Current color
*
* \param corner Corner of the sprite to query
*
* \see SetCornerColor
*/
inline const Color& Sprite::GetCornerColor(RectCorner corner) const
{
NazaraAssert(corner < m_cornerColor.size(), "Invalid corner");
return m_cornerColor[corner];
}
/*!
* \brief Gets the material of the sprite
* \return Current material
@@ -86,7 +110,7 @@ namespace Nz
*
* \see SetOrigin
*/
inline const Vector3f & Sprite::GetOrigin() const
inline const Vector3f& Sprite::GetOrigin() const
{
return m_origin;
}
@@ -105,18 +129,21 @@ namespace Nz
* \brief Gets the texture coordinates of the sprite
* \return Current texture coordinates
*/
inline const Rectf& Sprite::GetTextureCoords() const
{
return m_textureCoords;
}
/*!
* \brief Sets the color of the billboard
* \brief Sets the global color of the sprite
*
* \param color Color for the billboard
* This is independent from the corner color of the sprite
*
* \param color Color for the sprite
*
* \see GetColor
* \see SetCornerColor
*/
inline void Sprite::SetColor(const Color& color)
{
m_color = color;
@@ -124,6 +151,26 @@ namespace Nz
InvalidateVertices();
}
/*!
* \brief Sets a color for a corner of the sprite
*
* This is independent from the sprite global color, which gets multiplied by the corner color when rendering the sprite.
*
* \param corner Corner of the sprite to set
* \param color Color for the sprite
*
* \see GetCornerColor
* \see SetColor
*/
inline void Sprite::SetCornerColor(RectCorner corner, const Color& color)
{
NazaraAssert(corner < m_cornerColor.size(), "Invalid corner");
m_cornerColor[corner] = color;
InvalidateVertices();
}
/*!
* \brief Sets the default material of the sprite (just default material)
*/