-
Notifications
You must be signed in to change notification settings - Fork 1
/
Transform.h
120 lines (106 loc) · 2.62 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef editor_hook_Transform_h
#define editor_hook_Transform_h
#include "AssetLibrary.h"
#include "Hook.h"
#include "comp/Transform.h"
#include "gfx/Framebuffer.h"
#include "gfx/Texture.h"
#include "math/Geometry.h"
namespace Editor {
namespace Hook {
template<>
void Edit(Comp::Transform* transform);
template<>
struct Gizmo<Comp::Transform>: public GizmoBase
{
public:
Gizmo();
bool Run(Comp::Transform* transform, const World::Object& object);
private:
enum class Mode
{
Translate,
Scale,
Rotate
};
enum class Operation
{
None,
X,
Y,
Z,
Xy,
Xz,
Yz,
Xyz
};
enum class ReferenceFrame
{
World,
Parent,
Relative,
};
void DisplayOptionsWindow();
void TryStartOperation(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId,
const Math::Ray& mouseRay);
bool Translate(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId,
const Math::Ray& mouseRay);
bool Scale(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId,
const Math::Ray& mouseRay);
bool Rotate(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId,
const Math::Ray& mouseRay);
void SwitchMode(Mode newMode);
Operation GetHandleOperation(World::MemberId handleId) const;
void PrepareGizmoRepresentation(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId,
Math::Ray* gizmoRay,
Math::Plane* gizmoPlane,
Vec3* planeAxis = nullptr) const;
Quat ReferenceFrameRotation(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId) const;
Vec3 ScaleToInterval(Vec3 vector, float interval);
void RenderHandle(World::MemberId handleId, const Vec4& color);
void RenderHandles(
Comp::Transform* transform,
const World::Space& space,
World::MemberId ownerId);
World::Space mSpace;
World::MemberId mParent, mX, mY, mZ, mXy, mXz, mYz, mXyz;
Gfx::Framebuffer mDrawbuffer;
Mode mMode;
ReferenceFrame mReferenceFrame;
bool mSnapping;
float mTranslateSnapInterval;
float mScaleSnapInterval;
int mRotationSnapDenominator;
Operation mOperation;
Vec3 mStartScale;
Quat mStartRotation;
Quat mStartWorldRotation;
Vec3 mTranslateOffset;
static bool smRequiredAssetsLoaded;
static AssetLibrary::AssetId smArrowId;
static AssetLibrary::AssetId smCubeId;
static AssetLibrary::AssetId smScaleId;
static AssetLibrary::AssetId smSphereId;
static AssetLibrary::AssetId smTorusId;
};
} // namespace Hook
} // namespace Editor
#endif