Ticket #3301: cinematic_camera_core_v0.6.patch

File cinematic_camera_core_v0.6.patch, 80.3 KB (added by Vladislav Belov, 8 years ago)
  • source/graphics/CinemaManager.cpp

     
     1/* Copyright (C) 2015 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
     19#include "precompiled.h"
     20
     21#include "Camera.h"
     22#include "CinemaManager.h"
     23#include "GameView.h"
     24#include "gui/CGUI.h"
     25#include "gui/GUIManager.h"
     26#include "gui/IGUIObject.h"
     27#include "lib/ogl.h"
     28#include "maths/MathUtil.h"
     29#include "maths/Quaternion.h"
     30#include "maths/Vector3D.h"
     31#include "maths/Vector4D.h"
     32#include "ps/CLogger.h"
     33#include "ps/CStr.h"
     34#include "ps/Game.h"
     35#include "ps/Hotkey.h"
     36#include "simulation2/components/ICmpOverlayRenderer.h"
     37#include "simulation2/components/ICmpRangeManager.h"
     38#include "simulation2/components/ICmpSelectable.h"
     39#include "simulation2/components/ICmpTerritoryManager.h"
     40#include "simulation2/MessageTypes.h"
     41#include "simulation2/system/ComponentManager.h"
     42#include "simulation2/Simulation2.h"
     43#include <sstream>
     44#include <string>
     45#include "renderer/Renderer.h"
     46
     47
     48CCinemaManager::CCinemaManager()
     49    : m_Active(false), m_Paused(true), m_DrawPaths(true)
     50{
     51}
     52
     53void CCinemaManager::AddPath(const CStrW& name, CCinemaPath path)
     54{
     55    ENSURE(m_Paths.find(name) == m_Paths.end());
     56    m_Paths[name] = path;
     57}
     58
     59void CCinemaManager::AddPathToQueue(const CStrW& name)
     60{
     61    ENSURE(HasPath(name));
     62    m_PathQueue.push_back(m_Paths[name]);
     63}
     64
     65void CCinemaManager::ClearQueue()
     66{
     67    m_PathQueue.clear();
     68}
     69
     70void CCinemaManager::SetAllPaths(const std::map<CStrW, CCinemaPath>& paths)
     71{
     72    m_Paths = paths;
     73}
     74
     75void CCinemaManager::SetCurrentPath(const CStrW& name, bool current)
     76{
     77    // ...
     78}
     79
     80bool CCinemaManager::HasPath(const CStrW& name) const
     81{
     82    return m_Paths.find(name) != m_Paths.end();
     83}
     84
     85void CCinemaManager::SetActive(bool active)
     86{
     87    if (m_Active == active)
     88        return;
     89
     90    IGUIObject *sn = g_GUI->FindObjectByName("sn");
     91    CmpPtr <ICmpRangeManager> cmpRangeManager(*(g_Game->GetSimulation2()), SYSTEM_ENTITY);
     92    CmpPtr <ICmpTerritoryManager> cmpTerritoryManager(*(g_Game->GetSimulation2()), SYSTEM_ENTITY);
     93
     94    // GUI visibility
     95    if (sn)
     96    {
     97        if (active)
     98            sn->SetSetting("hidden", L"true");
     99        else
     100            sn->SetSetting("hidden", L"false");
     101    }
     102
     103    // Overlay visibility
     104    g_Renderer.SetOptionBool(CRenderer::Option::OPT_SILHOUETTES, !active);
     105    if (cmpRangeManager)
     106    {
     107        if (active)
     108            m_MapRevealed = cmpRangeManager->GetLosRevealAll(-1);
     109        // TODO: improve m_MapRevealed state and without fade in
     110        cmpRangeManager->SetLosRevealAll(-1, active);
     111    }
     112    if (cmpTerritoryManager)
     113        cmpTerritoryManager->SetVisibility(!active);
     114    ICmpSelectable::SetOverrideVisibility(!active);
     115    ICmpOverlayRenderer::SetOverrideVisibility(!active);
     116
     117    m_Active = active;
     118}
     119
     120void CCinemaManager::MoveToPointAt(float time)
     121{
     122    // TODO: Update after Atlas UI patch
     123    /*ENSURE(m_CurrentPath != m_Paths.end());
     124    ClearQueue();
     125
     126    m_CurrentPath->second.m_TimeElapsed = time;
     127    if (!m_CurrentPath->second.Validate())
     128        return;
     129
     130    m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
     131                m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
     132                m_CurrentPath->second.m_PreviousRotation );*/
     133}
     134
     135void CCinemaManager::Play()
     136{
     137    SetActive(true);
     138    m_Paused = false;
     139}
     140
     141void CCinemaManager::Pause()
     142{
     143    m_Paused = true;
     144}
     145
     146void CCinemaManager::Stop()
     147{
     148    m_Paused = true;
     149}
     150
     151void CCinemaManager::Skip()
     152{
     153    m_PathQueue.clear();
     154    SetActive(false);
     155    m_Paused = true;
     156}
     157
     158void CCinemaManager::Next()
     159{
     160    CMessageCinemaPathEnded msg(m_PathQueue.back().GetName());
     161    g_Game->GetSimulation2()->PostMessage(SYSTEM_ENTITY, msg);
     162
     163    m_PathQueue.pop_front();
     164    if (m_PathQueue.empty())
     165    {
     166        SetActive(false);
     167        m_Paused = true;
     168    }
     169}
     170
     171void CCinemaManager::Update(const float deltaRealTime)
     172{
     173    if (!m_Active || m_Paused)
     174        return;
     175
     176    if (HotkeyIsPressed("leave"))
     177    {
     178        Skip();
     179        return;
     180    }
     181
     182    if (m_PathQueue.front().Play(deltaRealTime))
     183        return;
     184
     185    Next();
     186    return;
     187}
     188
     189void CCinemaManager::Render()
     190{
     191    if (IsActive())
     192    {
     193        DrawBars();
     194        return;
     195    }
     196   
     197    if (!m_DrawPaths)
     198        return;
     199
     200    for (auto it : m_Paths)
     201    {
     202        it.second.DrawSpline(CVector4D(0.2f, 0.2f, 1.f, 0.5f), 100, true);
     203        it.second.DrawNodes(CVector4D(0.5f, 1.0f, 0.f, 0.5f));
     204    }
     205}
     206
     207void CCinemaManager::DrawBars() const
     208{
     209    int height = (float)g_xres / 2.39f;
     210    int shift = (g_yres - height) / 2;
     211    if (shift <= 0)
     212        return;
     213
     214#if CONFIG2_GLES
     215    #warning TODO : implement bars for GLES
     216#else
     217    // Set up transform for GL bars
     218    glMatrixMode(GL_PROJECTION);
     219    glPushMatrix();
     220    glLoadIdentity();
     221    glMatrixMode(GL_MODELVIEW);
     222    glPushMatrix();
     223    glLoadIdentity();
     224    CMatrix3D transform;
     225    transform.SetOrtho(0.f, (float)g_xres, 0.f, (float)g_yres, -1.f, 1000.f);
     226    glLoadMatrixf(&transform._11);
     227
     228    glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
     229
     230    glEnable(GL_BLEND);
     231    glDisable(GL_DEPTH_TEST);
     232
     233    glBegin(GL_QUADS);
     234    glVertex2i(0, 0);
     235    glVertex2i(g_xres, 0);
     236    glVertex2i(g_xres, shift);
     237    glVertex2i(0, shift);
     238    glEnd();
     239
     240    glBegin(GL_QUADS);
     241    glVertex2i(0, g_yres - shift);
     242    glVertex2i(g_xres, g_yres - shift);
     243    glVertex2i(g_xres, g_yres);
     244    glVertex2i(0, g_yres);
     245    glEnd();
     246
     247    glDisable(GL_BLEND);
     248    glEnable(GL_DEPTH_TEST);
     249
     250    // Restore transform
     251    glMatrixMode(GL_PROJECTION);
     252    glPopMatrix();
     253    glMatrixMode(GL_MODELVIEW);
     254    glPopMatrix();
     255#endif
     256}
  • source/graphics/CinemaManager.h

     
     1/* Copyright (C) 2015 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
     19#ifndef INCLUDED_CINEMAMANAGER
     20#define INCLUDED_CINEMAMANAGER
     21
     22#include <list>
     23#include <map>
     24#include "graphics/CinemaPath.h"
     25#include "ps/CStr.h"
     26
     27/*
     28    desc: contains various functions used for cinematic camera paths
     29    See also: CinemaHandler.cpp, CinemaPath.cpp
     30*/
     31
     32/**
     33 * Class for in game playing of cinematics. Should only be instantiated in CGameView.
     34 */
     35
     36class CCinemaManager
     37{
     38public:
     39    CCinemaManager();
     40    ~CCinemaManager() {}
     41
     42    /**
     43     * Adds the path to the path list
     44     * @param name path name
     45     * @param CCinemaPath path data
     46     */
     47    void AddPath(const CStrW& name, CCinemaPath path);
     48
     49    /**
     50     * Adds the path to the playlist
     51     * @param name path name
     52     */
     53    void AddPathToQueue(const CStrW& name);
     54
     55    /**
     56     * Clears the playlist
     57     */
     58    void ClearQueue();
     59
     60    /**
     61     * Checks the path name in the path list
     62     * @param name path name
     63     * @return true if path with that name exists, else false
     64     */
     65    bool HasPath(const CStrW& name) const;
     66   
     67    /**
     68     * These stop track play, and accept time, not ratio of time
     69     * @time point in the timeline
     70     */
     71    void MoveToPointAt(float time);
     72
     73    // TODO: remove legacy methods after Atlas UI patch
     74    inline const std::map<CStrW, CCinemaPath>& GetAllPaths() { return m_Paths; }
     75    void SetAllPaths( const std::map<CStrW, CCinemaPath>& tracks);
     76    void SetCurrentPath(const CStrW& name, bool current);
     77
     78    /**
     79     * Starts play paths
     80     */
     81    void Play();
     82    void Pause();
     83    void Next();
     84    void Stop();
     85    void Skip();
     86    inline bool IsPlaying() const { return !m_Paused; }
     87
     88    /**
     89     * Renders black bars and paths (if enabled)
     90     */
     91    void Render();
     92    void DrawBars() const;
     93
     94    /**
     95     * Sets active state of the cinema manager (shows/hide gui, show/hide rings, etc)
     96     * @active new active state
     97     */
     98    void SetActive(bool active);
     99    inline bool IsActive() const { return m_Active; }
     100
     101    /**
     102     * Updates CCinemManager and current path
     103     * @param deltaRealTime Elapsed real time since the last frame.
     104     */
     105    void Update(const float deltaRealTime);
     106
     107private:   
     108    bool m_Active, m_Paused, m_DrawPaths;
     109
     110    std::map<CStrW, CCinemaPath> m_Paths;
     111    std::list<CCinemaPath> m_PathQueue;
     112
     113    // States before playing
     114    bool m_MapRevealed;
     115};
     116
     117#endif
  • source/graphics/CinemaPath.cpp

     
     1/* Copyright (C) 2015 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#include "precompiled.h"
     19
     20#include "CinemaPath.h"
     21
     22#include "Camera.h"
     23#include "CinemaManager.h"
     24#include "GameView.h"
     25#include "gui/CGUI.h"
     26#include "gui/GUIManager.h"
     27#include "gui/IGUIObject.h"
     28#include "lib/ogl.h"
     29#include "maths/MathUtil.h"
     30#include "maths/Quaternion.h"
     31#include "maths/Vector3D.h"
     32#include "maths/Vector4D.h"
     33#include "ps/CLogger.h"
     34#include "ps/CStr.h"
     35#include "ps/Game.h"
     36#include <sstream>
     37#include <string>
     38#include "renderer/Renderer.h"
     39
     40CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline)
     41    : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f)
     42{
     43    BuildSpline();
     44
     45    if (m_Orientation == L"target")
     46    {
     47        m_LookAtTarget = true;
     48        ENSURE(m_TargetSpline.GetAllNodes().size() > 0);
     49    }
     50
     51    // Set distortion mode and style
     52    if (data.m_Mode == L"ease_in")
     53        DistModePtr = &CCinemaPath::EaseIn;
     54    else if (data.m_Mode == L"ease_out")
     55        DistModePtr = &CCinemaPath::EaseOut;
     56    else if (data.m_Mode == L"ease_inout")
     57        DistModePtr = &CCinemaPath::EaseInOut;
     58    else if (data.m_Mode == L"ease_outin")
     59        DistModePtr = &CCinemaPath::EaseOutIn;
     60    else
     61    {
     62        debug_printf("Cinematic mode not found for '%s'\n", data.m_Mode.ToUTF8().c_str());
     63        DistModePtr = &CCinemaPath::EaseInOut;
     64    }
     65
     66    if (data.m_Style == L"default")
     67        DistStylePtr = &CCinemaPath::EaseDefault;
     68    else if (data.m_Style == L"growth")
     69        DistStylePtr = &CCinemaPath::EaseGrowth;
     70    else if (data.m_Style == L"expo")
     71        DistStylePtr = &CCinemaPath::EaseExpo;
     72    else if (data.m_Style == L"circle")
     73        DistStylePtr = &CCinemaPath::EaseCircle;
     74    else if (data.m_Style == L"sine")
     75        DistStylePtr = &CCinemaPath::EaseSine;
     76    else
     77    {
     78        debug_printf("Cinematic style not found for '%s'\n", data.m_Style.ToUTF8().c_str());
     79        DistStylePtr = &CCinemaPath::EaseDefault;
     80    }
     81
     82    //UpdateDuration();
     83}
     84
     85void CCinemaPath::DrawSpline(const CVector4D& RGBA, int smoothness, bool lines) const
     86{
     87    if (NodeCount < 2 || DistModePtr == NULL)
     88        return;
     89    if (NodeCount == 2 && lines)
     90        smoothness = 2;
     91
     92    float start = MaxDistance / smoothness;
     93    float time = 0;
     94
     95#if CONFIG2_GLES
     96    #warning TODO : do something about CCinemaPath on GLES
     97#else
     98
     99    glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W);
     100    if (lines)
     101    {
     102        glLineWidth(1.8f);
     103        glEnable(GL_LINE_SMOOTH);
     104        glBegin(GL_LINE_STRIP);
     105
     106        for (int i = 0; i <= smoothness; ++i)
     107        {
     108            // Find distorted time
     109            time = start*i / MaxDistance;
     110            CVector3D tmp = GetPosition(time);
     111            glVertex3f(tmp.X, tmp.Y, tmp.Z);
     112        }
     113        glEnd();
     114        glDisable(GL_LINE_SMOOTH);
     115        glLineWidth(1.0f);
     116    }
     117    else
     118    {
     119        smoothness /= 2;
     120        start = MaxDistance / smoothness;
     121        glEnable(GL_POINT_SMOOTH);
     122        glPointSize(3.0f);
     123        glBegin(GL_POINTS);
     124
     125        for (int i = 0; i <= smoothness; ++i)
     126        {
     127            // Find distorted time
     128            time = (this->*DistModePtr)(start*i / MaxDistance);
     129            CVector3D tmp = GetPosition(time);
     130            glVertex3f(tmp.X, tmp.Y, tmp.Z);
     131        }
     132        glColor3f(1.0f, 1.0f, 0.0f);    // yellow
     133
     134        for (size_t i = 0; i<Node.size(); ++i)
     135            glVertex3f(Node[i].Position.X, Node[i].Position.Y, Node[i].Position.Z);
     136
     137        glEnd();
     138        glPointSize(1.0f);
     139        glDisable(GL_POINT_SMOOTH);
     140    }
     141
     142#endif
     143}
     144
     145void CCinemaPath::DrawNodes(const CVector4D& RGBA) const
     146{
     147#if CONFIG2_GLES
     148    #warning TODO : do something about CCinemaPath on GLES
     149#else
     150    glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W);
     151    glEnable(GL_POINT_SMOOTH);
     152    glPointSize(5.0f);
     153    glBegin(GL_POINTS);
     154    for (size_t i = 0; i < Node.size(); ++i)
     155        glVertex3f(Node[i].Position.X, Node[i].Position.Y, Node[i].Position.Z);
     156    glEnd();
     157    glPointSize(1.0f);
     158    glDisable(GL_POINT_SMOOTH);
     159#endif
     160}
     161
     162void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation)
     163{
     164    CCamera *Cam = g_Game->GetView()->GetCamera();
     165    t = (this->*DistModePtr)(t);
     166    CVector3D pos = GetPosition(t);
     167   
     168    if (m_LookAtTarget)
     169    {
     170        if (m_TimeElapsed <= m_TargetSpline.MaxDistance)
     171            Cam->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance), CVector3D(0, 1, 0));
     172        else
     173            Cam->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
     174    }
     175    else
     176    {
     177        CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
     178        CQuaternion start, end;
     179        start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
     180        end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
     181        start.Slerp(start, end, nodet);
     182
     183        Cam->m_Orientation.SetIdentity();
     184        Cam->m_Orientation.Rotate(start);
     185        Cam->m_Orientation.Translate(pos);
     186    }
     187    Cam->UpdateFrustum();
     188}
     189
     190// Distortion mode functions
     191float CCinemaPath::EaseIn(float t) const
     192{
     193    return (this->*DistStylePtr)(t);
     194}
     195
     196float CCinemaPath::EaseOut(float t) const
     197{
     198    return 1.0f - EaseIn(1.0f - t);
     199}
     200
     201float CCinemaPath::EaseInOut(float t) const
     202{
     203    if (t < m_Switch)
     204        return EaseIn(1.0f / m_Switch * t) * m_Switch;
     205    return EaseOut(1.0f / m_Switch * (t - m_Switch)) * m_Switch + m_Switch;
     206}
     207
     208float CCinemaPath::EaseOutIn(float t) const
     209{
     210    if (t < m_Switch)
     211        return EaseOut(1.0f / m_Switch * t) * m_Switch;
     212    return EaseIn(1.0f / m_Switch * (t - m_Switch)) * m_Switch + m_Switch;
     213}
     214
     215// Distortion style functions
     216float CCinemaPath::EaseDefault(float t) const
     217{
     218    return t;
     219}
     220
     221float CCinemaPath::EaseGrowth(float t) const
     222{
     223    return pow(t, m_Growth);
     224}
     225
     226
     227float CCinemaPath::EaseExpo(float t) const
     228{
     229    if (t == 0)
     230        return t;
     231    return powf(m_Growth, 10 * (t - 1.0f));
     232}
     233
     234float CCinemaPath::EaseCircle(float t) const
     235{
     236    t = -(sqrt(1.0f - t*t) - 1.0f);
     237    if (m_GrowthCount > 1.0f)
     238    {
     239        --m_GrowthCount;
     240        return (this->*DistStylePtr)(t);
     241    }
     242    return t;
     243}
     244
     245float CCinemaPath::EaseSine(float t) const
     246{
     247    t = 1.0f - cos(t * (float)M_PI / 2);
     248    if (m_GrowthCount > 1.0f)
     249    {
     250        --m_GrowthCount;
     251        return (this->*DistStylePtr)(t);
     252    }
     253    return t;
     254}
     255
     256bool CCinemaPath::Validate()
     257{
     258    if (m_TimeElapsed <= GetDuration() && m_TimeElapsed >= 0.0f)
     259    {
     260        // Find current node and past "node time"
     261        float previousTime = 0.0f, cumulation = 0.0f;
     262        // Ignore the last node, since it is a blank (node time values are shifted down one from interface)
     263        for (size_t i = 0; i < Node.size() - 1; ++i)
     264        {
     265            cumulation += Node[i].Distance;
     266            if (m_TimeElapsed <= cumulation)
     267            {
     268                m_PreviousNodeTime = previousTime;
     269                m_PreviousRotation = Node[i].Rotation;
     270                m_CurrentNode = i;  // We're moving toward this next node, so use its rotation
     271                return true;
     272            }
     273            else
     274                previousTime += Node[i].Distance;
     275        }
     276    }
     277    return false;
     278}
     279
     280bool CCinemaPath::Play(const float deltaRealTime)
     281{
     282    m_TimeElapsed += m_Timescale * deltaRealTime;
     283    if (!Validate())
     284    {
     285        m_TimeElapsed = 0.0f;
     286        return false;
     287    }
     288    MoveToPointAt(m_TimeElapsed / GetDuration(), GetNodeFraction(), m_PreviousRotation);
     289    return true;
     290}
  • source/graphics/CinemaPath.h

     
     1/* Copyright (C) 2015 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 CVector4D;
     26class CCamera;
     27
     28// For loading data
     29class CCinemaData
     30{
     31public:
     32    CCinemaData() : m_LookAtTarget(false), m_GrowthCount(0), m_Growth(1), m_Switch(1), m_Timescale(1) {}
     33    virtual ~CCinemaData() {}
     34
     35    const CCinemaData* GetData() const { return this; }
     36
     37    CStrW m_Name;
     38    CStrW m_Orientation;
     39    bool m_LookAtTarget;
     40
     41    // Distortion variables
     42    mutable float m_GrowthCount;
     43    float m_Growth;
     44    float m_Switch;
     45    CStrW m_Mode;
     46    CStrW m_Style;
     47    float m_Timescale; // a negative timescale results in backwards play
     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:
     58    CCinemaPath() : m_TimeElapsed(0), m_PreviousNodeTime(0) {}
     59    CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline);
     60    ~CCinemaPath() { DistStylePtr = NULL;  DistModePtr = NULL; }
     61
     62    // Sets camera position to calculated point on spline
     63    void MoveToPointAt(float t, float nodet, const CVector3D&);
     64
     65    // Distortion mode functions-change how ratio is passed to distortion style functions
     66    float EaseIn(float t) const;
     67    float EaseOut(float t) const;
     68    float EaseInOut(float t) const;
     69    float EaseOutIn(float t) const;
     70
     71    // Distortion style functions
     72    float EaseDefault(float t) const;
     73    float EaseGrowth(float t) const;
     74    float EaseExpo(float t) const;
     75    float EaseCircle(float t) const;
     76    float EaseSine(float t) const;
     77
     78    float (CCinemaPath::*DistStylePtr)(float ratio) const;
     79    float (CCinemaPath::*DistModePtr)(float ratio) const;
     80
     81    const CCinemaData* GetData() const { return CCinemaData::GetData(); }
     82
     83public:
     84
     85    void DrawSpline(const CVector4D& RGBA, int smoothness, bool lines) const;
     86    void DrawNodes(const CVector4D& RGBA) const;
     87
     88    inline CVector3D GetNodePosition(const int index) const { return Node[index].Position; }
     89    inline float GetNodeDuration(const int index) const { return Node[index].Distance; }
     90    inline float GetDuration() const { return MaxDistance; }
     91
     92    inline float GetNodeFraction() const { return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance; }
     93    inline float GetElapsedTime() const { return m_TimeElapsed; }
     94
     95    CStrW GetName() const { return m_Name; }
     96
     97    inline void SetTimescale(float scale) { m_Timescale = scale; }
     98
     99    float m_TimeElapsed;
     100    float m_PreviousNodeTime;   //How much time has passed before the current node
     101
     102    size_t m_CurrentNode;
     103    CVector3D m_PreviousRotation;
     104
     105public:
     106
     107    /**
     108     * Returns false if finished.
     109     * @param deltaRealTime Elapsed real time since the last frame.
     110     */
     111    bool Play(const float deltaRealTime);
     112
     113    /**
     114     * Validate the path
     115     * @return true if the path is valid
     116     */
     117    bool Validate();
     118
     119    /**
     120     * Returns true if path doesn't contain nodes
     121     */
     122    bool Empty() { return Node.empty(); }
     123
     124    inline float GetTimescale() const { return m_Timescale; }
     125
     126private:
     127
     128    TNSpline m_TargetSpline;
     129};
     130
     131#endif // INCLUDED_CINEMAPATH
  • source/graphics/CinemaTrack.cpp

     
    1 /* Copyright (C) 2015 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 
    19 #include "precompiled.h"
    20 #include <string>
    21 #include <sstream>
    22 #include "lib/ogl.h"
    23 #include "CinemaTrack.h"
    24 #include "ps/Game.h"
    25 #include "GameView.h"
    26 #include "maths/MathUtil.h"
    27 #include "Camera.h"
    28 #include "ps/CStr.h"
    29 #include "maths/Vector3D.h"
    30 #include "maths/Vector4D.h"
    31 #include "maths/Quaternion.h"
    32 
    33 CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline)
    34     : CCinemaData(data), TNSpline(spline), m_TimeElapsed(0.f)
    35 {
    36     m_TimeElapsed = 0;
    37     BuildSpline();
    38 
    39     //Set distortion mode and style
    40     switch(data.m_Mode)
    41     {
    42     case CCinemaPath::EM_IN:
    43         DistModePtr = &CCinemaPath::EaseIn;
    44         break;
    45     case CCinemaPath::EM_OUT:
    46         DistModePtr = &CCinemaPath::EaseOut;
    47         break;
    48     case CCinemaPath::EM_INOUT:
    49         DistModePtr = &CCinemaPath::EaseInOut;
    50         break;
    51     case CCinemaPath::EM_OUTIN:
    52         DistModePtr = &CCinemaPath::EaseOutIn;
    53         break;
    54     default:
    55         debug_printf("Cinematic mode not found for %d\n", data.m_Mode);
    56         break;
    57     }
    58 
    59     switch (data.m_Style)
    60     {
    61     case CCinemaPath::ES_DEFAULT:
    62         DistStylePtr = &CCinemaPath::EaseDefault;
    63         break;
    64     case CCinemaPath::ES_GROWTH:
    65         DistStylePtr = &CCinemaPath::EaseGrowth;
    66         break;
    67     case CCinemaPath::ES_EXPO:
    68         DistStylePtr = &CCinemaPath::EaseExpo;
    69         break;
    70     case CCinemaPath::ES_CIRCLE:
    71         DistStylePtr = &CCinemaPath::EaseCircle;
    72         break;
    73     case CCinemaPath::ES_SINE:
    74         DistStylePtr = &CCinemaPath::EaseSine;
    75         break;
    76     default:
    77         debug_printf("Cinematic mode not found for %d\n", data.m_Style);
    78         break;
    79     }
    80     //UpdateDuration();
    81 
    82 }
    83 
    84 void CCinemaPath::DrawSpline(const CVector4D& RGBA, int smoothness, bool lines) const
    85 {
    86     if (NodeCount < 2 || DistModePtr == NULL)
    87         return;
    88     if ( NodeCount == 2 && lines )
    89         smoothness = 2;
    90 
    91     float start = MaxDistance / smoothness;
    92     float time=0;
    93    
    94 #if CONFIG2_GLES
    95 #warning TODO: do something about CCinemaPath on GLES
    96 #else
    97 
    98     glColor4f( RGBA.X, RGBA.Y, RGBA.Z, RGBA.W );
    99     if ( lines )
    100     {   
    101         glLineWidth(1.8f);
    102         glEnable(GL_LINE_SMOOTH);
    103         glBegin(GL_LINE_STRIP);
    104 
    105         for (int i=0; i<=smoothness; ++i)
    106         {
    107             //Find distorted time
    108             time = start*i / MaxDistance;
    109             CVector3D tmp = GetPosition(time);
    110             glVertex3f( tmp.X, tmp.Y, tmp.Z );
    111         }
    112         glEnd();
    113         glDisable(GL_LINE_SMOOTH);
    114         glLineWidth(1.0f);
    115     }
    116     else
    117     {
    118         smoothness /= 2;
    119         start = MaxDistance / smoothness;
    120         glEnable(GL_POINT_SMOOTH);
    121         glPointSize(3.0f);
    122         glBegin(GL_POINTS);
    123 
    124         for (int i=0; i<=smoothness; ++i)
    125         {
    126             //Find distorted time
    127             time = (this->*DistModePtr)(start*i / MaxDistance);
    128             CVector3D tmp = GetPosition(time);
    129             glVertex3f( tmp.X, tmp.Y, tmp.Z );
    130         }
    131         glColor3f(1.0f, 1.0f, 0.0f);    //yellow
    132 
    133         for ( size_t i=0; i<Node.size(); ++i )
    134             glVertex3f(Node[i].Position.X, Node[i].Position.Y, Node[i].Position.Z);
    135 
    136         glEnd();
    137         glPointSize(1.0f);
    138         glDisable(GL_POINT_SMOOTH);
    139     }
    140 
    141 #endif
    142 }
    143 
    144 void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation)
    145 {
    146     CCamera *Cam = g_Game->GetView()->GetCamera();
    147     t = (this->*DistModePtr)(t);
    148    
    149     CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
    150     CQuaternion start, end;
    151     start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
    152     end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
    153     start.Slerp(start, end, nodet);
    154     CVector3D pos = GetPosition(t);
    155     CQuaternion quat;
    156    
    157     Cam->m_Orientation.SetIdentity();
    158     Cam->m_Orientation.Rotate(start);
    159     Cam->m_Orientation.Translate(pos);
    160     Cam->UpdateFrustum();
    161 }
    162 
    163 //Distortion mode functions
    164 float CCinemaPath::EaseIn(float t) const
    165 {
    166     return (this->*DistStylePtr)(t);
    167 }
    168 float CCinemaPath::EaseOut(float t) const
    169 {
    170     return 1.0f - EaseIn(1.0f-t);
    171 }
    172 float CCinemaPath::EaseInOut(float t) const
    173 {
    174     if (t < m_Switch)
    175         return EaseIn(1.0f/m_Switch * t) * m_Switch;
    176     return EaseOut(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
    177 }
    178 float CCinemaPath::EaseOutIn(float t) const
    179 {
    180     if (t < m_Switch)
    181         return EaseOut(1.0f/m_Switch * t) * m_Switch;
    182     return EaseIn(1.0f/m_Switch * (t-m_Switch)) * m_Switch + m_Switch;
    183 }
    184 
    185 
    186 //Distortion style functions
    187 float CCinemaPath::EaseDefault(float t) const
    188 {
    189     return t;
    190 }
    191 float CCinemaPath::EaseGrowth(float t) const
    192 {
    193     return pow(t, m_Growth);
    194 }
    195 
    196 float CCinemaPath::EaseExpo(float t) const
    197 {
    198     if(t == 0)
    199         return t;
    200     return powf(m_Growth, 10*(t-1.0f));
    201 }
    202 float CCinemaPath::EaseCircle(float t) const
    203 {
    204      t = -(sqrt(1.0f - t*t) - 1.0f);
    205      if(m_GrowthCount > 1.0f)
    206      {
    207          m_GrowthCount--;
    208          return (this->*DistStylePtr)(t);
    209      }
    210      return t;
    211 }
    212 
    213 float CCinemaPath::EaseSine(float t) const
    214 {
    215      t = 1.0f - cos(t * (float)M_PI/2);
    216      if(m_GrowthCount > 1.0f)
    217      {
    218          m_GrowthCount--;
    219          return (this->*DistStylePtr)(t);
    220      }
    221      return t;
    222 }
    223 
    224 bool CCinemaPath::Validate()
    225 {
    226     if ( m_TimeElapsed <= GetDuration() && m_TimeElapsed >= 0.0f )
    227     {
    228         //Find current node and past "node time"
    229         float previousTime = 0.0f, cumulation = 0.0f;
    230         //Ignore the last node, since it is a blank (node time values are shifted down one from interface)
    231         for ( size_t i = 0; i < Node.size() - 1; ++i )
    232         {
    233             cumulation += Node[i].Distance;
    234             if ( m_TimeElapsed <= cumulation )
    235             {
    236                 m_PreviousNodeTime = previousTime;
    237                 m_PreviousRotation = Node[i].Rotation;
    238                 m_CurrentNode = i;  //We're moving toward this next node, so use its rotation
    239                 return true;
    240             }
    241             else
    242                 previousTime += Node[i].Distance;
    243         }
    244     }
    245     return false;
    246 }
    247 
    248 bool CCinemaPath::Play(const float deltaRealTime)
    249 {
    250     m_TimeElapsed += m_Timescale * deltaRealTime;
    251 
    252     if (!Validate())
    253     {
    254         m_TimeElapsed = 0.0f;
    255         return false;
    256     }
    257    
    258     MoveToPointAt( m_TimeElapsed / GetDuration(), GetNodeFraction(), m_PreviousRotation );
    259     return true;
    260 }
    261 
    262 
    263 CCinemaManager::CCinemaManager() : m_DrawCurrentSpline(false), m_Active(true), m_ValidCurrent(false)
    264 {
    265     m_CurrentPath = m_Paths.end();
    266 }
    267 
    268 void CCinemaManager::AddPath(CCinemaPath path, const CStrW& name)
    269 {
    270     ENSURE( m_Paths.find( name ) == m_Paths.end() );
    271     m_Paths[name] = path;
    272 }
    273 
    274 void CCinemaManager::QueuePath(const CStrW& name, bool queue )
    275 {
    276     if (!m_PathQueue.empty() && queue == false)
    277     {
    278         return;
    279     }
    280     else
    281     {
    282         ENSURE(HasTrack(name));
    283         m_PathQueue.push_back(m_Paths[name]);
    284     }
    285 }
    286 
    287 void CCinemaManager::OverridePath(const CStrW& name)
    288 {
    289     m_PathQueue.clear();
    290     ENSURE(HasTrack(name));
    291     m_PathQueue.push_back( m_Paths[name] );
    292 }
    293 
    294 void CCinemaManager::SetAllPaths( const std::map<CStrW, CCinemaPath>& paths)
    295 {
    296     CStrW name;
    297     m_Paths = paths;
    298 }
    299 void CCinemaManager::SetCurrentPath(const CStrW& name, bool current, bool drawLines)
    300 {
    301     if ( !HasTrack(name) )
    302         m_ValidCurrent = false;
    303     else
    304         m_ValidCurrent = true;
    305 
    306     m_CurrentPath = m_Paths.find(name);
    307     m_DrawCurrentSpline = current;
    308     m_DrawLines = drawLines;
    309     DrawSpline();
    310 }
    311 
    312 bool CCinemaManager::HasTrack(const CStrW& name) const
    313 {
    314     return m_Paths.find(name) != m_Paths.end();
    315 }
    316 
    317 void CCinemaManager::DrawSpline() const
    318 {
    319     if ( !(m_DrawCurrentSpline && m_ValidCurrent) )
    320         return;
    321     static const int smoothness = 200;
    322 
    323     m_CurrentPath->second.DrawSpline(CVector4D(0.f, 0.f, 1.f, 1.f), smoothness, m_DrawLines);
    324 }
    325 
    326 void CCinemaManager::MoveToPointAt(float time)
    327 {
    328     ENSURE(m_CurrentPath != m_Paths.end());
    329     StopPlaying();
    330 
    331     m_CurrentPath->second.m_TimeElapsed = time;
    332     if ( !m_CurrentPath->second.Validate() )
    333         return;
    334 
    335     m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
    336                 m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
    337                 m_CurrentPath->second.m_PreviousRotation );
    338 }
    339 
    340 bool CCinemaManager::Update(const float deltaRealTime)
    341 {
    342     if (!m_PathQueue.front().Play(deltaRealTime))
    343     {
    344         m_PathQueue.pop_front();
    345         return false;
    346     }
    347     return true;
    348 }
  • source/graphics/CinemaTrack.h

     
    1 /* Copyright (C) 2009 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 
    19 #ifndef INCLUDED_CINEMATRACK
    20 #define INCLUDED_CINEMATRACK
    21 
    22 #include <list>
    23 #include <map>
    24 #include "ps/CStr.h"
    25 #include "maths/NUSpline.h"
    26 
    27 /*
    28     desc: contains various functions used for cinematic camera paths
    29     See also: CinemaHandler.cpp, Cinematic.h/.cpp
    30 */
    31 
    32 class CVector3D;
    33 class CVector4D;
    34 class CCamera;
    35 
    36 //For loading data
    37 class CCinemaData
    38 {
    39 public:
    40     CCinemaData() : m_GrowthCount(0), m_Growth(0), m_Switch(0),
    41                     m_Mode(0), m_Style(0), m_Timescale(1) {}
    42     virtual ~CCinemaData() {}
    43    
    44     const CCinemaData* GetData() const { return this; }
    45    
    46     //Distortion variables
    47     mutable float m_GrowthCount;
    48     float m_Growth;
    49     float m_Switch;
    50     int m_Mode;
    51     int m_Style;
    52     float m_Timescale;  //a negative timescale results in backwards play
    53 
    54 };
    55 
    56 
    57 //Once the data is part of the path, it shouldn't be changeable, so use private inheritance.
    58 //This class encompasses the spline and the information which determines how the path will operate
    59 //and also provides the functionality for doing so
    60 
    61 class CCinemaPath : private CCinemaData, public TNSpline
    62 {
    63 public:
    64     CCinemaPath() { m_TimeElapsed = 0.0f; m_PreviousNodeTime = 0.0f; }
    65     CCinemaPath(const CCinemaData& data, const TNSpline& spline);
    66     ~CCinemaPath() { DistStylePtr = NULL;  DistModePtr = NULL; }
    67    
    68     enum { EM_IN, EM_OUT, EM_INOUT, EM_OUTIN };
    69     enum { ES_DEFAULT, ES_GROWTH, ES_EXPO, ES_CIRCLE, ES_SINE };
    70    
    71     //sets camera position to calculated point on spline
    72     void MoveToPointAt(float t, float nodet, const CVector3D& );
    73    
    74     //Distortion mode functions-change how ratio is passed to distortion style functions
    75     float EaseIn(float t) const;
    76     float EaseOut(float t) const;
    77     float EaseInOut(float t) const;
    78     float EaseOutIn(float t) const;
    79 
    80     //Distortion style functions
    81     float EaseDefault(float t) const;
    82     float EaseGrowth(float t) const;
    83     float EaseExpo(float t) const;
    84     float EaseCircle(float t) const;
    85     float EaseSine(float t) const;
    86    
    87     float (CCinemaPath::*DistStylePtr)(float ratio) const;
    88     float (CCinemaPath::*DistModePtr)(float ratio) const;
    89 
    90     const CCinemaData* GetData() const { return CCinemaData::GetData(); }
    91 
    92 public:
    93 
    94     void DrawSpline(const CVector4D& RGBA, int smoothness, bool lines) const;
    95 
    96     inline CVector3D GetNodePosition(const int index) const { return Node[index].Position; }
    97     inline float GetNodeDuration(const int index) const { return Node[index].Distance; }
    98     inline float GetDuration() const { return MaxDistance; }
    99    
    100     inline float GetNodeFraction() const { return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance; }
    101     inline float GetElapsedTime() const { return m_TimeElapsed; }
    102 
    103     inline void SetTimescale(float scale) { m_Timescale = scale; }
    104    
    105     float m_TimeElapsed;
    106     float m_PreviousNodeTime;   //How much time has passed before the current node
    107    
    108     size_t m_CurrentNode;
    109     CVector3D m_PreviousRotation;
    110 
    111 public:
    112 
    113     /**
    114      * Returns false if finished.
    115      *
    116      * @param deltaRealTime Elapsed real time since the last frame.
    117      */
    118     bool Play(const float deltaRealTime);
    119     bool Validate();
    120 
    121     inline float GetTimescale() const { return m_Timescale; }   
    122 };
    123 
    124 //Class for in game playing of cinematics. Should only be instantiated in CGameView.
    125 class CCinemaManager
    126 {
    127 public:
    128     CCinemaManager();
    129     ~CCinemaManager() {}
    130 
    131     void AddPath(CCinemaPath path, const CStrW& name);
    132 
    133     //Adds track to list of being played.
    134     void QueuePath(const CStrW& name, bool queue);
    135     void OverridePath(const CStrW& name);   //clears track queue and replaces with 'name'
    136 
    137     /**
    138      * @param deltaRealTime Elapsed real time since the last frame.
    139      */
    140     bool Update(const float deltaRealTime);
    141    
    142     //These stop track play, and accept time, not ratio of time
    143     void MoveToPointAt(float time);
    144 
    145     inline void StopPlaying() { m_PathQueue.clear(); }
    146     void DrawSpline() const;
    147    
    148     inline bool IsPlaying() const { return !m_PathQueue.empty(); }
    149     bool HasTrack(const CStrW& name) const;
    150     inline bool IsActive() const { return m_Active; }
    151     inline void SetActive(bool active) { m_Active=active; }
    152 
    153     inline const std::map<CStrW, CCinemaPath>& GetAllPaths() { return m_Paths; }
    154     void SetAllPaths( const std::map<CStrW, CCinemaPath>& tracks);
    155     void SetCurrentPath(const CStrW& name, bool current, bool lines);
    156 
    157 private:
    158    
    159     bool m_Active, m_DrawCurrentSpline, m_DrawLines, m_ValidCurrent;
    160     std::map<CStrW, CCinemaPath>::iterator m_CurrentPath;
    161     std::map<CStrW, CCinemaPath> m_Paths;
    162     std::list<CCinemaPath> m_PathQueue;
    163 };
    164 
    165 #endif
  • source/graphics/GameView.cpp

     
    2020#include "GameView.h"
    2121
    2222#include "graphics/Camera.h"
    23 #include "graphics/CinemaTrack.h"
     23#include "graphics/CinemaManager.h"
    2424#include "graphics/ColladaManager.h"
    2525#include "graphics/HFTracer.h"
    2626#include "graphics/LOSTexture.h"
     
    258258     */
    259259    CLightEnv CachedLightEnv;
    260260
    261     CCinemaManager TrackManager;
     261    CCinemaManager CinemaManager;
    262262
    263263    /**
    264264     * Entity for the camera to follow, or INVALID_ENTITY if none.
     
    395395
    396396CCinemaManager* CGameView::GetCinema()
    397397{
    398     return &m->TrackManager;
     398    return &m->CinemaManager;
    399399};
    400400
    401401CLOSTexture& CGameView::GetLOSTexture()
     
    626626    if (!g_app_has_focus)
    627627        return;
    628628
    629     if (m->TrackManager.IsActive() && m->TrackManager.IsPlaying())
     629    if (m->CinemaManager.IsActive())
    630630    {
    631         if (! m->TrackManager.Update(deltaRealTime))
    632         {
    633 //          ResetCamera();
    634         }
     631        m->CinemaManager.Update(deltaRealTime);
    635632        return;
    636633    }
    637634
  • source/graphics/MapReader.cpp

     
    2020#include "MapReader.h"
    2121
    2222#include "graphics/Camera.h"
    23 #include "graphics/CinemaTrack.h"
     23#include "graphics/CinemaManager.h"
    2424#include "graphics/Entity.h"
    2525#include "graphics/GameView.h"
    2626#include "graphics/MapGenerator.h"
     
    5555CMapReader::CMapReader()
    5656    : xml_reader(0), m_PatchesPerSide(0), m_MapGen(0)
    5757{
    58     cur_terrain_tex = 0;    // important - resets generator state
     58    cur_terrain_tex = 0;    // important - resets generator state
    5959
    6060    // Maps that don't override the default probably want the old lighting model
    6161    //m_LightEnv.SetLightingModel("old");
     
    215215{
    216216    // now unpack everything into local data
    217217    int ret = UnpackTerrain();
    218     if (ret != 0)   // failed or timed out
     218    if (ret != 0)   // failed or timed out
    219219    {
    220220        return ret;
    221221    }
     
    224224}
    225225
    226226// UnpackTerrain: unpack the terrain from the end of the input data stream
    227 //      - data: map size, heightmap, list of textures used by map, texture tile assignments
     227//      - data: map size, heightmap, list of textures used by map, texture tile assignments
    228228int CMapReader::UnpackTerrain()
    229229{
    230230    // yield after this time is reached. balances increased progress bar
     
    292292            for (ssize_t i=0; i<m_PatchesPerSide; i++) {
    293293                for (ssize_t m=0; m<PATCH_SIZE; m++) {
    294294                    for (ssize_t k=0; k<PATCH_SIZE; k++) {
    295                         CMiniPatch& mp = pTerrain->GetPatch(i,j)->m_MiniPatches[m][k];  // can't fail
     295                        CMiniPatch& mp = pTerrain->GetPatch(i,j)->m_MiniPatches[m][k];  // can't fail
    296296
    297297                        mp.Tex = m_TerrainTextures[tileptr->m_Tex1Index];
    298298                        mp.Priority = tileptr->m_Priority;
     
    456456    void ReadTerrain(XMBElement parent);
    457457    void ReadEnvironment(XMBElement parent);
    458458    void ReadCamera(XMBElement parent);
    459     void ReadCinema(XMBElement parent);
     459    void ReadPaths(XMBElement parent);
    460460    void ReadTriggers(XMBElement parent);
    461461    int ReadEntities(XMBElement parent, double end_time);
    462462};
     
    573573    {
    574574        for (ssize_t px = 0; px < patches; ++px)
    575575        {
    576             CPatch* patch = m_MapReader.pTerrain->GetPatch(px, pz); // can't fail
     576            CPatch* patch = m_MapReader.pTerrain->GetPatch(px, pz); // can't fail
    577577
    578578            for (ssize_t z = 0; z < PATCH_SIZE; ++z)
    579579            {
     
    605605    EL(color);
    606606    EL(tint);
    607607    EL(height);
    608     EL(shininess);  // for compatibility
     608    EL(shininess);  // for compatibility
    609609    EL(waviness);
    610610    EL(murkiness);
    611611    EL(windangle);
    612     EL(reflectiontint); // for compatibility
    613     EL(reflectiontintstrength); // for compatibility
     612    EL(reflectiontint); // for compatibility
     613    EL(reflectiontintstrength); // for compatibility
    614614    EL(fog);
    615615    EL(fogcolor);
    616616    EL(fogfactor);
     
    839839    }
    840840}
    841841
    842 void CXMLReader::ReadCinema(XMBElement parent)
     842void CXMLReader::ReadPaths(XMBElement parent)
    843843{
    844844    #define EL(x) int el_##x = xmb_file.GetElementID(#x)
    845845    #define AT(x) int at_##x = xmb_file.GetAttributeID(#x)
     
    849849    EL(distortion);
    850850    EL(node);
    851851    EL(position);
    852     EL(time);
     852    EL(target);
    853853    AT(name);
    854854    AT(timescale);
     855    AT(orientation);
    855856    AT(mode);
    856857    AT(style);
    857858    AT(growth);
     
    859860    AT(x);
    860861    AT(y);
    861862    AT(z);
     863    AT(deltatime);
    862864
    863865#undef EL
    864866#undef AT
    865    
    866     std::map<CStrW, CCinemaPath> pathList;
     867
    867868    XERO_ITER_EL(parent, element)
    868869    {
    869870        int elementName = element.GetNodeName();
    870            
    871         if ( elementName == el_path )
     871        if (elementName == el_path)
    872872        {
     873            CCinemaData pathData;
    873874            XMBAttributeList attrs = element.GetAttributes();
    874             CStrW name(attrs.GetNamedItem(at_name).FromUTF8());
    875             float timescale = attrs.GetNamedItem(at_timescale).ToFloat();
    876             CCinemaData pathData;
    877             pathData.m_Timescale = timescale;
    878             TNSpline spline, backwardSpline;
     875            CStrW pathName(attrs.GetNamedItem(at_name).FromUTF8());
     876            pathData.m_Timescale = attrs.GetNamedItem(at_timescale).ToFloat();
     877            TNSpline pathSpline, targetSpline;
     878            float lastTargetTime = 0;
     879           
     880            pathData.m_Name = pathName;
     881            pathData.m_Orientation = attrs.GetNamedItem(at_orientation).FromUTF8();
     882            pathData.m_Mode = attrs.GetNamedItem(at_mode).FromUTF8();
     883            pathData.m_Style = attrs.GetNamedItem(at_style).FromUTF8();
    879884
    880885            XERO_ITER_EL(element, pathChild)
    881886            {
    882887                elementName = pathChild.GetNodeName();
    883888                attrs = pathChild.GetAttributes();
    884 
    885                 //Load distortion attributes
    886                 if ( elementName == el_distortion )
    887                 {
    888                         pathData.m_Mode = attrs.GetNamedItem(at_mode).ToInt();
    889                         pathData.m_Style = attrs.GetNamedItem(at_style).ToInt();
    890                         pathData.m_Growth = attrs.GetNamedItem(at_growth).ToInt();
    891                         pathData.m_Switch = attrs.GetNamedItem(at_switch).ToInt();
    892                 }
    893889               
    894                 //Load node data used for spline
    895                 else if ( elementName == el_node )
     890                // Load node data used for spline
     891                if (elementName == el_node)
    896892                {
    897893                    SplineData data;
     894                    data.Distance = pathChild.GetAttributes().GetNamedItem(at_deltatime).ToFloat();
     895                    lastTargetTime += pathChild.GetAttributes().GetNamedItem(at_deltatime).ToFloat();
    898896                    XERO_ITER_EL(pathChild, nodeChild)
    899897                    {
    900898                        elementName = nodeChild.GetNodeName();
    901899                        attrs = nodeChild.GetAttributes();
    902                        
    903                         //Fix?:  assumes that time is last element
    904                         if ( elementName == el_position )
     900                        if (elementName == el_position)
    905901                        {
    906902                            data.Position.X = attrs.GetNamedItem(at_x).ToFloat();
    907903                            data.Position.Y = attrs.GetNamedItem(at_y).ToFloat();
    908904                            data.Position.Z = attrs.GetNamedItem(at_z).ToFloat();
    909                             continue;
    910905                        }
    911                         else if ( elementName == el_rotation )
     906                        else if (elementName == el_rotation)
    912907                        {
    913908                            data.Rotation.X = attrs.GetNamedItem(at_x).ToFloat();
    914909                            data.Rotation.Y = attrs.GetNamedItem(at_y).ToFloat();
    915910                            data.Rotation.Z = attrs.GetNamedItem(at_z).ToFloat();
    916                             continue;
    917911                        }
    918                         else if ( elementName == el_time )
    919                             data.Distance = nodeChild.GetText().ToFloat();
     912                        else if (elementName == el_target)
     913                        {
     914                            CVector3D targetPosition;
     915                            targetPosition.X = attrs.GetNamedItem(at_x).ToFloat();
     916                            targetPosition.Y = attrs.GetNamedItem(at_y).ToFloat();
     917                            targetPosition.Z = attrs.GetNamedItem(at_z).ToFloat();
     918
     919                            targetSpline.AddNode(targetPosition, CVector3D(), lastTargetTime);
     920                            lastTargetTime = 0;
     921                        }
    920922                        else
    921                             debug_warn(L"Invalid cinematic element for node child");
    922                    
    923                         backwardSpline.AddNode(data.Position, data.Rotation, data.Distance);
     923                            LOGWARNING("Invalid cinematic element for node child");
    924924                    }
     925                    pathSpline.AddNode(data.Position, data.Rotation, data.Distance);
    925926                }
    926927                else
    927                     debug_warn(L"Invalid cinematic element for path child");
    928                
    929                
     928                    LOGWARNING("Invalid cinematic element for path child");
    930929            }
    931930
    932             //Construct cinema path with data gathered
    933             CCinemaPath temp(pathData, backwardSpline);
    934             const std::vector<SplineData>& nodes = temp.GetAllNodes();
    935             if ( nodes.empty() )
     931            // Construct cinema path with data gathered
     932            CCinemaPath path(pathData, pathSpline, targetSpline);
     933            if (path.Empty())
    936934            {
    937                 debug_warn(L"Failure loading cinematics");
     935                LOGWARNING("Path with name '%s' is empty", pathName.ToUTF8());
    938936                return;
    939937            }
    940                    
    941             for ( std::vector<SplineData>::const_reverse_iterator it = nodes.rbegin();
    942                                                             it != nodes.rend(); ++it )
    943             {
    944                 spline.AddNode(it->Position, it->Rotation, it->Distance);
    945             }
    946                
    947             CCinemaPath path(pathData, spline);
    948             pathList[name] = path; 
     938
     939            if (!m_MapReader.pCinema->HasPath(pathName))
     940                m_MapReader.pCinema->AddPath(pathName, path);
     941            else
     942                LOGWARNING("Path with name '%s' already exists", pathName.ToUTF8());
    949943        }
    950944        else
    951             ENSURE("Invalid cinema child");
     945            LOGWARNING("Invalid path child with name '%s'", element.GetText());
    952946    }
    953 
    954     if (m_MapReader.pCinema)
    955         m_MapReader.pCinema->SetAllPaths(pathList);
    956947}
    957948
    958949void CXMLReader::ReadTriggers(XMBElement UNUSED(parent))
     
    10481039        entity_id_t ent = sim.AddEntity(TemplateName, EntityUid);
    10491040        entity_id_t player = cmpPlayerManager->GetPlayerByID(PlayerID);
    10501041        if (ent == INVALID_ENTITY || player == INVALID_ENTITY)
    1051         {   // Don't add entities with invalid player IDs
     1042        {   // Don't add entities with invalid player IDs
    10521043            LOGERROR("Failed to load entity template '%s'", utf8_from_wstring(TemplateName));
    10531044        }
    10541045        else
     
    11251116        }
    11261117        else if (name == "Paths")
    11271118        {
    1128             ReadCinema(node);
     1119            ReadPaths(node);
    11291120        }
    11301121        else if (name == "Triggers")
    11311122        {
     
    11611152            if (!m_MapReader.m_SkipEntities)
    11621153            {
    11631154                ret = ReadEntities(node, end_time);
    1164                 if (ret != 0)   // error or timed out
     1155                if (ret != 0)   // error or timed out
    11651156                    return ret;
    11661157            }
    11671158        }
     
    13231314    JSAutoRequest rq(cx);
    13241315   
    13251316    // parse terrain from map data
    1326     //  an error here should stop the loading process
     1317    //  an error here should stop the loading process
    13271318#define GET_TERRAIN_PROPERTY(val, prop, out)\
    13281319    if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\
    1329         {   LOGERROR("CMapReader::ParseTerrain() failed to get '%s' property", #prop);\
     1320        {   LOGERROR("CMapReader::ParseTerrain() failed to get '%s' property", #prop);\
    13301321            throw PSERROR_Game_World_MapLoadFailed("Error parsing terrain data.\nCheck application log for details"); }
    13311322
    13321323    u32 size;
     
    14201411        entity_id_t ent = pSimulation2->AddEntity(currEnt.templateName, currEnt.entityID);
    14211412        entity_id_t player = cmpPlayerManager->GetPlayerByID(currEnt.playerID);
    14221413        if (ent == INVALID_ENTITY || player == INVALID_ENTITY)
    1423         {   // Don't add entities with invalid player IDs
     1414        {   // Don't add entities with invalid player IDs
    14241415            LOGERROR("Failed to load entity template '%s'", utf8_from_wstring(currEnt.templateName));
    14251416        }
    14261417        else
     
    15761567    GET_CAMERA_PROPERTY(m_MapData.get(), Camera, &cameraObj)
    15771568
    15781569    if (!cameraObj.isUndefined())
    1579     {   // If camera property exists, read values
     1570    {   // If camera property exists, read values
    15801571        CFixedVector3D pos;
    15811572        GET_CAMERA_PROPERTY(cameraObj, Position, pos)
    15821573        translation = pos;
  • source/graphics/MapReader.h

     
    7070
    7171    // UnpackTerrain: unpack the terrain from the input stream
    7272    int UnpackTerrain();
    73     //UnpackCinema: unpack the cinematic tracks from the input stream
     73    // UnpackCinema: unpack the cinematic tracks from the input stream
    7474    int UnpackCinema();
    7575
    7676    // UnpackMap: unpack the given data from the raw data stream into local variables
  • source/graphics/MapWriter.cpp

     
    1818#include "precompiled.h"
    1919
    2020#include "Camera.h"
    21 #include "CinemaTrack.h"
     21#include "CinemaManager.h"
    2222#include "GameView.h"
    2323#include "LightEnv.h"
    2424#include "MapReader.h"
     
    8484// handle isn't in list
    8585static u16 GetEntryIndex(const CTerrainTextureEntry* entry, const std::vector<CTerrainTextureEntry*>& entries)
    8686{
    87     const size_t limit = std::min(entries.size(), size_t(0xFFFEu)); // paranoia
     87    const size_t limit = std::min(entries.size(), size_t(0xFFFEu)); // paranoia
    8888    for (size_t i=0;i<limit;i++) {
    8989        if (entries[i]==entry) {
    9090            return (u16)i;
     
    114114        for (ssize_t i=0;i<patchesPerSide;i++) {
    115115            for (ssize_t m=0;m<PATCH_SIZE;m++) {
    116116                for (ssize_t k=0;k<PATCH_SIZE;k++) {
    117                     CMiniPatch& mp=pTerrain->GetPatch(i,j)->m_MiniPatches[m][k];    // can't fail
     117                    CMiniPatch& mp=pTerrain->GetPatch(i,j)->m_MiniPatches[m][k];    // can't fail
    118118                    u16 index=u16(GetEntryIndex(mp.GetTextureEntry(),entries));
    119119                    if (index==0xFFFF) {
    120120                        index=(u16)entries.size();
     
    154154
    155155///////////////////////////////////////////////////////////////////////////////////////////////////
    156156// PackTerrain: pack the terrain onto the end of the output data stream
    157 //      - data: map size, heightmap, list of textures used by map, texture tile assignments
     157//      - data: map size, heightmap, list of textures used by map, texture tile assignments
    158158void CMapWriter::PackTerrain(CFilePacker& packer, CTerrain* pTerrain)
    159159{
    160160    // pack map size
     
    162162    packer.PackSize(mapsize);
    163163   
    164164    // pack heightmap
    165     packer.PackRaw(pTerrain->GetHeightMap(),sizeof(u16)*SQR(pTerrain->GetVerticesPerSide()));   
     165    packer.PackRaw(pTerrain->GetHeightMap(),sizeof(u16)*SQR(pTerrain->GetVerticesPerSide()));   
    166166
    167167    // the list of textures used by map
    168168    std::vector<CStr> terrainTextures;
     
    408408
    409409            for ( ; it != paths.end(); ++it )
    410410            {
    411                 CStrW name = it->first;
    412411                float timescale = it->second.GetTimescale();
     412                const std::vector<SplineData>& nodes = it->second.GetAllNodes();
     413                const CCinemaData* data = it->second.GetData();
    413414               
    414415                XML_Element("Path");
    415                 XML_Attribute("name", name);
     416                XML_Attribute("name", data->m_Name);
    416417                XML_Attribute("timescale", timescale);
     418                XML_Attribute("orientation", data->m_Orientation);
     419                XML_Attribute("mode", data->m_Mode);
     420                XML_Attribute("style", data->m_Style);
    417421
    418                 const std::vector<SplineData>& nodes = it->second.GetAllNodes();
    419                 const CCinemaData* data = it->second.GetData();
    420                
     422                for (size_t j = 0; j < nodes.size(); ++j)
    421423                {
    422                     XML_Element("Distortion");
    423                     XML_Attribute("mode", data->m_Mode);
    424                     XML_Attribute("style", data->m_Style);
    425                     XML_Attribute("growth", data->m_Growth);
    426                     XML_Attribute("switch", data->m_Switch);
    427                 }
    428 
    429                 for ( ssize_t j=nodes.size()-1; j >= 0; --j )
    430                 {
    431424                    XML_Element("Node");
     425                    if (j > 0)
     426                        XML_Attribute("deltatime", nodes[j - 1].Distance);
     427                    else
     428                        XML_Attribute("deltatime", 0.0f);
    432429                   
    433430                    {
    434431                        XML_Element("Position");
     
    443440                        XML_Attribute("y", nodes[j].Rotation.Y);
    444441                        XML_Attribute("z", nodes[j].Rotation.Z);
    445442                    }
    446 
    447                     XML_Setting("Time", nodes[j].Distance);
    448443                }
    449444            }
    450445        }
  • source/maths/NUSpline.cpp

     
    1 /* Copyright (C) 2009 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    4848// adds node and updates segment length
    4949void RNSpline::AddNode(const CVector3D &pos)
    5050{
    51   if ( NodeCount >= MAX_SPLINE_NODES )
    52       return;
    53   if (NodeCount == 0)
    54     MaxDistance = 0.f;
    55   else
    56   {
    57     Node[NodeCount-1].Distance = (Node[NodeCount-1].Position - pos).Length();
    58     MaxDistance += Node[NodeCount-1].Distance;
    59   }
    60   SplineData temp;
    61   temp.Position = pos;
    62   Node.push_back(temp);
    63   NodeCount++;
     51    if (NodeCount >= MAX_SPLINE_NODES)
     52        return;
     53    if (NodeCount == 0)
     54        MaxDistance = 0.f;
     55    else
     56    {
     57        Node[NodeCount - 1].Distance = (Node[NodeCount - 1].Position - pos).Length();
     58        MaxDistance += Node[NodeCount - 1].Distance;
     59    }
     60    SplineData temp;
     61    temp.Position = pos;
     62    Node.push_back(temp);
     63    NodeCount++;
    6464}
    6565
    6666
     
    6767// called after all nodes added. This function calculates the node velocities
    6868void RNSpline::BuildSpline()
    6969{
    70   if ( NodeCount == 2 )
    71   {
    72       Node[0].Velocity = GetStartVelocity(0);
    73       Node[NodeCount-1].Velocity = GetEndVelocity(NodeCount-1);
    74       return;
    75   }
    76   else if ( NodeCount < 2 )
    77       return;
    78  
    79   for (int i = 1; i<NodeCount-1; i++)
    80   {
    81     CVector3D Next = Node[i+1].Position - Node[i].Position;
    82     CVector3D Previous = Node[i-1].Position - Node[i].Position;
    83     Next.Normalize();
    84     Previous.Normalize();
    85      
    86     // split the angle (figure 4)
    87     Node[i].Velocity = Next - Previous;
    88     Node[i].Velocity.Normalize();
    89   }
    90   // calculate start and end velocities
    91   Node[0].Velocity = GetStartVelocity(0);
    92   Node[NodeCount-1].Velocity = GetEndVelocity(NodeCount-1);
     70    if (NodeCount == 2)
     71    {
     72        Node[0].Velocity = GetStartVelocity(0);
     73        Node[NodeCount - 1].Velocity = GetEndVelocity(NodeCount - 1);
     74        return;
     75    }
     76    else if (NodeCount < 2)
     77        return;
     78
     79    for (int i = 1; i < NodeCount - 1; ++i)
     80    {
     81        CVector3D Next = Node[i + 1].Position - Node[i].Position;
     82        CVector3D Previous = Node[i - 1].Position - Node[i].Position;
     83        Next.Normalize();
     84        Previous.Normalize();
     85
     86        // split the angle (figure 4)
     87        Node[i].Velocity = Next - Previous;
     88        Node[i].Velocity.Normalize();
     89    }
     90    // calculate start and end velocities
     91    Node[0].Velocity = GetStartVelocity(0);
     92    Node[NodeCount - 1].Velocity = GetEndVelocity(NodeCount - 1);
    9393}
    9494
    9595// spline access function. time is 0 -> 1
    9696CVector3D RNSpline::GetPosition(float time) const
    9797{
    98   if ( NodeCount < 2 )
    99       return CVector3D(0.0f, 0.0f, 0.0f);
    100   if ( time > 1.0f )
     98    if (NodeCount < 2)
     99        return CVector3D(0.0f, 0.0f, 0.0f);
     100    if (time > 1.0f)
    101101        time = 1.0f;
    102   float Distance = time * MaxDistance;
    103   float CurrentDistance = 0.f;
    104   int i = 0;
    105  
    106   //Find which node we're on
    107   while (CurrentDistance + Node[i].Distance < Distance
    108     && i < NodeCount - 2)
    109   {
    110     CurrentDistance += Node[i].Distance;
    111     i++;
    112   }
    113   ENSURE( i < NodeCount - 1 );
    114   float t = Distance - CurrentDistance;
    115   t /= Node[i].Distance; // scale t in range 0 - 1
    116   CVector3D startVel = Node[i].Velocity * Node[i].Distance;
    117   CVector3D endVel = Node[i+1].Velocity * Node[i].Distance;   
    118   return GetPositionOnCubic(Node[i].Position, startVel,
    119                          Node[i+1].Position, endVel, t);
     102    float Distance = time * MaxDistance;
     103    float CurrentDistance = 0.f;
     104    int i = 0;
     105
     106    //Find which node we're on
     107    while (CurrentDistance + Node[i].Distance < Distance
     108        && i < NodeCount - 2)
     109    {
     110        CurrentDistance += Node[i].Distance;
     111        ++i;
     112    }
     113    ENSURE(i < NodeCount - 1);
     114    float t = Distance - CurrentDistance;
     115    t /= Node[i].Distance; // scale t in range 0 - 1
     116    CVector3D startVel = Node[i].Velocity * Node[i].Distance;
     117    CVector3D endVel = Node[i + 1].Velocity * Node[i].Distance;
     118    return GetPositionOnCubic(Node[i].Position, startVel,
     119        Node[i + 1].Position, endVel, t);
    120120}
    121121
    122122// internal. Based on Equation 14
    123123CVector3D RNSpline::GetStartVelocity(int index)
    124124{
    125   if ( index >= NodeCount - 1 || index < 0)
    126       return CVector3D(0.0f, 0.0f, 0.0f);
    127   CVector3D temp = (Node[index+1].Position - Node[index].Position) * 3.0f * ( 1.0f / Node[index].Distance) ;
    128   return (temp - Node[index+1].Velocity)*0.5f;
     125    if (index >= NodeCount - 1 || index < 0)
     126        return CVector3D(0.0f, 0.0f, 0.0f);
     127    CVector3D temp = (Node[index + 1].Position - Node[index].Position) * 3.0f * (1.0f / Node[index].Distance);
     128    return (temp - Node[index + 1].Velocity)*0.5f;
    129129}
    130130
    131131// internal. Based on Equation 15
    132132CVector3D RNSpline::GetEndVelocity(int index)
    133133{
    134   if ( index >= NodeCount || index < 1)
    135       return CVector3D(0.0f, 0.0f, 0.0f);
    136   CVector3D temp = (Node[index].Position - Node[index-1].Position) * 3.0f * (1.0f / Node[index-1].Distance);
    137   return (temp - Node[index-1].Velocity) * 0.5f;
     134    if (index >= NodeCount || index < 1)
     135        return CVector3D(0.0f, 0.0f, 0.0f);
     136    CVector3D temp = (Node[index].Position - Node[index - 1].Position) * 3.0f * (1.0f / Node[index - 1].Distance);
     137    return (temp - Node[index - 1].Velocity) * 0.5f;
    138138}
    139139
    140140/*********************************** S N S **************************************************/
     
    142142// smoothing filter.
    143143void SNSpline::Smooth()
    144144{
    145   if ( NodeCount < 3 )
    146       return;
    147   CVector3D newVel;
    148   CVector3D oldVel = GetStartVelocity(0);
    149   for (int i = 1; i<NodeCount-1; i++)
    150   {
    151     // Equation 12
    152     newVel = GetEndVelocity(i) * Node[i].Distance +
    153              GetStartVelocity(i) * Node[i-1].Distance;
    154     newVel = newVel * ( 1 / (Node[i-1].Distance + Node[i].Distance) );
    155     Node[i-1].Velocity = oldVel;
    156     oldVel = newVel;
    157   }
    158   Node[NodeCount-1].Velocity = GetEndVelocity(NodeCount-1);
    159   Node[NodeCount-2].Velocity = oldVel;
     145    if (NodeCount < 3)
     146        return;
     147    CVector3D newVel;
     148    CVector3D oldVel = GetStartVelocity(0);
     149    for (int i = 1; i < NodeCount - 1; ++i)
     150    {
     151        // Equation 12
     152        newVel = GetEndVelocity(i) * Node[i].Distance +
     153            GetStartVelocity(i) * Node[i - 1].Distance;
     154        newVel = newVel * (1 / (Node[i - 1].Distance + Node[i].Distance));
     155        Node[i - 1].Velocity = oldVel;
     156        oldVel = newVel;
     157    }
     158    Node[NodeCount - 1].Velocity = GetEndVelocity(NodeCount - 1);
     159    Node[NodeCount - 2].Velocity = oldVel;
    160160}
    161161
    162162/*********************************** T N S **************************************************/
     
    165165// ie time period is time from last node to this node
    166166void TNSpline::AddNode(const CVector3D &pos, const CVector3D& rotation, float timePeriod)
    167167{
    168   if ( NodeCount >= MAX_SPLINE_NODES )
    169       return;
    170   if (NodeCount == 0)
    171      MaxDistance = 0.f;
    172   else
    173   {
    174     Node[NodeCount-1].Distance = timePeriod;
    175     MaxDistance += Node[NodeCount-1].Distance;
    176   }
     168    if (NodeCount >= MAX_SPLINE_NODES)
     169        return;
     170    if (NodeCount == 0)
     171        MaxDistance = 0.f;
     172    else
     173    {
     174        Node[NodeCount - 1].Distance = timePeriod;
     175        MaxDistance += Node[NodeCount - 1].Distance;
     176    }
    177177
    178   SplineData temp;
    179   temp.Position = pos;
     178    SplineData temp;
     179    temp.Position = pos;
    180180
    181   //make sure we don't end up using undefined numbers...
    182   temp.Distance = 0.0f;
    183   temp.Velocity = CVector3D( 0.0f, 0.0f, 0.0f );
    184   temp.Rotation = rotation;
    185   Node.push_back(temp);
    186   NodeCount++;
     181    //make sure we don't end up using undefined numbers...
     182    temp.Distance = 0.0f;
     183    temp.Velocity = CVector3D(0.0f, 0.0f, 0.0f);
     184    temp.Rotation = rotation;
     185    Node.push_back(temp);
     186    NodeCount++;
    187187}
    188188
    189189//Inserts node before position
    190190void TNSpline::InsertNode(const int index, const CVector3D &pos, const CVector3D& rotation, float timePeriod)
    191191{
    192   if ( NodeCount >= MAX_SPLINE_NODES || index < NodeCount - 1  )
    193       return;
    194   if (NodeCount == 0)
    195       MaxDistance = 0.f;
    196   else
    197   {
    198     Node[NodeCount-1].Distance = timePeriod;
    199     Node[NodeCount-1].Rotation = rotation;
    200     MaxDistance += Node[NodeCount-1].Distance;
    201   }
    202   SplineData temp;
    203   temp.Position = pos;
    204   Node.insert(Node.begin() + index, temp);
    205   NodeCount++;
     192    if (NodeCount >= MAX_SPLINE_NODES || index < NodeCount - 1)
     193        return;
     194    if (NodeCount == 0)
     195        MaxDistance = 0.f;
     196    else
     197    {
     198        Node[NodeCount - 1].Distance = timePeriod;
     199        Node[NodeCount - 1].Rotation = rotation;
     200        MaxDistance += Node[NodeCount - 1].Distance;
     201    }
     202    SplineData temp;
     203    temp.Position = pos;
     204    Node.insert(Node.begin() + index, temp);
     205    NodeCount++;
    206206}
    207207//Removes node at index
    208208void TNSpline::RemoveNode(const int index)
    209209{
    210   if (NodeCount == 0 || index > NodeCount - 1 )
    211   {
    212      return;
    213   }
    214   else
    215   {
    216       MaxDistance -= Node[index].Distance;
    217       MaxDistance -= Node[index-1].Distance;
    218       Node[index-1].Distance = 0.0f;
    219       Node.erase( Node.begin() + index, Node.begin() + index + 1 );
    220   }
    221   NodeCount--;
     210    if (NodeCount == 0 || index > NodeCount - 1)
     211    {
     212        return;
     213    }
     214    else
     215    {
     216        MaxDistance -= Node[index].Distance;
     217        MaxDistance -= Node[index - 1].Distance;
     218        Node[index - 1].Distance = 0.0f;
     219        Node.erase(Node.begin() + index, Node.begin() + index + 1);
     220    }
     221    NodeCount--;
    222222}
    223223void TNSpline::UpdateNodeTime(const int index, float time)
    224224{
     
    238238}
    239239void TNSpline::Constrain()
    240240{
    241   if ( NodeCount < 3 )
    242       return;
    243   for (int i = 1; i<NodeCount-1; i++)
    244   {
    245     // Equation 13
    246     float r0 = (Node[i].Position-Node[i-1].Position).Length() / Node[i-1].Distance;
    247     float r1 = (Node[i+1].Position - Node[i].Position).Length() / Node[i].Distance;
    248     Node[i].Velocity *= 4.0f*r0*r1/((r0+r1)*(r0+r1));
    249   }
     241    if (NodeCount < 3)
     242        return;
     243    for (int i = 1; i < NodeCount - 1; ++i)
     244    {
     245        // Equation 13
     246        float r0 = (Node[i].Position - Node[i - 1].Position).Length() / Node[i - 1].Distance;
     247        float r1 = (Node[i + 1].Position - Node[i].Position).Length() / Node[i].Distance;
     248        Node[i].Velocity *= 4.0f*r0*r1 / ((r0 + r1)*(r0 + r1));
     249    }
    250250}
    251251
  • source/maths/NUSpline.h

     
    2222#ifndef INCLUDED_NUSPLINE
    2323#define INCLUDED_NUSPLINE
    2424
     25// TODO: why not bigger?
    2526#define MAX_SPLINE_NODES 40
    2627#include <stdlib.h>
    2728#include "Vector3D.h"
  • source/ps/GameSetup/GameSetup.cpp

     
    3535#include "lib/sysdep/os/win/wversion.h"
    3636#endif
    3737
    38 #include "graphics/CinemaTrack.h"
     38#include "graphics/CinemaManager.h"
    3939#include "graphics/FontMetrics.h"
    4040#include "graphics/GameView.h"
    4141#include "graphics/LightEnv.h"
     
    226226
    227227    ogl_WarnIfError();
    228228
     229    if (g_Game && g_Game->IsGameStarted())
     230        g_Game->GetView()->GetCinema()->Render();
     231
     232    ogl_WarnIfError();
     233
    229234    g_Renderer.RenderTextOverlays();
    230235
    231236    if (g_DoRenderGui)
  • source/simulation2/components/CCmpCinemaManager.cpp

     
     1/* Copyright (C) 2015 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#include "precompiled.h"
     19
     20#include "simulation2/system/Component.h"
     21#include "ICmpCinemaManager.h"
     22
     23#include "graphics/GameView.h"
     24#include "graphics/CinemaManager.h"
     25#include "ps/CLogger.h"
     26#include "ps/Game.h"
     27#include "simulation2/MessageTypes.h"
     28
     29
     30class CCmpCinemaManager : public ICmpCinemaManager
     31{
     32public:
     33    static void ClassInit(CComponentManager& componentManager)
     34    {
     35        componentManager.SubscribeToMessageType(MT_CinemaPathEnded);
     36    }
     37
     38    DEFAULT_COMPONENT_ALLOCATOR(CinemaManager)
     39
     40    static std::string GetSchema()
     41    {
     42        return "<a:component type='system'/><empty/>";
     43    }
     44
     45    virtual void Init(const CParamNode& UNUSED(paramNode))
     46    {
     47        // ...
     48    }
     49
     50    virtual void Deinit()
     51    {
     52        // ...
     53    }
     54
     55    virtual void Serialize(ISerializer& UNUSED(serialize))
     56    {
     57        // ...
     58    }
     59
     60    virtual void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& UNUSED(deserialize))
     61    {
     62        // ...
     63    }
     64
     65    virtual void HandleMessage(const CMessage& msg, bool UNUSED(global))
     66    {
     67        switch (msg.GetType())
     68        {
     69        case MT_CinemaPathEnded:
     70        {
     71            const CMessageCinemaPathEnded& msgData = static_cast<const CMessageCinemaPathEnded&> (msg);
     72            // TODO: send more msg to trigger
     73            break;
     74        }
     75        }
     76    }
     77
     78    virtual void AddCinemaPathToQueue(CStrW name)
     79    {
     80        if (!g_Game || !g_Game->GetView())
     81        {
     82            LOGERROR("Trying to add cinema path when GameView isn't initialized!");
     83            return;
     84        }
     85        g_Game->GetView()->GetCinema()->AddPathToQueue(name);
     86    }
     87
     88    virtual void Play()
     89    {
     90        if (!g_Game || !g_Game->GetView())
     91        {
     92            LOGERROR("Trying to add cinema path when GameView isn't initialized!");
     93            return;
     94        }
     95        g_Game->GetView()->GetCinema()->Play();
     96    }
     97
     98    virtual void Pause()
     99    {
     100        if (!g_Game || !g_Game->GetView())
     101        {
     102            LOGERROR("Trying to add cinema path when GameView isn't initialized!");
     103            return;
     104        }
     105        g_Game->GetView()->GetCinema()->Pause();
     106    }
     107
     108    virtual void Stop()
     109    {
     110        if (!g_Game || !g_Game->GetView())
     111        {
     112            LOGERROR("Trying to add cinema path when GameView isn't initialized!");
     113            return;
     114        }
     115        g_Game->GetView()->GetCinema()->Stop();
     116    }
     117};
     118
     119REGISTER_COMPONENT_TYPE(CinemaManager)
  • source/simulation2/components/CCmpOverlayRenderer.cpp

     
    166166
    167167    void RenderSubmit(SceneCollector& collector)
    168168    {
    169         if (!m_Enabled)
     169        if (!m_Enabled || !ICmpOverlayRenderer::m_OverrideVisible)
    170170            return;
    171171
    172172        for (size_t i = 0; i < m_Sprites.size(); ++i)
  • source/simulation2/components/CCmpSelectable.cpp

     
    587587void CCmpSelectable::RenderSubmit(SceneCollector& collector)
    588588{
    589589    // don't render selection overlay if it's not gonna be visible
     590    if (!ICmpSelectable::m_OverrideVisible)
     591        return;
     592
    590593    if (m_Visible && m_Color.a > 0)
    591594    {
    592595        if (!m_Cached)
  • source/simulation2/components/CCmpTerritoryManager.cpp

     
    124124        m_TriggerEvent = true;
    125125        m_EnableLineDebugOverlays = false;
    126126        m_DirtyID = 1;
     127        m_Visible = true;
    127128
    128129        m_AnimTime = 0.0;
    129130
     
    276277    void Interpolate(float frameTime, float frameOffset);
    277278
    278279    void RenderSubmit(SceneCollector& collector);
     280
     281    void SetVisibility(bool visible)
     282    {
     283        m_Visible = visible;
     284    }
     285
     286private:
     287
     288    bool m_Visible;
    279289};
    280290
    281291REGISTER_COMPONENT_TYPE(TerritoryManager)
     
    645655
    646656void CCmpTerritoryManager::RenderSubmit(SceneCollector& collector)
    647657{
     658    if (!m_Visible)
     659        return;
     660
    648661    for (size_t i = 0; i < m_BoundaryLines.size(); ++i)
    649662        collector.Submit(&m_BoundaryLines[i].overlay);
    650663   
  • source/simulation2/components/ICmpCinemaManager.cpp

     
     1/* Copyright (C) 2015 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#include "precompiled.h"
     19
     20#include "ICmpCinemaManager.h"
     21
     22#include "simulation2/system/InterfaceScripted.h"
     23
     24BEGIN_INTERFACE_WRAPPER(CinemaManager)
     25DEFINE_INTERFACE_METHOD_1("AddCinemaPathToQueue", void, ICmpCinemaManager, AddCinemaPathToQueue, CStrW)
     26DEFINE_INTERFACE_METHOD_0("Play", void, ICmpCinemaManager, Play)
     27DEFINE_INTERFACE_METHOD_0("Pause", void, ICmpCinemaManager, Pause)
     28DEFINE_INTERFACE_METHOD_0("Stop", void, ICmpCinemaManager, Stop)
     29END_INTERFACE_WRAPPER(CinemaManager)
     30 No newline at end of file
  • source/simulation2/components/ICmpCinemaManager.h

     
     1/* Copyright (C) 2015 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_ICMPCINEMAMANAGER
     19#define INCLUDED_ICMPCINEMAMANAGER
     20
     21#include "simulation2/system/Interface.h"
     22
     23#include "ps/CStr.h"
     24
     25/**
     26 * Component for CCinemaManager class
     27 * TODO: write description
     28 */
     29
     30class ICmpCinemaManager : public IComponent
     31{
     32public:
     33    // TODO: add path name and description
     34    virtual void AddCinemaPathToQueue(CStrW name) = 0;
     35   
     36    virtual void Play() = 0;
     37    virtual void Pause() = 0;
     38    virtual void Stop() = 0;
     39
     40    DECLARE_INTERFACE_TYPE(CinemaManager)
     41};
     42
     43#endif // INCLUDED_ICMPCINEMAMANAGER
     44 No newline at end of file
  • source/simulation2/components/ICmpOverlayRenderer.cpp

     
    2525DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpOverlayRenderer, Reset)
    2626DEFINE_INTERFACE_METHOD_5("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D, std::string)
    2727END_INTERFACE_WRAPPER(OverlayRenderer)
     28
     29bool ICmpOverlayRenderer::m_OverrideVisible = true;
     30 No newline at end of file
  • source/simulation2/components/ICmpOverlayRenderer.h

     
    5252     */
    5353    virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset, std::string color = "255 255 255 255") = 0;
    5454
     55    /**
     56    * Enables or disables rendering of all sprites.
     57    * @param visible Whether the selectable should be visible.
     58    */
     59    static void SetOverrideVisibility(bool visible)
     60    {
     61        ICmpOverlayRenderer::m_OverrideVisible = visible;
     62    }
     63
    5564    DECLARE_INTERFACE_TYPE(OverlayRenderer)
     65
     66protected:
     67    static bool m_OverrideVisible;
    5668};
    5769
    5870#endif // INCLUDED_ICMPOVERLAYRENDERER
  • source/simulation2/components/ICmpSelectable.cpp

     
    2828END_INTERFACE_WRAPPER(Selectable)
    2929
    3030bool ICmpSelectable::ms_EnableDebugOverlays = false;
     31bool ICmpSelectable::m_OverrideVisible = true;
  • source/simulation2/components/ICmpSelectable.h

     
    6767    virtual void SetVisibility(bool visible) = 0;
    6868
    6969    /**
     70    * Enables or disables rendering of all entities selectable.
     71    * @param visible Whether the selectable should be visible.
     72    */
     73    static void SetOverrideVisibility(bool visible)
     74    {
     75        ICmpSelectable::m_OverrideVisible = visible;
     76    }
     77
     78    /**
    7079     * Set the alpha of the selection highlight. Set to 0 to hide the highlight.
    7180     */
    7281    virtual void SetSelectionHighlightAlpha(float alpha) = 0;
     
    7786    // and methods, where we can keep settings like these. Note that any such data store would need to be per-component-manager
    7887    // and not entirely global, to support multiple simulation instances.
    7988    static bool ms_EnableDebugOverlays; // ms for member static
     89
     90protected:
     91    static bool m_OverrideVisible;
    8092};
    8193
    8294#endif // INCLUDED_ICMPSELECTABLE
  • source/simulation2/components/ICmpTerritoryManager.h

     
    7878     */
    7979     virtual u8 GetTerritoryPercentage(player_id_t player) = 0;
    8080
     81    /**
     82     * Enables or disables rendering of an territory borders.
     83     */
     84    virtual void SetVisibility(bool visible) = 0;
     85
    8186    DECLARE_INTERFACE_TYPE(TerritoryManager)
    8287};
    8388
  • source/simulation2/MessageTypes.h

     
    2929
    3030#include "maths/Vector3D.h"
    3131
     32#include "ps/CStr.h"
     33
    3234#define DEFAULT_MESSAGE_IMPL(name) \
    3335    virtual int GetType() const { return MT_##name; } \
    3436    virtual const char* GetScriptHandlerName() const { return "On" #name; } \
     
    538540    }
    539541};
    540542
     543/**
     544* Send when an path has ended
     545*/
     546
     547class CMessageCinemaPathEnded : public CMessage
     548{
     549public:
     550    DEFAULT_MESSAGE_IMPL(CinemaPathEnded)
     551
     552    CMessageCinemaPathEnded(CStrW name) :
     553    m_PathName(name)
     554    {
     555    }
     556
     557    CStrW m_PathName;
     558};
     559
    541560#endif // INCLUDED_MESSAGETYPES
  • source/simulation2/scripting/MessageTypeConversions.cpp

     
    470470    return new CMessageMinimapPing();
    471471}
    472472
     473////////////////////////////////
     474
     475jsval CMessageCinemaPathEnded::ToJSVal(ScriptInterface& scriptInterface) const
     476{
     477    TOJSVAL_SETUP();
     478    SET_MSG_PROPERTY(m_PathName);
     479    return OBJECT_TO_JSVAL(obj);
     480}
     481
     482CMessage* CMessageCinemaPathEnded::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
     483{
     484    FROMJSVAL_SETUP();
     485    GET_MSG_PROPERTY(CStrW, name);
     486    return new CMessageCinemaPathEnded(name);
     487}
     488
    473489////////////////////////////////////////////////////////////////
    474490
    475491CMessage* CMessageFromJSVal(int mtid, ScriptInterface& scriptingInterface, JS::HandleValue val)
  • source/simulation2/system/ComponentManager.cpp

     
    711711{
    712712    CParamNode noParam;
    713713    AddComponent(m_SystemEntity, CID_TemplateManager, noParam);
     714    AddComponent(m_SystemEntity, CID_CinemaManager, noParam);
    714715    AddComponent(m_SystemEntity, CID_CommandQueue, noParam);
    715716    AddComponent(m_SystemEntity, CID_ObstructionManager, noParam);
    716717    AddComponent(m_SystemEntity, CID_ParticleManager, noParam);
  • source/simulation2/TypeList.h

     
    5757MESSAGE(TemplateModification)
    5858MESSAGE(VisionRangeChanged)
    5959MESSAGE(MinimapPing)
     60MESSAGE(CinemaPathEnded)
    6061
    6162// TemplateManager must come before all other (non-test) components,
    6263// so that it is the first to be (de)serialized
     
    7576INTERFACE(AIManager)
    7677COMPONENT(AIManager)
    7778
     79INTERFACE(CinemaManager)
     80COMPONENT(CinemaManager)
     81
    7882INTERFACE(CommandQueue)
    7983COMPONENT(CommandQueue)
    8084
  • source/tools/atlas/GameInterface/Handlers/CameraCtrlHandlers.cpp

     
    2727#include "ps/Game.h"
    2828#include "renderer/Renderer.h"
    2929#include "graphics/GameView.h"
    30 #include "graphics/CinemaTrack.h"
     30#include "graphics/CinemaManager.h"
    3131
    3232#include "ps/World.h"
    3333#include "graphics/Terrain.h"
  • source/tools/atlas/GameInterface/Handlers/CinemaHandler.cpp

     
    2020#include "MessageHandler.h"
    2121#include "../CommandProc.h"
    2222#include "graphics/Camera.h"
    23 #include "graphics/CinemaTrack.h"
     23#include "graphics/CinemaManager.h"
    2424#include "graphics/GameView.h"
    2525#include "ps/Game.h"
    2626#include "ps/CStr.h"
     
    3838{
    3939    sCinemaPath path;
    4040    const CCinemaData* data = source->GetData();
    41     path.mode = data->m_Mode;
    42     path.style = data->m_Style;
     41    //path.mode = data->m_Mode;
     42    //path.style = data->m_Style;
    4343    path.growth = data->m_Growth;
    4444    path.timescale = data->m_Timescale;
    4545    path.change = data->m_Switch;
     
    5151    CCinemaData data;
    5252    data.m_Growth = data.m_GrowthCount = path.growth;
    5353    data.m_Switch = path.change;
    54     data.m_Mode = path.mode;
    55     data.m_Style = path.style;
     54    //data.m_Mode = path.mode;
     55    //data.m_Style = path.style;
    5656   
    5757    return data;
    5858}
     
    124124            spline.AddNode( CVector3D(nodes[j].px, nodes[j].py, nodes[j].pz),
    125125                            CVector3D(nodes[j].rx, nodes[j].ry, nodes[j].rz), nodes[j].t );
    126126        }
    127         paths[pathName] = CCinemaPath(data, spline);
     127        paths[pathName] = CCinemaPath(data, spline, TNSpline());
    128128    }
    129129
    130130    g_Game->GetView()->GetCinema()->SetAllPaths(paths);
     
    155155{
    156156    CCinemaManager* manager = g_Game->GetView()->GetCinema();
    157157   
    158     if ( msg->mode == eCinemaEventMode::SMOOTH )
    159         manager->OverridePath(*msg->path); 
     158    if (msg->mode == eCinemaEventMode::SMOOTH)
     159    {
     160        manager->ClearQueue();
     161        manager->AddPathToQueue(*msg->path);
     162    }
    160163    else if ( msg->mode == eCinemaEventMode::IMMEDIATE_PATH )
    161164        manager->MoveToPointAt(msg->t);
    162165    else if ( msg->mode == eCinemaEventMode::RESET )
     
    164167//      g_Game->GetView()->ResetCamera();
    165168    }
    166169    else if ( msg->mode == eCinemaEventMode::SELECT )
    167         manager->SetCurrentPath(*msg->path, msg->drawCurrent, msg->lines);
     170        manager->SetCurrentPath(*msg->path, msg->drawCurrent);
    168171    else
    169172        ENSURE(false);
    170173}
  • source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp

     
    2222
    2323#include "../GameLoop.h"
    2424#include "../View.h"
    25 #include "graphics/CinemaTrack.h"
     25#include "graphics/CinemaManager.h"
    2626#include "graphics/GameView.h"
    2727#include "gui/GUIManager.h"
    2828#include "gui/GUI.h"
     
    5757QUERYHANDLER(CinemaRecord)
    5858{
    5959    CCinemaManager* manager = g_Game->GetView()->GetCinema();
    60     manager->SetCurrentPath(*msg->path, false, false);
     60    manager->SetCurrentPath(*msg->path, false);
    6161
    6262    const int w = msg->width, h = msg->height;
    6363
  • source/tools/atlas/GameInterface/Handlers/TriggerHandler.cpp

     
    2323
    2424#include "ps/Game.h"
    2525#include "graphics/GameView.h"
    26 #include "graphics/CinemaTrack.h"
     26#include "graphics/CinemaManager.h"
    2727#include "simulation2/Simulation2.h"
    2828
    2929namespace AtlasMessage {
  • source/tools/atlas/GameInterface/View.cpp

     
    2424#include "Messages.h"
    2525#include "SimState.h"
    2626
    27 #include "graphics/CinemaTrack.h"
     27#include "graphics/CinemaManager.h"
    2828#include "graphics/GameView.h"
    2929#include "graphics/ParticleManager.h"
    3030#include "graphics/SColor.h"