Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_TRANSFORM_H_
34#define DVD_TRANSFORM_H_
35
36#include "TransformInterface.h"
37
38namespace Divide {
39
40//Not thread safe!
41class Transform final : public TransformValues, public ITransform, public GUIDWrapper, NonCopyable {
42 public:
43
44 Transform() noexcept = default;
45 explicit Transform(const Quaternion<F32>& orientation,
46 const vec3<F32>& translation,
47 const vec3<F32>& scale) noexcept;
48
49 void setPosition(const vec3<F32>& position) noexcept override;
50 void setPosition(F32 x, F32 y, F32 z) noexcept override;
51 void setPositionX(F32 positionX) noexcept override;
52 void setPositionY(F32 positionY) noexcept override;
53 void setPositionZ(F32 positionZ) noexcept override;
54 void translate(const vec3<F32>& axisFactors) noexcept override;
55
56 void setScale(const vec3<F32>& amount) noexcept override;
57 void setScaleX(F32 amount) noexcept override;
58 void setScaleY(F32 amount) noexcept override;
59 void setScaleZ(F32 amount) noexcept override;
60 void scale(const vec3<F32>& axisFactors) noexcept override;
61 void scaleX(F32 amount) noexcept override;
62 void scaleY(F32 amount) noexcept override;
63 void scaleZ(F32 amount) noexcept override;
64
65 void setRotation(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) noexcept override;
66 void setRotation(Angle::DEGREES<F32> pitch, Angle::DEGREES<F32> yaw, Angle::DEGREES<F32> roll) noexcept override;
67 void setRotation(const Quaternion<F32>& quat) noexcept override;
68 void setRotationX(Angle::DEGREES<F32> angle) noexcept override;
69 void setRotationY(Angle::DEGREES<F32> angle) noexcept override;
70 void setRotationZ(Angle::DEGREES<F32> angle) noexcept override;
71 void rotate(const vec3<F32>& axis, Angle::DEGREES<F32> degrees) noexcept override;
72 void rotate(Angle::DEGREES<F32> pitch, Angle::DEGREES<F32> yaw, Angle::DEGREES<F32> roll) noexcept override;
73 void rotate(const Quaternion<F32>& quat) noexcept override;
74 void rotateSlerp(const Quaternion<F32>& quat, D64 deltaTime) override;
75 void rotateX(Angle::DEGREES<F32> angle) noexcept override;
76 void rotateY(Angle::DEGREES<F32> angle) noexcept override;
77 void rotateZ(Angle::DEGREES<F32> angle) noexcept override;
78
79 void getScale(vec3<F32>& scaleOut) const noexcept override;
80 void getPosition(vec3<F32>& posOut) const noexcept override;
81 void getOrientation(Quaternion<F32>& quatOut) const noexcept override;
82
83 [[nodiscard]] bool isUniformScale(const F32 tolerance = EPSILON_F32) const noexcept;
84
87 void setTransforms(const mat4<F32>& transform);
88
90 void clone(const Transform* transform) noexcept;
91
93 void setValues(const TransformValues& values) noexcept;
94
96 bool operator==(const Transform& other) const;
97 bool operator!=(const Transform& other) const;
98
100 void identity() noexcept;
101};
102
103} // namespace Divide
104
105#endif //DVD_TRANSFORM_H_
106
107#include "Transform.inl"
Utility class that adds basic GUID management to objects.
Definition: GUIDWrapper.h:44
void rotate(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees) noexcept override
Definition: Transform.inl:98
void setScaleZ(F32 amount) noexcept override
Set the scaling factor on the Z axis.
Definition: Transform.inl:129
Transform() noexcept=default
void setPositionY(F32 positionY) noexcept override
Set the object's position on the Y axis.
Definition: Transform.inl:52
void clone(const Transform *transform) noexcept
Set all of the internal values to match those of the specified transform.
Definition: Transform.inl:195
void scaleZ(F32 amount) noexcept override
Increase the scaling factor on the Z axis by the specified factor.
Definition: Transform.inl:142
void setScaleX(F32 amount) noexcept override
Set the scaling factor on the X axis.
Definition: Transform.inl:121
void setScale(const vec3< F32 > &amount) noexcept override
Set the local X,Y and Z amount factors.
Definition: Transform.inl:62
void rotateX(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:147
void setRotationX(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:162
void getOrientation(Quaternion< F32 > &quatOut) const noexcept override
Return the orientation quaternion.
Definition: Transform.inl:187
void identity() noexcept
Reset transform to identity.
Definition: Transform.cpp:21
void getScale(vec3< F32 > &scaleOut) const noexcept override
Return the scale factor.
Definition: Transform.inl:177
void setRotationY(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:167
void setTransforms(const mat4< F32 > &transform)
Definition: Transform.cpp:14
void rotateY(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:152
void getPosition(vec3< F32 > &posOut) const noexcept override
Return the position.
Definition: Transform.inl:182
void translate(const vec3< F32 > &axisFactors) noexcept override
Add the specified translation factors to the current local position.
Definition: Transform.inl:86
void setPositionX(F32 positionX) noexcept override
Set the object's position on the X axis.
Definition: Transform.inl:48
void setRotation(const vec3< F32 > &axis, Angle::DEGREES< F32 > degrees) noexcept override
Definition: Transform.inl:68
void setPositionZ(F32 positionZ) noexcept override
Set the object's position on the Z axis.
Definition: Transform.inl:57
void setScaleY(F32 amount) noexcept override
Set the scaling factor on the Y axis.
Definition: Transform.inl:125
void rotateSlerp(const Quaternion< F32 > &quat, D64 deltaTime) override
Perform a SLERP rotation towards the specified quaternion.
Definition: Transform.inl:115
bool isUniformScale(const F32 tolerance=EPSILON_F32) const noexcept
Definition: Transform.inl:191
void setRotationZ(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:172
void scale(const vec3< F32 > &axisFactors) noexcept override
Add the specified scale factors to the current local position.
Definition: Transform.inl:91
void scaleY(F32 amount) noexcept override
Increase the scaling factor on the Y axis by the specified factor.
Definition: Transform.inl:138
void setValues(const TransformValues &values) noexcept
Set position, scale and rotation based on the specified transform values.
Definition: Transform.inl:200
void rotateZ(Angle::DEGREES< F32 > angle) noexcept override
Definition: Transform.inl:157
void setPosition(const vec3< F32 > &position) noexcept override
Set the local X,Y and Z position.
Definition: Transform.inl:38
void scaleX(F32 amount) noexcept override
Increase the scaling factor on the X axis by the specified factor.
Definition: Transform.inl:134
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr F32 EPSILON_F32
double D64