DDraceNetwork Docs
camera.h
Go to the documentation of this file.
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
12
13class CCamera : public CComponent
14{
15 friend class CMenuBackground;
16
17public:
18 enum
19 {
23 };
24
25private:
29
32
41
42 float CameraSmoothingProgress(float CurrentTime) const;
43
47
48 void ScaleZoom(float Factor);
49 void ChangeZoom(float Target, int Smoothness, bool IsUser);
50 float ZoomProgress(float CurrentTime) const;
51
52 float MinZoomLevel();
53 float MaxZoomLevel();
54
59
60public:
61 static constexpr float ZOOM_STEP = 0.866025f;
62
69 static inline float ZoomStepsToValue(float Steps) { return std::pow(CCamera::ZOOM_STEP, Steps); }
70
74 float m_Zoom;
76
80
83
84 CCamera();
85 virtual int Sizeof() const override { return sizeof(*this); }
86 virtual void OnRender() override;
87
88 // DDRace
89
90 virtual void OnConsoleInit() override;
91 virtual void OnReset() override;
92
93 void SetView(ivec2 Pos, bool Relative = false);
94 void GotoSwitch(int Number, int Offset = -1);
95 void GotoTele(int Number, int Offset = -1);
96
97 void SetZoom(float Target, int Smoothness, bool IsUser);
98 bool ZoomAllowed() const;
99
100 int Deadzone() const;
101 int FollowFactor() const;
102 int CamType() const { return m_CamType; }
103
104 void UpdateCamera();
105 void ResetAutoSpecCamera();
106 bool SpectatingPlayer() const { return m_IsSpectatingPlayer; }
107 bool CanUseAutoSpecCamera() const;
108
109private:
110 static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData);
111 static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData);
112 static void ConZoom(IConsole::IResult *pResult, void *pUserData);
113 static void ConSetView(IConsole::IResult *pResult, void *pUserData);
114 static void ConSetViewRelative(IConsole::IResult *pResult, void *pUserData);
115 static void ConGotoSwitch(IConsole::IResult *pResult, void *pUserData);
116 static void ConGotoTele(IConsole::IResult *pResult, void *pUserData);
117
125};
126
127#endif
Definition: camera.h:14
float m_DyncamSmoothingSpeedBias
Definition: camera.h:56
float CameraSmoothingProgress(float CurrentTime) const
Definition: camera.cpp:49
float m_ZoomSmoothingEnd
Definition: camera.h:46
int m_GotoTeleOffset
Definition: camera.h:121
float MaxZoomLevel()
Definition: camera.cpp:71
int m_CamType
Definition: camera.h:26
CCubicBezier m_CameraSmoothingBezierY
Definition: camera.h:37
int CamType() const
Definition: camera.h:102
int m_PrevSpecId
Definition: camera.h:30
bool m_AutoSpecCameraZooming
Definition: camera.h:77
vec2 m_CenterBeforeSmoothing
Definition: camera.h:40
CCamera()
Definition: camera.cpp:18
vec2 m_CameraSmoothingTarget
Definition: camera.h:35
bool m_Zooming
Definition: camera.h:73
float m_Zoom
Definition: camera.h:74
static void ConGotoSwitch(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:479
static float ZoomStepsToValue(float Steps)
Definition: camera.h:69
static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:430
bool m_IsSpectatingPlayer
Definition: camera.h:57
int m_GotoTeleLastNumber
Definition: camera.h:124
int Deadzone() const
Definition: camera.cpp:614
bool m_UsingAutoSpecCamera
Definition: camera.h:58
CCubicBezier m_CameraSmoothingBezierX
Definition: camera.h:36
@ CAMTYPE_UNDEFINED
Definition: camera.h:20
@ CAMTYPE_PLAYER
Definition: camera.h:22
@ CAMTYPE_SPEC
Definition: camera.h:21
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:417
bool ZoomAllowed() const
Definition: camera.cpp:607
float ZoomProgress(float CurrentTime) const
Definition: camera.cpp:55
vec2 m_aLastPos[NUM_DUMMIES]
Definition: camera.h:27
virtual void OnRender() override
Definition: camera.cpp:281
virtual void OnConsoleInit() override
Definition: camera.cpp:396
vec2 m_DyncamTargetCameraOffset
Definition: camera.h:81
static void ConGotoTele(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:484
vec2 m_LastTargetPos
Definition: camera.h:55
float m_CameraSmoothingEnd
Definition: camera.h:39
ivec2 m_GotoTeleLastPos
Definition: camera.h:123
void SetView(ivec2 Pos, bool Relative=false)
Definition: camera.cpp:490
static void ConSetViewRelative(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:473
void GotoTele(int Number, int Offset=-1)
Definition: camera.cpp:546
bool SpectatingPlayer() const
Definition: camera.h:106
vec2 m_CameraSmoothingCenter
Definition: camera.h:34
void SetZoom(float Target, int Smoothness, bool IsUser)
Definition: camera.cpp:602
bool m_WasSpectating
Definition: camera.h:31
bool m_ZoomSet
Definition: camera.h:72
void UpdateCamera()
Definition: camera.cpp:114
vec2 m_PrevCenter
Definition: camera.h:28
vec2 m_Center
Definition: camera.h:71
static void ConSetView(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:467
bool m_ForceFreeview
Definition: camera.h:118
bool CanUseAutoSpecCamera() const
Definition: camera.cpp:624
ivec2 m_GotoSwitchLastPos
Definition: camera.h:122
virtual void OnReset() override
Definition: camera.cpp:407
float m_CameraSmoothingStart
Definition: camera.h:38
vec2 m_ForceFreeviewPos
Definition: camera.h:119
CCubicBezier m_ZoomSmoothing
Definition: camera.h:44
void ResetAutoSpecCamera()
Definition: camera.cpp:109
void GotoSwitch(int Number, int Offset=-1)
Definition: camera.cpp:502
int m_GotoSwitchOffset
Definition: camera.h:120
static constexpr float ZOOM_STEP
Definition: camera.h:61
void ScaleZoom(float Factor)
Definition: camera.cpp:60
static void ConZoom(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:444
virtual int Sizeof() const override
Definition: camera.h:85
float m_ZoomSmoothingTarget
Definition: camera.h:75
float m_ZoomSmoothingStart
Definition: camera.h:45
float m_UserZoomTarget
Definition: camera.h:79
int FollowFactor() const
Definition: camera.cpp:619
vec2 m_aDyncamCurrentCameraOffset[NUM_DUMMIES]
Definition: camera.h:82
void ChangeZoom(float Target, int Smoothness, bool IsUser)
Definition: camera.cpp:81
bool m_AutoSpecCamera
Definition: camera.h:78
bool m_CameraSmoothing
Definition: camera.h:33
float MinZoomLevel()
Definition: camera.cpp:76
Definition: component.h:20
Definition: bezier.h:10
Definition: menu_background.h:33
Definition: console.h:47
@ NUM_DUMMIES
Definition: enums.h:8