ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Transform.cpp
Go to the documentation of this file.
1#include "Transform.h"
2#include "Mathematics.h" // Assuming this header contains necessary utility functions like DegreesToRadians
3
5 : baseRotation(1, 0, 0, 0), rotation(1, 0, 0, 0), position(0, 0, 0), scale(1, 1, 1), scaleRotationOffset(1, 0, 0, 0) {}
6
7Transform::Transform(const Vector3D& eulerXYZS, const Vector3D& position, const Vector3D& scale) {
9 this->position = position;
10 this->scale = scale;
11}
12
13Transform::Transform(const Quaternion& rotation, const Vector3D& position, const Vector3D& scale) {
14 this->rotation = rotation;
15 this->position = position;
16 this->scale = scale;
17}
18
19Transform::Transform(const Vector3D& eulerXYZS, const Vector3D& position, const Vector3D& scale, const Vector3D& rotationOffset, const Vector3D& scaleOffset) {
21 this->position = position;
22 this->scale = scale;
23 this->rotationOffset = rotationOffset;
24 this->scaleOffset = scaleOffset;
25}
26
27Transform::Transform(const Quaternion& rotation, const Vector3D& position, const Vector3D& scale, const Vector3D& rotationOffset, const Vector3D& scaleOffset) {
28 this->rotation = rotation;
29 this->position = position;
30 this->scale = scale;
31 this->rotationOffset = rotationOffset;
32 this->scaleOffset = scaleOffset;
33}
34
36 this->baseRotation = transform.baseRotation;
37 this->rotation = transform.rotation;
38 this->position = transform.position;
39 this->scale = transform.scale;
41 this->rotationOffset = transform.rotationOffset;
42 this->scaleOffset = transform.scaleOffset;
43}
44
45void Transform::SetBaseRotation(const Quaternion& baseRotation) {
46 this->baseRotation = baseRotation;
47}
48
52
53void Transform::SetRotation(const Quaternion& rotation) {
54 this->rotation = rotation;
55}
56
60
64
65void Transform::SetPosition(const Vector3D& position) {
66 this->position = position;
67}
68
72
73void Transform::SetScale(const Vector3D& scale) {
74 this->scale = scale;
75}
76
80
81void Transform::SetScaleRotationOffset(const Quaternion& scaleRotationOffset) {
82 this->scaleRotationOffset = scaleRotationOffset;
83}
84
88
89void Transform::SetRotationOffset(const Vector3D& rotationOffset) {
90 this->rotationOffset = rotationOffset;
91}
92
96
97void Transform::SetScaleOffset(const Vector3D& scaleOffset) {
98 this->scaleOffset = scaleOffset;
99}
100
104
108
109void Transform::Rotate(const Quaternion& rotation) {
110 this->rotation = this->rotation * rotation;
111}
112
113void Transform::Translate(const Vector3D& offset) {
114 this->position = this->position + offset;
115}
116
117void Transform::Scale(const Vector3D& scale) {
118 this->scale = this->scale * scale;
119}
120
Provides a collection of mathematical utility functions and constants.
Defines the Transform class for managing position, rotation, and scale of objects.
Encapsulates a 3D rotation using Euler angles and a specific order of application.
Definition EulerAngles.h:25
Vector3D Angles
The three rotation angles (pitch, yaw, roll) in degrees (or radians based on usage).
Definition EulerAngles.h:27
Implements a generic Kalman Filter for 1D data.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Handles 3D rotations and conversions between various rotation representations.
Definition Rotation.h:32
EulerAngles GetEulerAngles(const EulerOrder &order)
Gets the Euler angles representation of the rotation.
Definition Rotation.cpp:300
Quaternion GetQuaternion()
Gets the quaternion representation of the rotation.
Definition Rotation.cpp:234
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
String ToString()
Converts the transform to a string representation.
void Translate(const Vector3D &offset)
Translates the object by the given offset.
Vector3D GetRotationOffset()
Gets the rotation offset of the object.
Definition Transform.cpp:93
Vector3D scale
The scale of the object in 3D space.
Definition Transform.h:27
void SetScale(const Vector3D &scale)
Sets the scale of the object.
Definition Transform.cpp:73
Quaternion scaleRotationOffset
Offset for scaling transformations relative to rotation.
Definition Transform.h:28
void Scale(const Vector3D &scale)
Scales the object by the given scale factors.
Quaternion rotation
The current rotation of the object as a quaternion.
Definition Transform.h:25
Quaternion GetRotation()
Gets the current rotation of the object.
Definition Transform.cpp:61
Vector3D scaleOffset
Offset applied to the scale.
Definition Transform.h:30
void SetBaseRotation(const Quaternion &baseRotation)
Sets the base rotation of the object.
Definition Transform.cpp:45
Vector3D rotationOffset
Offset applied to the rotation.
Definition Transform.h:31
Quaternion GetBaseRotation()
Gets the base rotation of the object.
Definition Transform.cpp:49
Quaternion GetScaleRotationOffset()
Gets the scale rotation offset of the object.
Definition Transform.cpp:85
Vector3D position
The position of the object in 3D space.
Definition Transform.h:26
void SetScaleOffset(const Vector3D &scaleOffset)
Sets the scale offset of the object.
Definition Transform.cpp:97
Transform()
Default constructor.
Definition Transform.cpp:4
Vector3D GetPosition()
Gets the position of the object.
Definition Transform.cpp:69
void Rotate(const Vector3D &eulerXYZS)
Rotates the object by the given Euler angles.
void SetPosition(const Vector3D &position)
Sets the position of the object.
Definition Transform.cpp:65
void SetScaleRotationOffset(const Quaternion &scaleRotationOffset)
Sets the scale rotation offset of the object.
Definition Transform.cpp:81
void SetRotationOffset(const Vector3D &rotationOffset)
Sets the rotation offset of the object.
Definition Transform.cpp:89
Vector3D GetScaleOffset()
Gets the scale offset of the object.
Vector3D GetScale()
Gets the scale of the object.
Definition Transform.cpp:77
void SetRotation(const Quaternion &rotation)
Sets the current rotation of the object.
Definition Transform.cpp:53
Quaternion baseRotation
The base rotation of the object as a quaternion.
Definition Transform.h:24
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
String ToString() const
Converts the vector to a string representation.
Definition Vector3D.cpp:189
const EulerOrder EulerOrderXYZS
Order: X → Y → Z, static frame.