![]() |
COGS
Computer Graphics Structures library
|
Class used for effective management of transformation matrix by handling translation, rotation and scaling separately. More...
Public Member Functions | |
| Transform ()=default | |
| Creates an identity instance. | |
| Transform (const glm::mat4 &matrix) | |
| Creates an instance from a given matrix. | |
| Transform (const std::function< void(void)> ¬ifier_func) | |
| Creates an identity instance which notifies whenever its state changes. | |
| Transform (const Transform &)=default | |
| Transform & | operator= (const Transform &)=default |
| Transform (Transform &&) noexcept=default | |
| Transform & | operator= (Transform &&) noexcept=default |
| void | Translate (const glm::vec3 &move_vector) |
| Changes position by a given vector. | |
| void | SetPosition (const glm::vec3 &position) |
| Removes current position and replaces with specified position. | |
| const glm::vec3 | GetPosition () const |
| Returns position defined by transformation. | |
| void | Rotate (const glm::quat &rotation) |
| Applies additional rotation to transform, relative to current rotation. | |
| void | SetRotation (const glm::quat &rotation) |
| Removes current rotation and replaces with specified quaternion. | |
| const glm::quat | GetRotation () const |
| Returns rotation defined by transformation. | |
| void | Scale (const glm::vec3 &scale) |
| Applies scale to transform, accumulated with previous scaling. | |
| void | SetScaling (const glm::vec3 &scale) |
| Resets scaling of transform. | |
| const glm::vec3 | GetScaling () const |
| Returns scaling defined by transformation. | |
| void | Set (const glm::mat4 &trans_mat) |
| Resets current transform so that it represents specified matrix. | |
| virtual const glm::mat4 & | GetMat4 () const |
| Returns composed matrix of final transformation: scaling > rotation > translation. | |
| void | AddTransform (const Transform &transform) |
| Multiply this transform by a given one. | |
| void | InterpolateWith (const Transform &target, const float target_weight, Transform *out_transform) const |
| Interpolates current transform with another, in a specific mix ratio. More... | |
| virtual void | SaveToStream (std::ostream &ostr) const |
| Writes relevant information to stream. | |
| virtual void | LoadFromStream (std::istream &istr) |
| Reads relevant information from stream. | |
| Transform | operator* (const Transform &t) const |
| Multiply two transforms equivalently to matrix multiplication. | |
| operator glm::mat4 () const | |
Protected Member Functions | |
| virtual void | OnInvariantChange () |
| Function called each time a change on position, rotation or scaling is performed. | |
Class used for effective management of transformation matrix by handling translation, rotation and scaling separately.
Final transformation is computed in order: scaling > rotation > translation.
| void cogs::Transform::InterpolateWith | ( | const Transform & | target, |
| const float | target_weight, | ||
| Transform * | out_transform | ||
| ) | const |
Interpolates current transform with another, in a specific mix ratio.
Transformations are disassembled into translation, scale and rotation components. Translation and scale components are then interpolated linearly, rotation with SLERP function.
| target | The Transform which to interpolate to. |
| target_weight | Defines how much of target should be taken. Value 0 results in 100% of this transform, value 1 results in 100% of target. |
| out_transform | A pointer to an object where the computed transformation will be stored. |