1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
3 | #ifndef GAME_CLIENT_COMPONENTS_CAMERA_H |
4 | #define GAME_CLIENT_COMPONENTS_CAMERA_H |
5 | #include <base/bezier.h> |
6 | #include <base/vmath.h> |
7 | |
8 | #include <engine/client.h> |
9 | #include <engine/console.h> |
10 | |
11 | #include <game/client/component.h> |
12 | |
13 | class CCamera : public CComponent |
14 | { |
15 | friend class CMenuBackground; |
16 | |
17 | enum |
18 | { |
19 | CAMTYPE_UNDEFINED = -1, |
20 | CAMTYPE_SPEC, |
21 | CAMTYPE_PLAYER, |
22 | }; |
23 | |
24 | int m_CamType; |
25 | vec2 m_aLastPos[NUM_DUMMIES]; |
26 | vec2 m_PrevCenter; |
27 | |
28 | CCubicBezier m_ZoomSmoothing; |
29 | float m_ZoomSmoothingStart; |
30 | float m_ZoomSmoothingEnd; |
31 | |
32 | void ScaleZoom(float Factor); |
33 | void ChangeZoom(float Target, int Smoothness); |
34 | float ZoomProgress(float CurrentTime) const; |
35 | |
36 | float MinZoomLevel(); |
37 | float MaxZoomLevel(); |
38 | |
39 | public: |
40 | static constexpr float ZOOM_STEP = 0.866025f; |
41 | |
42 | vec2 m_Center; |
43 | bool m_ZoomSet; |
44 | bool m_Zooming; |
45 | float m_Zoom; |
46 | float m_ZoomSmoothingTarget; |
47 | |
48 | CCamera(); |
49 | virtual int Sizeof() const override { return sizeof(*this); } |
50 | virtual void OnRender() override; |
51 | |
52 | // DDRace |
53 | |
54 | virtual void OnConsoleInit() override; |
55 | virtual void OnReset() override; |
56 | |
57 | void SetZoom(float Target, int Smoothness); |
58 | void SetView(ivec2 Pos, bool Relative = false); |
59 | void GotoSwitch(int Number, int Offset = -1); |
60 | void GotoTele(int Number, int Offset = -1); |
61 | |
62 | private: |
63 | static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData); |
64 | static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData); |
65 | static void ConZoom(IConsole::IResult *pResult, void *pUserData); |
66 | static void ConSetView(IConsole::IResult *pResult, void *pUserData); |
67 | static void ConSetViewRelative(IConsole::IResult *pResult, void *pUserData); |
68 | static void ConGotoSwitch(IConsole::IResult *pResult, void *pUserData); |
69 | static void ConGotoTele(IConsole::IResult *pResult, void *pUserData); |
70 | |
71 | bool m_ForceFreeview; |
72 | vec2 m_ForceFreeviewPos; |
73 | int m_GotoSwitchOffset; |
74 | int m_GotoTeleOffset; |
75 | ivec2 m_GotoSwitchLastPos; |
76 | ivec2 m_GotoTeleLastPos; |
77 | int m_GotoTeleLastNumber = -1; |
78 | }; |
79 | |
80 | #endif |
81 | |