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
17 enum
18 {
22 };
23
27
30
39
40 float CameraSmoothingProgress(float CurrentTime) const;
41
45
46 void ScaleZoom(float Factor);
47 void ChangeZoom(float Target, int Smoothness);
48 float ZoomProgress(float CurrentTime) const;
49
50 float MinZoomLevel();
51 float MaxZoomLevel();
52
53public:
54 static constexpr float ZOOM_STEP = 0.866025f;
55
59 float m_Zoom;
61
62 CCamera();
63 virtual int Sizeof() const override { return sizeof(*this); }
64 virtual void OnRender() override;
65
66 // DDRace
67
68 virtual void OnConsoleInit() override;
69 virtual void OnReset() override;
70
71 void SetView(ivec2 Pos, bool Relative = false);
72 void GotoSwitch(int Number, int Offset = -1);
73 void GotoTele(int Number, int Offset = -1);
74
75 void SetZoom(float Target, int Smoothness);
76 bool ZoomAllowed() const;
77
78private:
79 static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData);
80 static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData);
81 static void ConZoom(IConsole::IResult *pResult, void *pUserData);
82 static void ConSetView(IConsole::IResult *pResult, void *pUserData);
83 static void ConSetViewRelative(IConsole::IResult *pResult, void *pUserData);
84 static void ConGotoSwitch(IConsole::IResult *pResult, void *pUserData);
85 static void ConGotoTele(IConsole::IResult *pResult, void *pUserData);
86
94};
95
96#endif
Definition: camera.h:14
float CameraSmoothingProgress(float CurrentTime) const
Definition: camera.cpp:40
float m_ZoomSmoothingEnd
Definition: camera.h:44
int m_GotoTeleOffset
Definition: camera.h:90
float MaxZoomLevel()
Definition: camera.cpp:57
int m_CamType
Definition: camera.h:24
CCubicBezier m_CameraSmoothingBezierY
Definition: camera.h:35
int m_PrevSpecId
Definition: camera.h:28
vec2 m_CenterBeforeSmoothing
Definition: camera.h:38
CCamera()
Definition: camera.cpp:18
vec2 m_CameraSmoothingTarget
Definition: camera.h:33
bool m_Zooming
Definition: camera.h:58
float m_Zoom
Definition: camera.h:59
static void ConGotoSwitch(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:342
static void ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:307
int m_GotoTeleLastNumber
Definition: camera.h:93
CCubicBezier m_CameraSmoothingBezierX
Definition: camera.h:34
static void ConZoomPlus(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:296
bool ZoomAllowed() const
Definition: camera.cpp:470
float ZoomProgress(float CurrentTime) const
Definition: camera.cpp:46
vec2 m_aLastPos[NUM_DUMMIES]
Definition: camera.h:25
virtual void OnRender() override
Definition: camera.cpp:92
virtual void OnConsoleInit() override
Definition: camera.cpp:277
static void ConGotoTele(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:347
float m_CameraSmoothingEnd
Definition: camera.h:37
ivec2 m_GotoTeleLastPos
Definition: camera.h:92
void SetView(ivec2 Pos, bool Relative=false)
Definition: camera.cpp:353
static void ConSetViewRelative(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:336
void GotoTele(int Number, int Offset=-1)
Definition: camera.cpp:409
vec2 m_CameraSmoothingCenter
Definition: camera.h:32
bool m_WasSpectating
Definition: camera.h:29
bool m_ZoomSet
Definition: camera.h:57
vec2 m_PrevCenter
Definition: camera.h:26
vec2 m_Center
Definition: camera.h:56
static void ConSetView(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:330
bool m_ForceFreeview
Definition: camera.h:87
ivec2 m_GotoSwitchLastPos
Definition: camera.h:91
virtual void OnReset() override
Definition: camera.cpp:288
float m_CameraSmoothingStart
Definition: camera.h:36
vec2 m_ForceFreeviewPos
Definition: camera.h:88
void SetZoom(float Target, int Smoothness)
Definition: camera.cpp:465
CCubicBezier m_ZoomSmoothing
Definition: camera.h:42
void GotoSwitch(int Number, int Offset=-1)
Definition: camera.cpp:365
int m_GotoSwitchOffset
Definition: camera.h:89
void ChangeZoom(float Target, int Smoothness)
Definition: camera.cpp:67
static constexpr float ZOOM_STEP
Definition: camera.h:54
void ScaleZoom(float Factor)
Definition: camera.cpp:51
static void ConZoom(IConsole::IResult *pResult, void *pUserData)
Definition: camera.cpp:318
virtual int Sizeof() const override
Definition: camera.h:63
float m_ZoomSmoothingTarget
Definition: camera.h:60
float m_ZoomSmoothingStart
Definition: camera.h:43
bool m_CameraSmoothing
Definition: camera.h:31
@ CAMTYPE_UNDEFINED
Definition: camera.h:19
@ CAMTYPE_PLAYER
Definition: camera.h:21
@ CAMTYPE_SPEC
Definition: camera.h:20
float MinZoomLevel()
Definition: camera.cpp:62
Definition: component.h:20
Definition: bezier.h:10
Definition: menu_background.h:33
Definition: console.h:45
@ NUM_DUMMIES
Definition: enums.h:8