Transformable.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef CPP3DS_TRANSFORMABLE_HPP
26 #define CPP3DS_TRANSFORMABLE_HPP
27 
29 // Headers
31 #include <cpp3ds/Graphics/Transform.hpp>
32 
33 
34 namespace cpp3ds
35 {
41 {
42 public :
43 
48  Transformable();
49 
54  virtual ~Transformable();
55 
69  void setPosition(float x, float y);
70 
83  void setPosition(const Vector2f& position);
84 
97  void setRotation(float angle);
98 
112  void setScale(float factorX, float factorY);
113 
126  void setScale(const Vector2f& factors);
127 
144  void setOrigin(float x, float y);
145 
161  void setOrigin(const Vector2f& origin);
162 
171  const Vector2f& getPosition() const;
172 
183  float getRotation() const;
184 
193  const Vector2f& getScale() const;
194 
203  const Vector2f& getOrigin() const;
204 
222  void move(float offsetX, float offsetY);
223 
239  void move(const Vector2f& offset);
240 
254  void rotate(float angle);
255 
273  void scale(float factorX, float factorY);
274 
291  void scale(const Vector2f& factor);
292 
301  const Transform& getTransform() const;
302 
311  const Transform& getInverseTransform() const;
312 
313 private :
314 
316  // Member data
318  Vector2f m_origin;
319  Vector2f m_position;
320  float m_rotation;
321  Vector2f m_scale;
322  mutable Transform m_transform;
323  mutable bool m_transformNeedUpdate;
324  mutable Transform m_inverseTransform;
325  mutable bool m_inverseTransformNeedUpdate;
326 };
327 
328 } // namespace cpp3ds
329 
330 
331 #endif // CPP3DS_TRANSFORMABLE_HPP
332 
333 
Decomposed transform defined by a position, a rotation and a scale.
virtual ~Transformable()
Virtual destructor.
void rotate(float angle)
Rotate the object.
const Transform & getTransform() const
get the combined transform of the object
const Transform & getInverseTransform() const
get the inverse of the combined transform of the object
void move(float offsetX, float offsetY)
Move the object by a given offset.
void setOrigin(float x, float y)
set the local origin of the object
const Vector2f & getPosition() const
get the position of the object
void setScale(float factorX, float factorY)
set the scale factors of the object
Transformable()
Default constructor.
void setPosition(float x, float y)
set the position of the object
void scale(float factorX, float factorY)
Scale the object.
float getRotation() const
get the orientation of the object
void setRotation(float angle)
set the orientation of the object
const Vector2f & getOrigin() const
get the local origin of the object
Define a 3x3 transform matrix.
Definition: Transform.hpp:41
const Vector2f & getScale() const
get the current scale of the object