Index: ps/trunk/source/graphics/CinemaManager.h
===================================================================
--- ps/trunk/source/graphics/CinemaManager.h
+++ ps/trunk/source/graphics/CinemaManager.h
@@ -24,7 +24,7 @@
#include "lib/input.h" // InReaction - can't forward-declare enum
-#include "graphics/CinemaPath.h"
+#include "simulation2/helpers/CinemaPath.h"
#include "ps/CStr.h"
#include "ps/Shapes.h"
Index: ps/trunk/source/graphics/CinemaPath.h
===================================================================
--- ps/trunk/source/graphics/CinemaPath.h
+++ ps/trunk/source/graphics/CinemaPath.h
@@ -1,137 +0,0 @@
-/* Copyright (C) 2017 Wildfire Games.
- * This file is part of 0 A.D.
- *
- * 0 A.D. is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 0 A.D. is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with 0 A.D. If not, see .
- */
-
-#ifndef INCLUDED_CINEMAPATH
-#define INCLUDED_CINEMAPATH
-
-#include "maths/NUSpline.h"
-#include "ps/CStr.h"
-
-class CVector3D;
-class CVector4D;
-class CCamera;
-
-// For loading data
-class CCinemaData
-{
-public:
- CCinemaData() : m_LookAtTarget(false), m_GrowthCount(0), m_Growth(1), m_Switch(1), m_Timescale(fixed::FromInt(1)) {}
- virtual ~CCinemaData() {}
-
- const CCinemaData* GetData() const { return this; }
-
- CStrW m_Name;
- CStrW m_Orientation;
- CStrW m_Mode;
- CStrW m_Style;
-
- bool m_LookAtTarget;
-
- fixed m_Timescale; // a negative timescale results in backwards play
-
- // Distortion variables
- mutable float m_GrowthCount;
- float m_Growth;
- float m_Switch;
-};
-
-
-// Once the data is part of the path, it shouldn't be changeable, so use private inheritance.
-// This class encompasses the spline and the information which determines how the path will operate
-// and also provides the functionality for doing so
-
-class CCinemaPath : private CCinemaData, public TNSpline
-{
-public:
- CCinemaPath() : m_TimeElapsed(0), m_PreviousNodeTime(0) {}
- CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
-
- // Sets camera position to calculated point on spline
- void MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const;
-
- // Distortion mode functions-change how ratio is passed to distortion style functions
- float EaseIn(float t) const;
- float EaseOut(float t) const;
- float EaseInOut(float t) const;
- float EaseOutIn(float t) const;
-
- // Distortion style functions
- float EaseDefault(float t) const;
- float EaseGrowth(float t) const;
- float EaseExpo(float t) const;
- float EaseCircle(float t) const;
- float EaseSine(float t) const;
-
- float (CCinemaPath::*DistStylePtr)(float ratio) const;
- float (CCinemaPath::*DistModePtr)(float ratio) const;
-
- const CCinemaData* GetData() const;
-
-public:
-
- CVector3D GetNodePosition(const int index) const;
- fixed GetNodeDuration(const int index) const;
- fixed GetDuration() const;
-
- float GetNodeFraction() const;
- float GetElapsedTime() const;
-
- const CStrW& GetName() const;
-
- void SetTimescale(fixed scale);
-
- float m_TimeElapsed;
- float m_PreviousNodeTime; // How much time has passed before the current node
-
- size_t m_CurrentNode;
- CVector3D m_PreviousRotation;
-
-public:
-
- /**
- * Returns false if finished.
- * @param deltaRealTime Elapsed real time since the last frame.
- * @param camera An affected camera
- */
- bool Play(const float deltaRealTime, CCamera* camera);
-
- /**
- * Validate the path
- * @return true if the path is valid
- */
- bool Validate();
-
- /**
- * Returns true if path doesn't contain nodes
- */
- bool Empty() const;
-
- /**
- * Resets the path state
- */
- void Reset();
-
- fixed GetTimescale() const;
-
- const TNSpline& GetTargetSpline() const;
-
-private:
-
- TNSpline m_TargetSpline;
-};
-
-#endif // INCLUDED_CINEMAPATH
Index: ps/trunk/source/graphics/CinemaPath.cpp
===================================================================
--- ps/trunk/source/graphics/CinemaPath.cpp
+++ ps/trunk/source/graphics/CinemaPath.cpp
@@ -1,273 +0,0 @@
-/* Copyright (C) 2017 Wildfire Games.
- * This file is part of 0 A.D.
- *
- * 0 A.D. is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * 0 A.D. is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with 0 A.D. If not, see .
- */
-
-#include "precompiled.h"
-
-#include "CinemaPath.h"
-
-#include
-#include
-
-#include "Camera.h"
-#include "CinemaManager.h"
-#include "GameView.h"
-#include "gui/CGUI.h"
-#include "gui/GUIManager.h"
-#include "gui/IGUIObject.h"
-#include "lib/ogl.h"
-#include "maths/MathUtil.h"
-#include "maths/Quaternion.h"
-#include "maths/Vector3D.h"
-#include "maths/Vector4D.h"
-#include "ps/CLogger.h"
-#include "ps/CStr.h"
-#include "ps/Game.h"
-#include "renderer/Renderer.h"
-
-
-CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline)
- : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f)
-{
- // Calculate curves by nodes
- BuildSpline();
- m_TargetSpline.BuildSpline();
-
- if (m_Orientation == L"target")
- {
- m_LookAtTarget = true;
- ENSURE(!m_TargetSpline.GetAllNodes().empty());
- }
-
- // Set distortion mode and style
- if (data.m_Mode == L"ease_in")
- DistModePtr = &CCinemaPath::EaseIn;
- else if (data.m_Mode == L"ease_out")
- DistModePtr = &CCinemaPath::EaseOut;
- else if (data.m_Mode == L"ease_inout")
- DistModePtr = &CCinemaPath::EaseInOut;
- else if (data.m_Mode == L"ease_outin")
- DistModePtr = &CCinemaPath::EaseOutIn;
- else
- {
- LOGWARNING("Cinematic mode not found for '%s'", data.m_Mode.ToUTF8().c_str());
- DistModePtr = &CCinemaPath::EaseInOut;
- }
-
- if (data.m_Style == L"default")
- DistStylePtr = &CCinemaPath::EaseDefault;
- else if (data.m_Style == L"growth")
- DistStylePtr = &CCinemaPath::EaseGrowth;
- else if (data.m_Style == L"expo")
- DistStylePtr = &CCinemaPath::EaseExpo;
- else if (data.m_Style == L"circle")
- DistStylePtr = &CCinemaPath::EaseCircle;
- else if (data.m_Style == L"sine")
- DistStylePtr = &CCinemaPath::EaseSine;
- else
- {
- LOGWARNING("Cinematic style not found for '%s'", data.m_Style.ToUTF8().c_str());
- DistStylePtr = &CCinemaPath::EaseDefault;
- }
-}
-
-CVector3D CCinemaPath::GetNodePosition(const int index) const
-{
- return Node[index].Position;
-}
-
-fixed CCinemaPath::GetNodeDuration(const int index) const
-{
- return Node[index].Distance;
-}
-
-fixed CCinemaPath::GetDuration() const
-{
- return MaxDistance;
-}
-
-float CCinemaPath::GetNodeFraction() const
-{
- return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance.ToFloat();
-}
-
-float CCinemaPath::GetElapsedTime() const
-{
- return m_TimeElapsed;
-}
-
-const CStrW& CCinemaPath::GetName() const
-{
- return m_Name;
-}
-
-void CCinemaPath::SetTimescale(fixed scale)
-{
- m_Timescale = scale;
-}
-
-void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const
-{
- t = (this->*DistModePtr)(t);
-
- CVector3D pos = GetPosition(t);
-
- if (m_LookAtTarget)
- {
- if (m_TimeElapsed <= m_TargetSpline.MaxDistance.ToFloat())
- camera->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance.ToFloat()), CVector3D(0, 1, 0));
- else
- camera->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
- }
- else
- {
- CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
- CQuaternion start, end;
- start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
- end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
- start.Slerp(start, end, nodet);
-
- camera->m_Orientation.SetIdentity();
- camera->m_Orientation.Rotate(start);
- camera->m_Orientation.Translate(pos);
- }
- camera->UpdateFrustum();
-}
-
-// Distortion mode functions
-float CCinemaPath::EaseIn(float t) const
-{
- return (this->*DistStylePtr)(t);
-}
-
-float CCinemaPath::EaseOut(float t) const
-{
- return 1.0f - EaseIn(1.0f-t);
-}
-
-float CCinemaPath::EaseInOut(float t) const
-{
- if (t < m_Switch)
- return EaseIn(1.0f/m_Switch * t) * m_Switch;
- return EaseOut(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
-}
-
-float CCinemaPath::EaseOutIn(float t) const
-{
- if (t < m_Switch)
- return EaseOut(1.0f/m_Switch * t) * m_Switch;
- return EaseIn(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
-}
-
-// Distortion style functions
-float CCinemaPath::EaseDefault(float t) const
-{
- return t;
-}
-
-float CCinemaPath::EaseGrowth(float t) const
-{
- return pow(t, m_Growth);
-}
-
-float CCinemaPath::EaseExpo(float t) const
-{
- if (t == 0)
- return t;
- return powf(m_Growth, 10*(t-1.0f));
-}
-
-float CCinemaPath::EaseCircle(float t) const
-{
- t = -(sqrt(1.0f - t*t) - 1.0f);
- if (m_GrowthCount > 1.0f)
- {
- --m_GrowthCount;
- return (this->*DistStylePtr)(t);
- }
- return t;
-}
-
-float CCinemaPath::EaseSine(float t) const
-{
- t = 1.0f - cos(t * (float)M_PI/2);
- if (m_GrowthCount > 1.0f)
- {
- --m_GrowthCount;
- return (this->*DistStylePtr)(t);
- }
- return t;
-}
-
-const CCinemaData* CCinemaPath::GetData() const
-{
- return CCinemaData::GetData();
-}
-
-bool CCinemaPath::Validate()
-{
- if (m_TimeElapsed > GetDuration().ToFloat() || m_TimeElapsed < 0.0f)
- return false;
-
- // Find current node and past "node time"
- float previousTime = 0.0f, cumulation = 0.0f;
-
- // Ignore the last node, since it is a blank (node time values are shifted down one from interface)
- for (size_t i = 0; i < Node.size() - 1; ++i)
- {
- cumulation += Node[i].Distance.ToFloat();
- if (m_TimeElapsed <= cumulation)
- {
- m_PreviousNodeTime = previousTime;
- m_PreviousRotation = Node[i].Rotation;
- m_CurrentNode = i; // We're moving toward this next node, so use its rotation
- return true;
- }
- previousTime += Node[i].Distance.ToFloat();
- }
- debug_warn("validation of cinema path is wrong\n");
- return false;
-}
-
-bool CCinemaPath::Play(const float deltaRealTime, CCamera* camera)
-{
- m_TimeElapsed += m_Timescale.ToFloat() * deltaRealTime;
- if (!Validate())
- return false;
-
- MoveToPointAt(m_TimeElapsed / GetDuration().ToFloat(), GetNodeFraction(), m_PreviousRotation, camera);
- return true;
-}
-
-bool CCinemaPath::Empty() const
-{
- return Node.empty();
-}
-
-void CCinemaPath::Reset()
-{
- m_TimeElapsed = 0.0f;
-}
-
-fixed CCinemaPath::GetTimescale() const
-{
- return m_Timescale;
-}
-
-const TNSpline& CCinemaPath::GetTargetSpline() const
-{
- return m_TargetSpline;
-}
Index: ps/trunk/source/ps/GameSetup/GameSetup.cpp
===================================================================
--- ps/trunk/source/ps/GameSetup/GameSetup.cpp
+++ ps/trunk/source/ps/GameSetup/GameSetup.cpp
@@ -36,7 +36,6 @@
#endif
#include "graphics/CinemaManager.h"
-#include "graphics/CinemaPath.h"
#include "graphics/FontMetrics.h"
#include "graphics/GameView.h"
#include "graphics/LightEnv.h"
Index: ps/trunk/source/simulation2/components/ICmpCinemaManager.h
===================================================================
--- ps/trunk/source/simulation2/components/ICmpCinemaManager.h
+++ ps/trunk/source/simulation2/components/ICmpCinemaManager.h
@@ -18,7 +18,7 @@
#ifndef INCLUDED_ICMPCINEMAMANAGER
#define INCLUDED_ICMPCINEMAMANAGER
-#include "graphics/CinemaPath.h"
+#include "simulation2/helpers/CinemaPath.h"
#include "simulation2/system/Interface.h"
#include "ps/CStr.h"
Index: ps/trunk/source/simulation2/helpers/CinemaPath.h
===================================================================
--- ps/trunk/source/simulation2/helpers/CinemaPath.h
+++ ps/trunk/source/simulation2/helpers/CinemaPath.h
@@ -0,0 +1,135 @@
+/* Copyright (C) 2017 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#ifndef INCLUDED_CINEMAPATH
+#define INCLUDED_CINEMAPATH
+
+#include "maths/NUSpline.h"
+#include "ps/CStr.h"
+
+class CVector3D;
+class CCamera;
+
+class CCinemaData
+{
+public:
+ CCinemaData() : m_LookAtTarget(false), m_GrowthCount(0), m_Growth(1), m_Switch(1), m_Timescale(fixed::FromInt(1)) {}
+ virtual ~CCinemaData() {}
+
+ const CCinemaData* GetData() const { return this; }
+
+ CStrW m_Name;
+ CStrW m_Orientation;
+ CStrW m_Mode;
+ CStrW m_Style;
+
+ bool m_LookAtTarget;
+
+ fixed m_Timescale; // a negative timescale results in backwards play
+
+ // Distortion variables
+ mutable float m_GrowthCount;
+ float m_Growth;
+ float m_Switch;
+};
+
+
+// Once the data is part of the path, it shouldn't be changeable, so use private inheritance.
+// This class encompasses the spline and the information which determines how the path will operate
+// and also provides the functionality for doing so
+
+class CCinemaPath : private CCinemaData, public TNSpline
+{
+public:
+ CCinemaPath() : m_TimeElapsed(0), m_PreviousNodeTime(0) {}
+ CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
+
+ // Sets camera position to calculated point on spline
+ void MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const;
+
+ // Distortion mode functions-change how ratio is passed to distortion style functions
+ float EaseIn(float t) const;
+ float EaseOut(float t) const;
+ float EaseInOut(float t) const;
+ float EaseOutIn(float t) const;
+
+ // Distortion style functions
+ float EaseDefault(float t) const;
+ float EaseGrowth(float t) const;
+ float EaseExpo(float t) const;
+ float EaseCircle(float t) const;
+ float EaseSine(float t) const;
+
+ float (CCinemaPath::*DistStylePtr)(float ratio) const;
+ float (CCinemaPath::*DistModePtr)(float ratio) const;
+
+ const CCinemaData* GetData() const;
+
+public:
+
+ CVector3D GetNodePosition(const int index) const;
+ fixed GetNodeDuration(const int index) const;
+ fixed GetDuration() const;
+
+ float GetNodeFraction() const;
+ float GetElapsedTime() const;
+
+ const CStrW& GetName() const;
+
+ void SetTimescale(fixed scale);
+
+ float m_TimeElapsed;
+ float m_PreviousNodeTime; // How much time has passed before the current node
+
+ size_t m_CurrentNode;
+ CVector3D m_PreviousRotation;
+
+public:
+
+ /**
+ * Returns false if finished.
+ * @param deltaRealTime Elapsed real time since the last frame.
+ * @param camera An affected camera
+ */
+ bool Play(const float deltaRealTime, CCamera* camera);
+
+ /**
+ * Validate the path
+ * @return true if the path is valid
+ */
+ bool Validate();
+
+ /**
+ * Returns true if path doesn't contain nodes
+ */
+ bool Empty() const;
+
+ /**
+ * Resets the path state
+ */
+ void Reset();
+
+ fixed GetTimescale() const;
+
+ const TNSpline& GetTargetSpline() const;
+
+private:
+
+ TNSpline m_TargetSpline;
+};
+
+#endif // INCLUDED_CINEMAPATH
Index: ps/trunk/source/simulation2/helpers/CinemaPath.cpp
===================================================================
--- ps/trunk/source/simulation2/helpers/CinemaPath.cpp
+++ ps/trunk/source/simulation2/helpers/CinemaPath.cpp
@@ -0,0 +1,263 @@
+/* Copyright (C) 2017 Wildfire Games.
+ * This file is part of 0 A.D.
+ *
+ * 0 A.D. is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0 A.D. is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0 A.D. If not, see .
+ */
+
+#include "precompiled.h"
+
+#include "CinemaPath.h"
+
+#include
+#include
+
+#include "graphics/Camera.h"
+#include "maths/MathUtil.h"
+#include "maths/Quaternion.h"
+#include "maths/Vector3D.h"
+#include "ps/CLogger.h"
+#include "ps/CStr.h"
+
+CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline)
+ : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f)
+{
+ // Calculate curves by nodes
+ BuildSpline();
+ m_TargetSpline.BuildSpline();
+
+ if (m_Orientation == L"target")
+ {
+ m_LookAtTarget = true;
+ ENSURE(!m_TargetSpline.GetAllNodes().empty());
+ }
+
+ // Set distortion mode and style
+ if (data.m_Mode == L"ease_in")
+ DistModePtr = &CCinemaPath::EaseIn;
+ else if (data.m_Mode == L"ease_out")
+ DistModePtr = &CCinemaPath::EaseOut;
+ else if (data.m_Mode == L"ease_inout")
+ DistModePtr = &CCinemaPath::EaseInOut;
+ else if (data.m_Mode == L"ease_outin")
+ DistModePtr = &CCinemaPath::EaseOutIn;
+ else
+ {
+ LOGWARNING("Cinematic mode not found for '%s'", data.m_Mode.ToUTF8().c_str());
+ DistModePtr = &CCinemaPath::EaseInOut;
+ }
+
+ if (data.m_Style == L"default")
+ DistStylePtr = &CCinemaPath::EaseDefault;
+ else if (data.m_Style == L"growth")
+ DistStylePtr = &CCinemaPath::EaseGrowth;
+ else if (data.m_Style == L"expo")
+ DistStylePtr = &CCinemaPath::EaseExpo;
+ else if (data.m_Style == L"circle")
+ DistStylePtr = &CCinemaPath::EaseCircle;
+ else if (data.m_Style == L"sine")
+ DistStylePtr = &CCinemaPath::EaseSine;
+ else
+ {
+ LOGWARNING("Cinematic style not found for '%s'", data.m_Style.ToUTF8().c_str());
+ DistStylePtr = &CCinemaPath::EaseDefault;
+ }
+}
+
+CVector3D CCinemaPath::GetNodePosition(const int index) const
+{
+ return Node[index].Position;
+}
+
+fixed CCinemaPath::GetNodeDuration(const int index) const
+{
+ return Node[index].Distance;
+}
+
+fixed CCinemaPath::GetDuration() const
+{
+ return MaxDistance;
+}
+
+float CCinemaPath::GetNodeFraction() const
+{
+ return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance.ToFloat();
+}
+
+float CCinemaPath::GetElapsedTime() const
+{
+ return m_TimeElapsed;
+}
+
+const CStrW& CCinemaPath::GetName() const
+{
+ return m_Name;
+}
+
+void CCinemaPath::SetTimescale(fixed scale)
+{
+ m_Timescale = scale;
+}
+
+void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation, CCamera* camera) const
+{
+ t = (this->*DistModePtr)(t);
+
+ CVector3D pos = GetPosition(t);
+
+ if (m_LookAtTarget)
+ {
+ if (m_TimeElapsed <= m_TargetSpline.MaxDistance.ToFloat())
+ camera->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance.ToFloat()), CVector3D(0, 1, 0));
+ else
+ camera->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
+ }
+ else
+ {
+ CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
+ CQuaternion start, end;
+ start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
+ end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
+ start.Slerp(start, end, nodet);
+
+ camera->m_Orientation.SetIdentity();
+ camera->m_Orientation.Rotate(start);
+ camera->m_Orientation.Translate(pos);
+ }
+ camera->UpdateFrustum();
+}
+
+// Distortion mode functions
+float CCinemaPath::EaseIn(float t) const
+{
+ return (this->*DistStylePtr)(t);
+}
+
+float CCinemaPath::EaseOut(float t) const
+{
+ return 1.0f - EaseIn(1.0f-t);
+}
+
+float CCinemaPath::EaseInOut(float t) const
+{
+ if (t < m_Switch)
+ return EaseIn(1.0f/m_Switch * t) * m_Switch;
+ return EaseOut(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
+}
+
+float CCinemaPath::EaseOutIn(float t) const
+{
+ if (t < m_Switch)
+ return EaseOut(1.0f/m_Switch * t) * m_Switch;
+ return EaseIn(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
+}
+
+// Distortion style functions
+float CCinemaPath::EaseDefault(float t) const
+{
+ return t;
+}
+
+float CCinemaPath::EaseGrowth(float t) const
+{
+ return pow(t, m_Growth);
+}
+
+float CCinemaPath::EaseExpo(float t) const
+{
+ if (t == 0)
+ return t;
+ return powf(m_Growth, 10*(t-1.0f));
+}
+
+float CCinemaPath::EaseCircle(float t) const
+{
+ t = -(sqrt(1.0f - t*t) - 1.0f);
+ if (m_GrowthCount > 1.0f)
+ {
+ --m_GrowthCount;
+ return (this->*DistStylePtr)(t);
+ }
+ return t;
+}
+
+float CCinemaPath::EaseSine(float t) const
+{
+ t = 1.0f - cos(t * (float)M_PI/2);
+ if (m_GrowthCount > 1.0f)
+ {
+ --m_GrowthCount;
+ return (this->*DistStylePtr)(t);
+ }
+ return t;
+}
+
+const CCinemaData* CCinemaPath::GetData() const
+{
+ return CCinemaData::GetData();
+}
+
+bool CCinemaPath::Validate()
+{
+ if (m_TimeElapsed > GetDuration().ToFloat() || m_TimeElapsed < 0.0f)
+ return false;
+
+ // Find current node and past "node time"
+ float previousTime = 0.0f, cumulation = 0.0f;
+
+ // Ignore the last node, since it is a blank (node time values are shifted down one from interface)
+ for (size_t i = 0; i < Node.size() - 1; ++i)
+ {
+ cumulation += Node[i].Distance.ToFloat();
+ if (m_TimeElapsed <= cumulation)
+ {
+ m_PreviousNodeTime = previousTime;
+ m_PreviousRotation = Node[i].Rotation;
+ m_CurrentNode = i; // We're moving toward this next node, so use its rotation
+ return true;
+ }
+ previousTime += Node[i].Distance.ToFloat();
+ }
+ debug_warn("validation of cinema path is wrong\n");
+ return false;
+}
+
+bool CCinemaPath::Play(const float deltaRealTime, CCamera* camera)
+{
+ m_TimeElapsed += m_Timescale.ToFloat() * deltaRealTime;
+ if (!Validate())
+ return false;
+
+ MoveToPointAt(m_TimeElapsed / GetDuration().ToFloat(), GetNodeFraction(), m_PreviousRotation, camera);
+ return true;
+}
+
+bool CCinemaPath::Empty() const
+{
+ return Node.empty();
+}
+
+void CCinemaPath::Reset()
+{
+ m_TimeElapsed = 0.0f;
+}
+
+fixed CCinemaPath::GetTimescale() const
+{
+ return m_Timescale;
+}
+
+const TNSpline& CCinemaPath::GetTargetSpline() const
+{
+ return m_TargetSpline;
+}