-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathArcBallCameraController.h
More file actions
67 lines (64 loc) · 2.06 KB
/
Copy pathArcBallCameraController.h
File metadata and controls
67 lines (64 loc) · 2.06 KB
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
#ifndef GAME_ENGINE_ARC_BALL_CAMERA_CONTROLLER_H
#define GAME_ENGINE_ARC_BALL_CAMERA_CONTROLLER_H
#include "Actor.h"
#include "InputDispatcher.h"
#include "CoreLib/LibUI/LibUI.h"
namespace GameEngine
{
class CameraActor;
enum class MouseState
{
None, Translate, Rotate
};
class ArcBallParams
{
public:
VectorMath::Vec3 center;
float radius = 800.0f;
float alpha = CoreLib::Math::Pi * 0.5f, beta = 0.0f;
ArcBallParams()
{
center.SetZero();
}
void GetCoordinates(VectorMath::Vec3 & camPos, VectorMath::Vec3 & up, VectorMath::Vec3 & right, VectorMath::Vec3 & dir);
};
class ArcBallCameraControllerActor : public Actor
{
private:
ArcBallParams lastArcBall;
ArcBallParams GetCurrentArcBall();
int lastX = 0, lastY = 0;
MouseState state = MouseState::None;
CameraActor * targetCamera = nullptr;
void FindTargetCamera();
void UpdateCamera();
void MouseMove(GraphicsUI::UI_Base * sender, GraphicsUI::UIMouseEventArgs & e);
void MouseDown(GraphicsUI::UI_Base * sender, GraphicsUI::UIMouseEventArgs & e);
void MouseUp(GraphicsUI::UI_Base * sender, GraphicsUI::UIMouseEventArgs & e);
void MouseWheel(GraphicsUI::UI_Base * sender, GraphicsUI::UIMouseEventArgs & e);
public:
PROPERTY_DEF(VectorMath::Vec3, Center, VectorMath::Vec3::Create(0.0f));
PROPERTY_DEF(float, Radius, 800.0f);
PROPERTY_DEF(float, Alpha, CoreLib::Math::Pi * 0.5f);
PROPERTY_DEF(float, Beta, 0.0f);
PROPERTY_DEF(float, TurnPrecision, CoreLib::Math::Pi / 1000.0f);
PROPERTY_DEF(float, TranslatePrecision, 0.001f);
PROPERTY_DEF(float, ZoomScale, 1.1f);
PROPERTY_DEF(float, MinDist, 10.0f);
PROPERTY_DEF(float, MaxDist, 10000.0f);
PROPERTY_DEF(bool, NeedAlt, true);
PROPERTY(CoreLib::String, TargetCameraName);
public:
virtual void OnLoad() override;
virtual void OnUnload() override;
virtual EngineActorType GetEngineType() override;
virtual CoreLib::String GetTypeName() override
{
return "ArcBallCameraController";
}
public:
void SetCenter(VectorMath::Vec3 center);
bool DumpCamera(const CoreLib::String & axisName, ActionInput scale);
};
}
#endif