Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CinemaPath.h
Go to the documentation of this file.
1/* Copyright (C) 2017 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_CINEMAPATH
19#define INCLUDED_CINEMAPATH
20
21#include "maths/NUSpline.h"
22#include "ps/CStr.h"
23
24class CVector3D;
25class CCamera;
26
28{
29public:
31 virtual ~CCinemaData() {}
32
33 const CCinemaData* GetData() const { return this; }
34
35 CStrW m_Name;
37 CStrW m_Mode;
38 CStrW m_Style;
39
41
42 fixed m_Timescale; // a negative timescale results in backwards play
43
44 // Distortion variables
45 mutable float m_GrowthCount;
46 float m_Growth;
47 float m_Switch;
48};
49
50
51// Once the data is part of the path, it shouldn't be changeable, so use private inheritance.
52// This class encompasses the spline and the information which determines how the path will operate
53// and also provides the functionality for doing so
54
55class CCinemaPath : private CCinemaData, public TNSpline
56{
57public:
59 CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
60
61 // Sets camera position to calculated point on spline
62 void MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const;
63
64 // Distortion mode functions-change how ratio is passed to distortion style functions
65 float EaseIn(float t) const;
66 float EaseOut(float t) const;
67 float EaseInOut(float t) const;
68 float EaseOutIn(float t) const;
69
70 // Distortion style functions
71 float EaseDefault(float t) const;
72 float EaseGrowth(float t) const;
73 float EaseExpo(float t) const;
74 float EaseCircle(float t) const;
75 float EaseSine(float t) const;
76
77 float (CCinemaPath::*DistStylePtr)(float ratio) const;
78 float (CCinemaPath::*DistModePtr)(float ratio) const;
79
80 const CCinemaData* GetData() const;
81
82public:
83
84 CVector3D GetNodePosition(const int index) const;
85 fixed GetNodeDuration(const int index) const;
86 fixed GetDuration() const;
87
88 float GetNodeFraction() const;
89 float GetElapsedTime() const;
90
91 const CStrW& GetName() const;
92
93 void SetTimescale(fixed scale);
94
96 float m_PreviousNodeTime; // How much time has passed before the current node
97
100
101public:
102
103 /**
104 * Returns false if finished.
105 * @param deltaRealTime Elapsed real time since the last frame.
106 * @param camera An affected camera
107 */
108 bool Play(const float deltaRealTime, CCamera* camera);
109
110 /**
111 * Validate the path
112 * @return true if the path is valid
113 */
114 bool Validate();
115
116 /**
117 * Returns true if path doesn't contain nodes
118 */
119 bool Empty() const;
120
121 /**
122 * Resets the path state
123 */
124 void Reset();
125
126 fixed GetTimescale() const;
127
128 const TNSpline& GetTargetSpline() const;
129
130private:
131
133};
134
135#endif // INCLUDED_CINEMAPATH
Definition: Camera.h:42
Definition: CinemaPath.h:28
fixed m_Timescale
Definition: CinemaPath.h:42
CStrW m_Mode
Definition: CinemaPath.h:37
float m_Switch
Definition: CinemaPath.h:47
CStrW m_Orientation
Definition: CinemaPath.h:36
CStrW m_Style
Definition: CinemaPath.h:38
float m_GrowthCount
Definition: CinemaPath.h:45
CStrW m_Name
Definition: CinemaPath.h:35
bool m_LookAtTarget
Definition: CinemaPath.h:40
CCinemaData()
Definition: CinemaPath.h:30
const CCinemaData * GetData() const
Definition: CinemaPath.h:33
float m_Growth
Definition: CinemaPath.h:46
virtual ~CCinemaData()
Definition: CinemaPath.h:31
Definition: CinemaPath.h:56
float GetNodeFraction() const
Definition: CinemaPath.cpp:92
float EaseGrowth(float t) const
Definition: CinemaPath.cpp:171
CCinemaPath()
Definition: CinemaPath.h:58
bool Play(const float deltaRealTime, CCamera *camera)
Returns false if finished.
Definition: CinemaPath.cpp:235
void SetTimescale(fixed scale)
Definition: CinemaPath.cpp:107
float EaseOut(float t) const
Definition: CinemaPath.cpp:146
TNSpline m_TargetSpline
Definition: CinemaPath.h:132
const CCinemaData * GetData() const
Definition: CinemaPath.cpp:205
const CStrW & GetName() const
Definition: CinemaPath.cpp:102
size_t m_CurrentNode
Definition: CinemaPath.h:98
CVector3D GetNodePosition(const int index) const
Definition: CinemaPath.cpp:77
bool Validate()
Validate the path.
Definition: CinemaPath.cpp:210
float m_PreviousNodeTime
Definition: CinemaPath.h:96
fixed GetTimescale() const
Definition: CinemaPath.cpp:255
float EaseCircle(float t) const
Definition: CinemaPath.cpp:183
fixed GetDuration() const
Definition: CinemaPath.cpp:87
float m_TimeElapsed
Definition: CinemaPath.h:95
void Reset()
Resets the path state.
Definition: CinemaPath.cpp:250
float(CCinemaPath::* DistStylePtr)(float ratio) const
Definition: CinemaPath.h:77
bool Empty() const
Returns true if path doesn't contain nodes.
Definition: CinemaPath.cpp:245
float EaseDefault(float t) const
Definition: CinemaPath.cpp:166
fixed GetNodeDuration(const int index) const
Definition: CinemaPath.cpp:82
float EaseSine(float t) const
Definition: CinemaPath.cpp:194
CVector3D m_PreviousRotation
Definition: CinemaPath.h:99
float(CCinemaPath::* DistModePtr)(float ratio) const
Definition: CinemaPath.h:78
const TNSpline & GetTargetSpline() const
Definition: CinemaPath.cpp:260
float EaseInOut(float t) const
Definition: CinemaPath.cpp:151
float EaseExpo(float t) const
Definition: CinemaPath.cpp:176
float GetElapsedTime() const
Definition: CinemaPath.cpp:97
float EaseOutIn(float t) const
Definition: CinemaPath.cpp:158
float EaseIn(float t) const
Definition: CinemaPath.cpp:141
void MoveToPointAt(float t, float nodet, const CVector3D &startRotation, CCamera *camera) const
Definition: CinemaPath.cpp:112
A simple fixed-point number class.
Definition: Fixed.h:120
Definition: Vector3D.h:31
Timed Nonuniform Spline for paths with different time intervals between nodes.
Definition: NUSpline.h:94