Initial commit
This commit is contained in:
commit
edfc5298e1
252 changed files with 93965 additions and 0 deletions
94
source/Graphics/Transformable.cpp
Normal file
94
source/Graphics/Transformable.cpp
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
|
||||
#include <Spectre/Graphics/Transformable.h>
|
||||
|
||||
Transformable::Transformable() :
|
||||
m_position (0.0f, 0.0f),
|
||||
m_scale (1.0f, 1.0f),
|
||||
m_rotation (0.0f),
|
||||
m_transformNeedsUpdate (false)
|
||||
{
|
||||
}
|
||||
|
||||
Transformable::Transformable(const Vector2f& position) :
|
||||
m_position (position),
|
||||
m_scale (1.0f, 1.0f),
|
||||
m_rotation (0.0f),
|
||||
m_transformNeedsUpdate (false)
|
||||
{
|
||||
}
|
||||
|
||||
Transformable::~Transformable()
|
||||
{
|
||||
}
|
||||
|
||||
void Transformable::setPosition(const Vector2f& position)
|
||||
{
|
||||
m_position = position;
|
||||
m_transformNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Transformable::setPosition(float x, float y)
|
||||
{
|
||||
setPosition(Vector2f(x, y));
|
||||
}
|
||||
|
||||
void Transformable::move(const Vector2f& offset)
|
||||
{
|
||||
setPosition(m_position + offset);
|
||||
}
|
||||
const Vector2f& Transformable::getPosition() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
void Transformable::setRotation(float angle)
|
||||
{
|
||||
m_rotation = angle;
|
||||
m_transformNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Transformable::rotate(float angle)
|
||||
{
|
||||
setRotation(m_rotation + angle);
|
||||
}
|
||||
|
||||
float Transformable::getRotation() const
|
||||
{
|
||||
return m_rotation;
|
||||
}
|
||||
|
||||
void Transformable::setScale(const Vector2f& scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
m_transformNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void Transformable::setScale(float scale)
|
||||
{
|
||||
setScale(Vector2f(scale));
|
||||
}
|
||||
|
||||
void Transformable::scale(const Vector2f& offset)
|
||||
{
|
||||
m_scale += offset;
|
||||
}
|
||||
|
||||
void Transformable::scale(float offset)
|
||||
{
|
||||
scale(Vector2f(offset));
|
||||
}
|
||||
|
||||
const Vector2f Transformable::getScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
|
||||
const Transform& Transformable::getTransform() const
|
||||
{
|
||||
if (m_transformNeedsUpdate) {
|
||||
//m_transform.reset();
|
||||
m_transform.set(m_position, m_rotation, m_scale);
|
||||
m_transformNeedsUpdate = false;
|
||||
}
|
||||
return m_transform;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue