-
Notifications
You must be signed in to change notification settings - Fork 13
/
Transform.h
65 lines (53 loc) · 1.64 KB
/
Transform.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <DirectXMath.h>
class Transform
{
public:
Transform();
// Transformers
void MoveAbsolute(float x, float y, float z);
void MoveAbsolute(DirectX::XMFLOAT3 offset);
void MoveRelative(float x, float y, float z);
void MoveRelative(DirectX::XMFLOAT3 offset);
void Rotate(float p, float y, float r);
void Rotate(DirectX::XMFLOAT3 pitchYawRoll);
void Scale(float uniformScale);
void Scale(float x, float y, float z);
void Scale(DirectX::XMFLOAT3 scale);
// Setters
void SetPosition(float x, float y, float z);
void SetPosition(DirectX::XMFLOAT3 position);
void SetRotation(float p, float y, float r);
void SetRotation(DirectX::XMFLOAT3 pitchYawRoll);
void SetScale(float uniformScale);
void SetScale(float x, float y, float z);
void SetScale(DirectX::XMFLOAT3 scale);
// Getters
DirectX::XMFLOAT3 GetPosition();
DirectX::XMFLOAT3 GetPitchYawRoll();
DirectX::XMFLOAT3 GetScale();
// Local direction vector getters
DirectX::XMFLOAT3 GetUp();
DirectX::XMFLOAT3 GetRight();
DirectX::XMFLOAT3 GetForward();
// Matrix getters
DirectX::XMFLOAT4X4 GetWorldMatrix();
DirectX::XMFLOAT4X4 GetWorldInverseTransposeMatrix();
private:
// Raw transformation data
DirectX::XMFLOAT3 position;
DirectX::XMFLOAT3 pitchYawRoll;
DirectX::XMFLOAT3 scale;
// Local orientation vectors
bool vectorsDirty;
DirectX::XMFLOAT3 up;
DirectX::XMFLOAT3 right;
DirectX::XMFLOAT3 forward;
// World matrix and inverse transpose of the world matrix
bool matricesDirty;
DirectX::XMFLOAT4X4 worldMatrix;
DirectX::XMFLOAT4X4 worldInverseTransposeMatrix;
// Helper to update both matrices if necessary
void UpdateMatrices();
void UpdateVectors();
};