Reorganize code in different files in prepartion for the cinematic camera patch (by Vladislav Belov).
Refs #3301 This was SVN commit r17575.
This commit is contained in:
parent
969008befd
commit
8d9cfd66b8
115
source/graphics/CinemaManager.cpp
Normal file
115
source/graphics/CinemaManager.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
/* Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "CinemaManager.h"
|
||||
|
||||
#include "CinemaPath.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "maths/Vector4D.h"
|
||||
|
||||
CCinemaManager::CCinemaManager() : m_DrawCurrentSpline(false), m_Active(true), m_ValidCurrent(false)
|
||||
{
|
||||
m_CurrentPath = m_Paths.end();
|
||||
}
|
||||
|
||||
void CCinemaManager::AddPath(CCinemaPath path, const CStrW& name)
|
||||
{
|
||||
ENSURE( m_Paths.find( name ) == m_Paths.end() );
|
||||
m_Paths[name] = path;
|
||||
}
|
||||
|
||||
void CCinemaManager::QueuePath(const CStrW& name, bool queue )
|
||||
{
|
||||
if (!m_PathQueue.empty() && queue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ENSURE(HasTrack(name));
|
||||
m_PathQueue.push_back(m_Paths[name]);
|
||||
}
|
||||
}
|
||||
|
||||
void CCinemaManager::OverridePath(const CStrW& name)
|
||||
{
|
||||
m_PathQueue.clear();
|
||||
ENSURE(HasTrack(name));
|
||||
m_PathQueue.push_back( m_Paths[name] );
|
||||
}
|
||||
|
||||
void CCinemaManager::SetAllPaths( const std::map<CStrW, CCinemaPath>& paths)
|
||||
{
|
||||
CStrW name;
|
||||
m_Paths = paths;
|
||||
}
|
||||
void CCinemaManager::SetCurrentPath(const CStrW& name, bool current, bool drawLines)
|
||||
{
|
||||
if ( !HasTrack(name) )
|
||||
m_ValidCurrent = false;
|
||||
else
|
||||
m_ValidCurrent = true;
|
||||
|
||||
m_CurrentPath = m_Paths.find(name);
|
||||
m_DrawCurrentSpline = current;
|
||||
m_DrawLines = drawLines;
|
||||
DrawSpline();
|
||||
}
|
||||
|
||||
bool CCinemaManager::HasTrack(const CStrW& name) const
|
||||
{
|
||||
return m_Paths.find(name) != m_Paths.end();
|
||||
}
|
||||
|
||||
void CCinemaManager::DrawSpline() const
|
||||
{
|
||||
if ( !(m_DrawCurrentSpline && m_ValidCurrent) )
|
||||
return;
|
||||
static const int smoothness = 200;
|
||||
|
||||
m_CurrentPath->second.DrawSpline(CVector4D(0.f, 0.f, 1.f, 1.f), smoothness, m_DrawLines);
|
||||
}
|
||||
|
||||
void CCinemaManager::MoveToPointAt(float time)
|
||||
{
|
||||
ENSURE(m_CurrentPath != m_Paths.end());
|
||||
StopPlaying();
|
||||
|
||||
m_CurrentPath->second.m_TimeElapsed = time;
|
||||
if ( !m_CurrentPath->second.Validate() )
|
||||
return;
|
||||
|
||||
m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
|
||||
m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
|
||||
m_CurrentPath->second.m_PreviousRotation );
|
||||
}
|
||||
|
||||
bool CCinemaManager::Update(const float deltaRealTime)
|
||||
{
|
||||
if (!m_PathQueue.front().Play(deltaRealTime))
|
||||
{
|
||||
m_PathQueue.pop_front();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
69
source/graphics/CinemaManager.h
Normal file
69
source/graphics/CinemaManager.h
Normal file
@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2015 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INCLUDED_CINEMAMANAGER
|
||||
#define INCLUDED_CINEMAMANAGER
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include "graphics/CinemaPath.h"
|
||||
#include "ps/CStr.h"
|
||||
|
||||
//Class for in game playing of cinematics. Should only be instantiated in CGameView.
|
||||
class CCinemaManager
|
||||
{
|
||||
public:
|
||||
CCinemaManager();
|
||||
~CCinemaManager() {}
|
||||
|
||||
void AddPath(CCinemaPath path, const CStrW& name);
|
||||
|
||||
//Adds track to list of being played.
|
||||
void QueuePath(const CStrW& name, bool queue);
|
||||
void OverridePath(const CStrW& name); //clears track queue and replaces with 'name'
|
||||
|
||||
/**
|
||||
* @param deltaRealTime Elapsed real time since the last frame.
|
||||
*/
|
||||
bool Update(const float deltaRealTime);
|
||||
|
||||
//These stop track play, and accept time, not ratio of time
|
||||
void MoveToPointAt(float time);
|
||||
|
||||
inline void StopPlaying() { m_PathQueue.clear(); }
|
||||
void DrawSpline() const;
|
||||
|
||||
inline bool IsPlaying() const { return !m_PathQueue.empty(); }
|
||||
bool HasTrack(const CStrW& name) const;
|
||||
inline bool IsActive() const { return m_Active; }
|
||||
inline void SetActive(bool active) { m_Active=active; }
|
||||
|
||||
inline const std::map<CStrW, CCinemaPath>& GetAllPaths() { return m_Paths; }
|
||||
void SetAllPaths( const std::map<CStrW, CCinemaPath>& tracks);
|
||||
void SetCurrentPath(const CStrW& name, bool current, bool lines);
|
||||
|
||||
private:
|
||||
|
||||
bool m_Active, m_DrawCurrentSpline, m_DrawLines, m_ValidCurrent;
|
||||
std::map<CStrW, CCinemaPath>::iterator m_CurrentPath;
|
||||
std::map<CStrW, CCinemaPath> m_Paths;
|
||||
std::list<CCinemaPath> m_PathQueue;
|
||||
};
|
||||
|
||||
#endif
|
@ -17,10 +17,13 @@
|
||||
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "CinemaPath.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "lib/ogl.h"
|
||||
#include "CinemaTrack.h"
|
||||
#include "ps/Game.h"
|
||||
#include "GameView.h"
|
||||
#include "maths/MathUtil.h"
|
||||
@ -257,92 +260,4 @@ bool CCinemaPath::Play(const float deltaRealTime)
|
||||
|
||||
MoveToPointAt( m_TimeElapsed / GetDuration(), GetNodeFraction(), m_PreviousRotation );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CCinemaManager::CCinemaManager() : m_DrawCurrentSpline(false), m_Active(true), m_ValidCurrent(false)
|
||||
{
|
||||
m_CurrentPath = m_Paths.end();
|
||||
}
|
||||
|
||||
void CCinemaManager::AddPath(CCinemaPath path, const CStrW& name)
|
||||
{
|
||||
ENSURE( m_Paths.find( name ) == m_Paths.end() );
|
||||
m_Paths[name] = path;
|
||||
}
|
||||
|
||||
void CCinemaManager::QueuePath(const CStrW& name, bool queue )
|
||||
{
|
||||
if (!m_PathQueue.empty() && queue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ENSURE(HasTrack(name));
|
||||
m_PathQueue.push_back(m_Paths[name]);
|
||||
}
|
||||
}
|
||||
|
||||
void CCinemaManager::OverridePath(const CStrW& name)
|
||||
{
|
||||
m_PathQueue.clear();
|
||||
ENSURE(HasTrack(name));
|
||||
m_PathQueue.push_back( m_Paths[name] );
|
||||
}
|
||||
|
||||
void CCinemaManager::SetAllPaths( const std::map<CStrW, CCinemaPath>& paths)
|
||||
{
|
||||
CStrW name;
|
||||
m_Paths = paths;
|
||||
}
|
||||
void CCinemaManager::SetCurrentPath(const CStrW& name, bool current, bool drawLines)
|
||||
{
|
||||
if ( !HasTrack(name) )
|
||||
m_ValidCurrent = false;
|
||||
else
|
||||
m_ValidCurrent = true;
|
||||
|
||||
m_CurrentPath = m_Paths.find(name);
|
||||
m_DrawCurrentSpline = current;
|
||||
m_DrawLines = drawLines;
|
||||
DrawSpline();
|
||||
}
|
||||
|
||||
bool CCinemaManager::HasTrack(const CStrW& name) const
|
||||
{
|
||||
return m_Paths.find(name) != m_Paths.end();
|
||||
}
|
||||
|
||||
void CCinemaManager::DrawSpline() const
|
||||
{
|
||||
if ( !(m_DrawCurrentSpline && m_ValidCurrent) )
|
||||
return;
|
||||
static const int smoothness = 200;
|
||||
|
||||
m_CurrentPath->second.DrawSpline(CVector4D(0.f, 0.f, 1.f, 1.f), smoothness, m_DrawLines);
|
||||
}
|
||||
|
||||
void CCinemaManager::MoveToPointAt(float time)
|
||||
{
|
||||
ENSURE(m_CurrentPath != m_Paths.end());
|
||||
StopPlaying();
|
||||
|
||||
m_CurrentPath->second.m_TimeElapsed = time;
|
||||
if ( !m_CurrentPath->second.Validate() )
|
||||
return;
|
||||
|
||||
m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
|
||||
m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
|
||||
m_CurrentPath->second.m_PreviousRotation );
|
||||
}
|
||||
|
||||
bool CCinemaManager::Update(const float deltaRealTime)
|
||||
{
|
||||
if (!m_PathQueue.front().Play(deltaRealTime))
|
||||
{
|
||||
m_PathQueue.pop_front();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INCLUDED_CINEMATRACK
|
||||
#define INCLUDED_CINEMATRACK
|
||||
#ifndef INCLUDED_CINEMAPATH
|
||||
#define INCLUDED_CINEMAPATH
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
@ -121,45 +121,4 @@ public:
|
||||
inline float GetTimescale() const { return m_Timescale; }
|
||||
};
|
||||
|
||||
//Class for in game playing of cinematics. Should only be instantiated in CGameView.
|
||||
class CCinemaManager
|
||||
{
|
||||
public:
|
||||
CCinemaManager();
|
||||
~CCinemaManager() {}
|
||||
|
||||
void AddPath(CCinemaPath path, const CStrW& name);
|
||||
|
||||
//Adds track to list of being played.
|
||||
void QueuePath(const CStrW& name, bool queue);
|
||||
void OverridePath(const CStrW& name); //clears track queue and replaces with 'name'
|
||||
|
||||
/**
|
||||
* @param deltaRealTime Elapsed real time since the last frame.
|
||||
*/
|
||||
bool Update(const float deltaRealTime);
|
||||
|
||||
//These stop track play, and accept time, not ratio of time
|
||||
void MoveToPointAt(float time);
|
||||
|
||||
inline void StopPlaying() { m_PathQueue.clear(); }
|
||||
void DrawSpline() const;
|
||||
|
||||
inline bool IsPlaying() const { return !m_PathQueue.empty(); }
|
||||
bool HasTrack(const CStrW& name) const;
|
||||
inline bool IsActive() const { return m_Active; }
|
||||
inline void SetActive(bool active) { m_Active=active; }
|
||||
|
||||
inline const std::map<CStrW, CCinemaPath>& GetAllPaths() { return m_Paths; }
|
||||
void SetAllPaths( const std::map<CStrW, CCinemaPath>& tracks);
|
||||
void SetCurrentPath(const CStrW& name, bool current, bool lines);
|
||||
|
||||
private:
|
||||
|
||||
bool m_Active, m_DrawCurrentSpline, m_DrawLines, m_ValidCurrent;
|
||||
std::map<CStrW, CCinemaPath>::iterator m_CurrentPath;
|
||||
std::map<CStrW, CCinemaPath> m_Paths;
|
||||
std::list<CCinemaPath> m_PathQueue;
|
||||
};
|
||||
|
||||
#endif
|
@ -20,7 +20,7 @@
|
||||
#include "GameView.h"
|
||||
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "graphics/ColladaManager.h"
|
||||
#include "graphics/HFTracer.h"
|
||||
#include "graphics/LOSTexture.h"
|
||||
@ -258,7 +258,7 @@ public:
|
||||
*/
|
||||
CLightEnv CachedLightEnv;
|
||||
|
||||
CCinemaManager TrackManager;
|
||||
CCinemaManager CinemaManager;
|
||||
|
||||
/**
|
||||
* Entity for the camera to follow, or INVALID_ENTITY if none.
|
||||
@ -395,7 +395,7 @@ CCamera* CGameView::GetCamera()
|
||||
|
||||
CCinemaManager* CGameView::GetCinema()
|
||||
{
|
||||
return &m->TrackManager;
|
||||
return &m->CinemaManager;
|
||||
};
|
||||
|
||||
CLOSTexture& CGameView::GetLOSTexture()
|
||||
@ -626,9 +626,9 @@ void CGameView::Update(const float deltaRealTime)
|
||||
if (!g_app_has_focus)
|
||||
return;
|
||||
|
||||
if (m->TrackManager.IsActive() && m->TrackManager.IsPlaying())
|
||||
if (m->CinemaManager.IsActive() && m->CinemaManager.IsPlaying())
|
||||
{
|
||||
if (! m->TrackManager.Update(deltaRealTime))
|
||||
if (! m->CinemaManager.Update(deltaRealTime))
|
||||
{
|
||||
// ResetCamera();
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "MapReader.h"
|
||||
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "graphics/Entity.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/MapGenerator.h"
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "Camera.h"
|
||||
#include "CinemaTrack.h"
|
||||
#include "CinemaManager.h"
|
||||
#include "GameView.h"
|
||||
#include "LightEnv.h"
|
||||
#include "MapReader.h"
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "lib/sysdep/os/win/wversion.h"
|
||||
#endif
|
||||
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaPath.h"
|
||||
#include "graphics/FontMetrics.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/LightEnv.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "ps/Game.h"
|
||||
#include "renderer/Renderer.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
|
||||
#include "ps/World.h"
|
||||
#include "graphics/Terrain.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "MessageHandler.h"
|
||||
#include "../CommandProc.h"
|
||||
#include "graphics/Camera.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/CStr.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "../GameLoop.h"
|
||||
#include "../View.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "gui/GUIManager.h"
|
||||
#include "gui/GUI.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "ps/Game.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "simulation2/Simulation2.h"
|
||||
|
||||
namespace AtlasMessage {
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "Messages.h"
|
||||
#include "SimState.h"
|
||||
|
||||
#include "graphics/CinemaTrack.h"
|
||||
#include "graphics/CinemaManager.h"
|
||||
#include "graphics/GameView.h"
|
||||
#include "graphics/ParticleManager.h"
|
||||
#include "graphics/SColor.h"
|
||||
|
Loading…
Reference in New Issue
Block a user