Ticket #3301: cinematic_camera_core_v1.0.patch

File cinematic_camera_core_v1.0.patch, 81.6 KB (added by Vladislav Belov, 8 years ago)

Disable mouse input, small fixes

  • binaries/data/mods/public/simulation/components/Trigger.js

     
    1919    "Interval",
    2020    "Range",
    2121    "TreasureCollected",
     22    "CinemaPathEnded"
    2223];
    2324
    2425Trigger.prototype.Init = function()
     
    234235    // See function "SpawnUnits" in ProductionQueue for more details
    235236};
    236237
    237 // Handles "OnTrainingFinished" event.
     238// Handles "OnResearchFinished" event.
    238239Trigger.prototype.OnGlobalResearchFinished = function(msg)
    239240{
    240241    this.CallEvent("ResearchFinished", msg);
     
    242243    //                           "tech": tech}
    243244};
    244245
     246// Handles "OnCinemaPathEnded" event.
     247Trigger.prototype.OnGlobalCinemaPathEnded = function(msg)
     248{
     249    this.CallEvent("CinemaPathEnded", msg);
     250}
     251
    245252Trigger.prototype.OnGlobalOwnershipChanged = function(msg)
    246253{
    247254    this.CallEvent("OwnershipChanged", msg);
  • 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_Enabled(false), m_Paused(true), m_DrawPaths(true)
     50{
     51}
     52
     53void CCinemaManager::AddPath(const CStrW& name, CCinemaPath path)
     54{
     55    if (m_Paths.find(name) != m_Paths.end())
     56    {
     57        LOGWARNING("Path with name '%s' already exists", name.ToUTF8());
     58        return;
     59    }
     60    m_Paths[name] = path;
     61}
     62
     63void CCinemaManager::AddPathToQueue(const CStrW& name)
     64{
     65    if (!HasPath(name))
     66    {
     67        LOGWARNING("Path with name '%s' doesn't exist", name.ToUTF8());
     68        return;
     69    }
     70    m_PathQueue.push_back(m_Paths[name]);
     71}
     72
     73void CCinemaManager::ClearQueue()
     74{
     75    m_PathQueue.clear();
     76}
     77
     78void CCinemaManager::SetAllPaths(const std::map<CStrW, CCinemaPath>& paths)
     79{
     80    m_Paths = paths;
     81}
     82
     83void CCinemaManager::SetCurrentPath(const CStrW& name, bool current)
     84{
     85    // ...
     86}
     87
     88bool CCinemaManager::HasPath(const CStrW& name) const
     89{
     90    return m_Paths.find(name) != m_Paths.end();
     91}
     92
     93void CCinemaManager::SetEnabled(bool enabled)
     94{
     95    if (m_Enabled == enabled)
     96        return;
     97
     98    // sn - session gui object
     99    IGUIObject *sn = g_GUI->FindObjectByName("sn");
     100    CmpPtr<ICmpRangeManager> cmpRangeManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
     101    CmpPtr<ICmpTerritoryManager> cmpTerritoryManager(g_Game->GetSimulation2()->GetSimContext().GetSystemEntity());
     102
     103    // GUI visibility
     104    if (sn)
     105    {
     106        if (enabled)
     107            sn->SetSetting("hidden", L"true");
     108        else
     109            sn->SetSetting("hidden", L"false");
     110    }
     111
     112    // Overlay visibility
     113    g_Renderer.SetOptionBool(CRenderer::Option::OPT_SILHOUETTES, !enabled);
     114    if (cmpRangeManager)
     115    {
     116        if (enabled)
     117            m_MapRevealed = cmpRangeManager->GetLosRevealAll(-1);
     118        // TODO: improve m_MapRevealed state and without fade in
     119        cmpRangeManager->SetLosRevealAll(-1, enabled);
     120    }
     121    if (cmpTerritoryManager)
     122        cmpTerritoryManager->SetVisibility(!enabled);
     123    ICmpSelectable::SetOverrideVisibility(!enabled);
     124    ICmpOverlayRenderer::SetOverrideVisibility(!enabled);
     125
     126    m_Enabled = enabled;
     127}
     128
     129void CCinemaManager::MoveToPointAt(float time)
     130{
     131    // TODO: Update after Atlas UI patch
     132    /*ENSURE(m_CurrentPath != m_Paths.end());
     133    ClearQueue();
     134
     135    m_CurrentPath->second.m_TimeElapsed = time;
     136    if (!m_CurrentPath->second.Validate())
     137        return;
     138
     139    m_CurrentPath->second.MoveToPointAt(m_CurrentPath->second.m_TimeElapsed /
     140                m_CurrentPath->second.GetDuration(), m_CurrentPath->second.GetNodeFraction(),
     141                m_CurrentPath->second.m_PreviousRotation );*/
     142}
     143
     144void CCinemaManager::Play()
     145{
     146    SetEnabled(true);
     147    m_Paused = false;
     148}
     149
     150void CCinemaManager::Pause()
     151{
     152    m_Paused = true;
     153}
     154
     155void CCinemaManager::Stop()
     156{
     157    m_Paused = true;
     158    SetEnabled(false);
     159    m_PathQueue.clear();
     160}
     161
     162void CCinemaManager::Skip()
     163{
     164    Next(true);
     165}
     166
     167void CCinemaManager::Next(bool skipped)
     168{
     169    CMessageCinemaPathEnded msg(m_PathQueue.back().GetName(), skipped);
     170    g_Game->GetSimulation2()->PostMessage(SYSTEM_ENTITY, msg);
     171
     172    m_PathQueue.pop_front();
     173    if (m_PathQueue.empty())
     174    {
     175        SetEnabled(false);
     176        m_Paused = true;
     177    }
     178}
     179
     180void CCinemaManager::Update(const float deltaRealTime)
     181{
     182    if (!m_Enabled || m_Paused)
     183        return;
     184   
     185    if (HotkeyIsPressed("leave"))
     186    {
     187        Skip();
     188        return;
     189    }
     190
     191    if (m_PathQueue.front().Play(deltaRealTime))
     192        return;
     193
     194    Next();
     195    return;
     196}
     197
     198void CCinemaManager::Render()
     199{
     200    if (GetEnabled())
     201    {
     202        DrawBars();
     203        return;
     204    }
     205   
     206    if (!m_DrawPaths)
     207        return;
     208
     209    // draw all paths
     210    for (auto it : m_Paths)
     211        it.second.Draw();
     212}
     213
     214void CCinemaManager::DrawBars() const
     215{
     216    int height = (float)g_xres / 2.39f;
     217    int shift = (g_yres - height) / 2;
     218    if (shift <= 0)
     219        return;
     220
     221#if CONFIG2_GLES
     222    #warning TODO : implement bars for GLES
     223#else
     224    // Set up transform for GL bars
     225    glMatrixMode(GL_PROJECTION);
     226    glPushMatrix();
     227    glLoadIdentity();
     228    glMatrixMode(GL_MODELVIEW);
     229    glPushMatrix();
     230    glLoadIdentity();
     231    CMatrix3D transform;
     232    transform.SetOrtho(0.f, (float)g_xres, 0.f, (float)g_yres, -1.f, 1000.f);
     233    glLoadMatrixf(&transform._11);
     234
     235    glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
     236
     237    glEnable(GL_BLEND);
     238    glDisable(GL_DEPTH_TEST);
     239
     240    glBegin(GL_QUADS);
     241    glVertex2i(0, 0);
     242    glVertex2i(g_xres, 0);
     243    glVertex2i(g_xres, shift);
     244    glVertex2i(0, shift);
     245    glEnd();
     246
     247    glBegin(GL_QUADS);
     248    glVertex2i(0, g_yres - shift);
     249    glVertex2i(g_xres, g_yres - shift);
     250    glVertex2i(g_xres, g_yres);
     251    glVertex2i(0, g_yres);
     252    glEnd();
     253
     254    glDisable(GL_BLEND);
     255    glEnable(GL_DEPTH_TEST);
     256
     257    // Restore transform
     258    glMatrixMode(GL_PROJECTION);
     259    glPopMatrix();
     260    glMatrixMode(GL_MODELVIEW);
     261    glPopMatrix();
     262#endif
     263}
     264
     265InReaction cinema_manager_handler(const SDL_Event_* ev)
     266{
     267    // put any events that must be processed even if inactive here
     268    if (!g_Game || !g_Game->IsGameStarted())
     269        return IN_PASS;
     270
     271    CCinemaManager* pCinemaManager = g_Game->GetView()->GetCinema();
     272
     273    return pCinemaManager->HandleEvent(ev);
     274}
     275
     276InReaction CCinemaManager::HandleEvent(const SDL_Event_* ev)
     277{
     278    switch (ev->ev.type)
     279    {
     280    case SDL_MOUSEBUTTONDOWN:
     281    case SDL_MOUSEBUTTONUP:
     282        if (GetEnabled())
     283            return IN_HANDLED;
     284    default:
     285        return IN_PASS;
     286    }
     287}
  • 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
     25#include "lib/input.h" // InReaction - can't forward-declare enum
     26
     27#include "graphics/CinemaPath.h"
     28#include "ps/CStr.h"
     29
     30/*
     31    desc: contains various functions used for cinematic camera paths
     32    See also: CinemaHandler.cpp, CinemaPath.cpp
     33*/
     34
     35/**
     36 * Class for in game playing of cinematics. Should only be instantiated in CGameView.
     37 */
     38
     39class CCinemaManager
     40{
     41public:
     42    CCinemaManager();
     43    ~CCinemaManager() {}
     44
     45    /**
     46     * Adds the path to the path list
     47     * @param name path name
     48     * @param CCinemaPath path data
     49     */
     50    void AddPath(const CStrW& name, CCinemaPath path);
     51
     52    /**
     53     * Adds the path to the playlist
     54     * @param name path name
     55     */
     56    void AddPathToQueue(const CStrW& name);
     57
     58    /**
     59     * Clears the playlist
     60     */
     61    void ClearQueue();
     62
     63    /**
     64     * Checks the path name in the path list
     65     * @param name path name
     66     * @return true if path with that name exists, else false
     67     */
     68    bool HasPath(const CStrW& name) const;
     69   
     70    /**
     71     * These stop track play, and accept time, not ratio of time
     72     * @time point in the timeline
     73     */
     74    void MoveToPointAt(float time);
     75
     76    // TODO: remove legacy methods after Atlas UI patch
     77    inline const std::map<CStrW, CCinemaPath>& GetAllPaths() { return m_Paths; }
     78    void SetAllPaths( const std::map<CStrW, CCinemaPath>& tracks);
     79    void SetCurrentPath(const CStrW& name, bool current);
     80
     81    /**
     82     * Starts play paths
     83     */
     84    void Play();
     85    void Pause();
     86    void Next(bool skipped = false);
     87    void Stop();
     88    void Skip();
     89    inline bool IsPlaying() const { return !m_Paused; }
     90
     91    /**
     92     * Renders black bars and paths (if enabled)
     93     */
     94    void Render();
     95    void DrawBars() const;
     96
     97    /**
     98    * Get current enable state of the cinema manager
     99    */
     100    inline bool GetEnabled() const { return m_Enabled; }
     101
     102    /**
     103     * Sets enable state of the cinema manager (shows/hide gui, show/hide rings, etc)
     104     * @enable new state
     105     */
     106    void SetEnabled(bool enabled);
     107
     108    /**
     109     * Updates CCinemManager and current path
     110     * @param deltaRealTime Elapsed real time since the last frame.
     111     */
     112    void Update(const float deltaRealTime);
     113
     114    InReaction HandleEvent(const SDL_Event_* ev);
     115
     116private:   
     117    bool m_Enabled;
     118    bool m_Paused;
     119    bool m_DrawPaths;
     120
     121    std::map<CStrW, CCinemaPath> m_Paths;
     122    std::list<CCinemaPath> m_PathQueue;
     123
     124    // States before playing
     125    bool m_MapRevealed;
     126};
     127
     128extern InReaction cinema_manager_handler(const SDL_Event_* ev);
     129
     130#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 <sstream>
     23#include <string>
     24
     25#include "Camera.h"
     26#include "CinemaManager.h"
     27#include "GameView.h"
     28#include "gui/CGUI.h"
     29#include "gui/GUIManager.h"
     30#include "gui/IGUIObject.h"
     31#include "lib/ogl.h"
     32#include "maths/MathUtil.h"
     33#include "maths/Quaternion.h"
     34#include "maths/Vector3D.h"
     35#include "maths/Vector4D.h"
     36#include "ps/CLogger.h"
     37#include "ps/CStr.h"
     38#include "ps/Game.h"
     39#include "renderer/Renderer.h"
     40
     41CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline, const TNSpline& targetSpline)
     42    : CCinemaData(data), TNSpline(spline), m_TargetSpline(targetSpline), m_TimeElapsed(0.f)
     43{
     44    BuildSpline();
     45
     46    if (m_Orientation == L"target")
     47    {
     48        m_LookAtTarget = true;
     49        ENSURE(m_TargetSpline.GetAllNodes().size() > 0);
     50    }
     51
     52    // Set distortion mode and style
     53    if (data.m_Mode == L"ease_in")
     54        DistModePtr = &CCinemaPath::EaseIn;
     55    else if (data.m_Mode == L"ease_out")
     56        DistModePtr = &CCinemaPath::EaseOut;
     57    else if (data.m_Mode == L"ease_inout")
     58        DistModePtr = &CCinemaPath::EaseInOut;
     59    else if (data.m_Mode == L"ease_outin")
     60        DistModePtr = &CCinemaPath::EaseOutIn;
     61    else
     62    {
     63        LOGWARNING("Cinematic mode not found for '%s'\n", data.m_Mode.ToUTF8().c_str());
     64        DistModePtr = &CCinemaPath::EaseInOut;
     65    }
     66
     67    if (data.m_Style == L"default")
     68        DistStylePtr = &CCinemaPath::EaseDefault;
     69    else if (data.m_Style == L"growth")
     70        DistStylePtr = &CCinemaPath::EaseGrowth;
     71    else if (data.m_Style == L"expo")
     72        DistStylePtr = &CCinemaPath::EaseExpo;
     73    else if (data.m_Style == L"circle")
     74        DistStylePtr = &CCinemaPath::EaseCircle;
     75    else if (data.m_Style == L"sine")
     76        DistStylePtr = &CCinemaPath::EaseSine;
     77    else
     78    {
     79        LOGWARNING("Cinematic style not found for '%s'\n", data.m_Style.ToUTF8().c_str());
     80        DistStylePtr = &CCinemaPath::EaseDefault;
     81    }
     82}
     83
     84void CCinemaPath::Draw() const
     85{
     86    DrawSpline(*this, CVector4D(0.2f, 0.2f, 1.f, 0.5f), 100, true);
     87    DrawSpline(m_TargetSpline, CVector4D(1.0f, 0.2f, 0.2f, 0.5f), 100, true);
     88    DrawNodes(CVector4D(0.5f, 1.0f, 0.f, 0.5f));
     89}
     90
     91void CCinemaPath::DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const
     92{
     93    if (spline.NodeCount < 2 || DistModePtr == NULL)
     94        return;
     95    if (spline.NodeCount == 2 && lines)
     96        smoothness = 2;
     97
     98    float start = spline.MaxDistance / smoothness;
     99    float time = 0;
     100
     101#if CONFIG2_GLES
     102    #warning TODO : do something about CCinemaPath on GLES
     103#else
     104
     105    glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W);
     106    if (lines)
     107    {
     108        glLineWidth(1.8f);
     109        glEnable(GL_LINE_SMOOTH);
     110        glBegin(GL_LINE_STRIP);
     111
     112        for (int i = 0; i <= smoothness; ++i)
     113        {
     114            // Find distorted time
     115            time = start*i / spline.MaxDistance;
     116            CVector3D tmp = spline.GetPosition(time);
     117            glVertex3f(tmp.X, tmp.Y, tmp.Z);
     118        }
     119        glEnd();
     120        glDisable(GL_LINE_SMOOTH);
     121        glLineWidth(1.0f);
     122    }
     123    else
     124    {
     125        smoothness /= 2;
     126        start = spline.MaxDistance / smoothness;
     127        glEnable(GL_POINT_SMOOTH);
     128        glPointSize(3.0f);
     129        glBegin(GL_POINTS);
     130
     131        for (int i = 0; i <= smoothness; ++i)
     132        {
     133            // Find distorted time
     134            time = (this->*DistModePtr)(start*i / spline.MaxDistance);
     135            CVector3D tmp = spline.GetPosition(time);
     136            glVertex3f(tmp.X, tmp.Y, tmp.Z);
     137        }
     138        glColor3f(1.0f, 1.0f, 0.0f);    // yellow
     139
     140        for (size_t i = 0; i < spline.GetAllNodes().size(); ++i)
     141            glVertex3f(spline.GetAllNodes()[i].Position.X, spline.GetAllNodes()[i].Position.Y, spline.GetAllNodes()[i].Position.Z);
     142
     143        glEnd();
     144        glPointSize(1.0f);
     145        glDisable(GL_POINT_SMOOTH);
     146    }
     147
     148#endif
     149}
     150
     151void CCinemaPath::DrawNodes(const CVector4D& RGBA) const
     152{
     153#if CONFIG2_GLES
     154    #warning TODO : do something about CCinemaPath on GLES
     155#else
     156    glEnable(GL_POINT_SMOOTH);
     157    glPointSize(5.0f);
     158
     159    glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W);
     160    glBegin(GL_POINTS);
     161    for (size_t i = 0; i < Node.size(); ++i)
     162        glVertex3f(Node[i].Position.X, Node[i].Position.Y, Node[i].Position.Z);
     163    glEnd();
     164
     165    if (!m_LookAtTarget)
     166    {
     167        glPointSize(1.0f);
     168        glDisable(GL_POINT_SMOOTH);
     169        return;
     170    }
     171
     172    // draw target nodes
     173    glColor4f(RGBA.Y, RGBA.X, RGBA.Z, RGBA.W);
     174    glBegin(GL_POINTS);
     175    for (size_t i = 0; i < m_TargetSpline.GetAllNodes().size(); ++i)
     176        glVertex3f(m_TargetSpline.GetAllNodes()[i].Position.X, m_TargetSpline.GetAllNodes()[i].Position.Y, m_TargetSpline.GetAllNodes()[i].Position.Z);
     177    glEnd();
     178
     179    glPointSize(1.0f);
     180    glDisable(GL_POINT_SMOOTH);
     181#endif
     182}
     183
     184void CCinemaPath::MoveToPointAt(float t, float nodet, const CVector3D& startRotation)
     185{
     186    CCamera *camera = g_Game->GetView()->GetCamera();
     187    t = (this->*DistModePtr)(t);
     188    CVector3D pos = GetPosition(t);
     189   
     190    if (m_LookAtTarget)
     191    {
     192        if (m_TimeElapsed <= m_TargetSpline.MaxDistance)
     193            camera->LookAt(pos, m_TargetSpline.GetPosition(m_TimeElapsed / m_TargetSpline.MaxDistance), CVector3D(0, 1, 0));
     194        else
     195            camera->LookAt(pos, m_TargetSpline.GetAllNodes().back().Position, CVector3D(0, 1, 0));
     196    }
     197    else
     198    {
     199        CVector3D nodeRotation = Node[m_CurrentNode + 1].Rotation;
     200        CQuaternion start, end;
     201        start.FromEulerAngles(DEGTORAD(startRotation.X), DEGTORAD(startRotation.Y), DEGTORAD(startRotation.Z));
     202        end.FromEulerAngles(DEGTORAD(nodeRotation.X), DEGTORAD(nodeRotation.Y), DEGTORAD(nodeRotation.Z));
     203        start.Slerp(start, end, nodet);
     204
     205        camera->m_Orientation.SetIdentity();
     206        camera->m_Orientation.Rotate(start);
     207        camera->m_Orientation.Translate(pos);
     208    }
     209    camera->UpdateFrustum();
     210}
     211
     212// Distortion mode functions
     213float CCinemaPath::EaseIn(float t) const
     214{
     215    return (this->*DistStylePtr)(t);
     216}
     217
     218float CCinemaPath::EaseOut(float t) const
     219{
     220    return 1.0f - EaseIn(1.0f - t);
     221}
     222
     223float CCinemaPath::EaseInOut(float t) const
     224{
     225    if (t < m_Switch)
     226        return EaseIn(1.0f / m_Switch * t) * m_Switch;
     227    return EaseOut(1.0f / m_Switch * (t - m_Switch)) * m_Switch + m_Switch;
     228}
     229
     230float CCinemaPath::EaseOutIn(float t) const
     231{
     232    if (t < m_Switch)
     233        return EaseOut(1.0f / m_Switch * t) * m_Switch;
     234    return EaseIn(1.0f / m_Switch * (t - m_Switch)) * m_Switch + m_Switch;
     235}
     236
     237// Distortion style functions
     238float CCinemaPath::EaseDefault(float t) const
     239{
     240    return t;
     241}
     242
     243float CCinemaPath::EaseGrowth(float t) const
     244{
     245    return pow(t, m_Growth);
     246}
     247
     248
     249float CCinemaPath::EaseExpo(float t) const
     250{
     251    if (t == 0)
     252        return t;
     253    return powf(m_Growth, 10 * (t - 1.0f));
     254}
     255
     256float CCinemaPath::EaseCircle(float t) const
     257{
     258    t = -(sqrt(1.0f - t*t) - 1.0f);
     259    if (m_GrowthCount > 1.0f)
     260    {
     261        --m_GrowthCount;
     262        return (this->*DistStylePtr)(t);
     263    }
     264    return t;
     265}
     266
     267float CCinemaPath::EaseSine(float t) const
     268{
     269    t = 1.0f - cos(t * (float)M_PI / 2);
     270    if (m_GrowthCount > 1.0f)
     271    {
     272        --m_GrowthCount;
     273        return (this->*DistStylePtr)(t);
     274    }
     275    return t;
     276}
     277
     278bool CCinemaPath::Validate()
     279{
     280    if (m_TimeElapsed > GetDuration() || m_TimeElapsed < 0.0f)
     281        return false;
     282
     283    // Find current node and past "node time"
     284    float previousTime = 0.0f, cumulation = 0.0f;
     285
     286    // Ignore the last node, since it is a blank (node time values are shifted down one from interface)
     287    for (size_t i = 0; i < Node.size() - 1; ++i)
     288    {
     289        cumulation += Node[i].Distance;
     290        if (m_TimeElapsed <= cumulation)
     291        {
     292            m_PreviousNodeTime = previousTime;
     293            m_PreviousRotation = Node[i].Rotation;
     294            m_CurrentNode = i;  // We're moving toward this next node, so use its rotation
     295            break;
     296        }
     297        previousTime += Node[i].Distance;
     298    }
     299    return true;
     300}
     301
     302bool CCinemaPath::Play(const float deltaRealTime)
     303{
     304    m_TimeElapsed += m_Timescale * deltaRealTime;
     305    if (!Validate())
     306    {
     307        m_TimeElapsed = 0.0f;
     308        return false;
     309    }
     310    MoveToPointAt(m_TimeElapsed / GetDuration(), GetNodeFraction(), m_PreviousRotation);
     311    return true;
     312}
  • 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 Draw() const;
     86    void DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const;
     87    void DrawNodes(const CVector4D& RGBA) const;
     88
     89    inline CVector3D GetNodePosition(const int index) const { return Node[index].Position; }
     90    inline float GetNodeDuration(const int index) const { return Node[index].Distance; }
     91    inline float GetDuration() const { return MaxDistance; }
     92
     93    inline float GetNodeFraction() const { return (m_TimeElapsed - m_PreviousNodeTime) / Node[m_CurrentNode].Distance; }
     94    inline float GetElapsedTime() const { return m_TimeElapsed; }
     95
     96    CStrW GetName() const { return m_Name; }
     97
     98    inline void SetTimescale(float scale) { m_Timescale = scale; }
     99
     100    float m_TimeElapsed;
     101    float m_PreviousNodeTime;   //How much time has passed before the current node
     102
     103    size_t m_CurrentNode;
     104    CVector3D m_PreviousRotation;
     105
     106public:
     107
     108    /**
     109     * Returns false if finished.
     110     * @param deltaRealTime Elapsed real time since the last frame.
     111     */
     112    bool Play(const float deltaRealTime);
     113
     114    /**
     115     * Validate the path
     116     * @return true if the path is valid
     117     */
     118    bool Validate();
     119
     120    /**
     121     * Returns true if path doesn't contain nodes
     122     */
     123    bool Empty() { return Node.empty(); }
     124
     125    inline float GetTimescale() const { return m_Timescale; }
     126
     127private:
     128
     129    TNSpline m_TargetSpline;
     130};
     131
     132#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.GetEnabled())
    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"
     
    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};
     
    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                {
     893                    bool positionDeclared = false;
    897894                    SplineData data;
     895                    data.Distance = pathChild.GetAttributes().GetNamedItem(at_deltatime).ToFloat();
     896                    lastTargetTime += pathChild.GetAttributes().GetNamedItem(at_deltatime).ToFloat();
    898897                    XERO_ITER_EL(pathChild, nodeChild)
    899898                    {
    900899                        elementName = nodeChild.GetNodeName();
    901900                        attrs = nodeChild.GetAttributes();
    902                        
    903                         //Fix?:  assumes that time is last element
    904                         if ( elementName == el_position )
     901                        if (elementName == el_position)
    905902                        {
    906903                            data.Position.X = attrs.GetNamedItem(at_x).ToFloat();
    907904                            data.Position.Y = attrs.GetNamedItem(at_y).ToFloat();
    908905                            data.Position.Z = attrs.GetNamedItem(at_z).ToFloat();
    909                             continue;
     906                            positionDeclared = true;
    910907                        }
    911                         else if ( elementName == el_rotation )
     908                        else if (elementName == el_rotation)
    912909                        {
    913910                            data.Rotation.X = attrs.GetNamedItem(at_x).ToFloat();
    914911                            data.Rotation.Y = attrs.GetNamedItem(at_y).ToFloat();
    915912                            data.Rotation.Z = attrs.GetNamedItem(at_z).ToFloat();
    916                             continue;
    917913                        }
    918                         else if ( elementName == el_time )
    919                             data.Distance = nodeChild.GetText().ToFloat();
     914                        else if (elementName == el_target)
     915                        {
     916                            CVector3D targetPosition;
     917                            targetPosition.X = attrs.GetNamedItem(at_x).ToFloat();
     918                            targetPosition.Y = attrs.GetNamedItem(at_y).ToFloat();
     919                            targetPosition.Z = attrs.GetNamedItem(at_z).ToFloat();
     920
     921                            targetSpline.AddNode(targetPosition, CVector3D(), lastTargetTime);
     922                            lastTargetTime = 0;
     923                        }
    920924                        else
    921                             debug_warn(L"Invalid cinematic element for node child");
    922                    
    923                         backwardSpline.AddNode(data.Position, data.Rotation, data.Distance);
     925                            LOGWARNING("Invalid cinematic element for node child");
    924926                    }
     927
     928                    // skip the node if no position
     929                    if (positionDeclared)
     930                        pathSpline.AddNode(data.Position, data.Rotation, data.Distance);
    925931                }
    926932                else
    927                     debug_warn(L"Invalid cinematic element for path child");
    928                
    929                
     933                    LOGWARNING("Invalid cinematic element for path child");
    930934            }
    931935
    932             //Construct cinema path with data gathered
    933             CCinemaPath temp(pathData, backwardSpline);
    934             const std::vector<SplineData>& nodes = temp.GetAllNodes();
    935             if ( nodes.empty() )
     936            // Construct cinema path with data gathered
     937            CCinemaPath path(pathData, pathSpline, targetSpline);
     938            if (path.Empty())
    936939            {
    937                 debug_warn(L"Failure loading cinematics");
     940                LOGWARNING("Path with name '%s' is empty", pathName.ToUTF8());
    938941                return;
    939942            }
    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; 
     943
     944            if (!m_MapReader.pCinema->HasPath(pathName))
     945                m_MapReader.pCinema->AddPath(pathName, path);
     946            else
     947                LOGWARNING("Path with name '%s' already exists", pathName.ToUTF8());
    949948        }
    950949        else
    951             ENSURE("Invalid cinema child");
     950            LOGWARNING("Invalid path child with name '%s'", element.GetText());
    952951    }
    953 
    954     if (m_MapReader.pCinema)
    955         m_MapReader.pCinema->SetAllPaths(pathList);
    956952}
    957953
    958954void CXMLReader::ReadTriggers(XMBElement UNUSED(parent))
     
    11251121        }
    11261122        else if (name == "Paths")
    11271123        {
    1128             ReadCinema(node);
     1124            ReadPaths(node);
    11291125        }
    11301126        else if (name == "Triggers")
    11311127        {
  • 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"
     
    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/lib/input.cpp

     
    3232
    3333#include "lib/external_libraries/libsdl.h"
    3434
    35 const size_t MAX_HANDLERS = 8;
     35const size_t MAX_HANDLERS = 9;
    3636static InHandler handler_stack[MAX_HANDLERS];
    3737static size_t handler_stack_top = 0;
    3838
  • 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 < 0.0f)
     101        time = 0.0f;
     102    if (time > 1.0f)
    101103        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);
     104    float Distance = time * MaxDistance;
     105    float CurrentDistance = 0.f;
     106    int i = 0;
     107
     108    // Find which node we're on
     109    while (CurrentDistance + Node[i].Distance < Distance
     110        && i < NodeCount - 2)
     111    {
     112        CurrentDistance += Node[i].Distance;
     113        ++i;
     114    }
     115    ENSURE(i < NodeCount - 1);
     116    float t = Distance - CurrentDistance;
     117    // TODO: reimplement CVector3D comparator (float comparing is bad without EPS)
     118    if (Node[i].Position == Node[i + 1].Position || Node[i].Distance < 1e-7) // distance too small or zero
     119    {
     120        return Node[i + 1].Position;
     121    }
     122    t /= Node[i].Distance; // scale t in range 0 - 1
     123    CVector3D startVel = Node[i].Velocity * Node[i].Distance;
     124    CVector3D endVel = Node[i + 1].Velocity * Node[i].Distance;
     125    return GetPositionOnCubic(Node[i].Position, startVel,
     126        Node[i + 1].Position, endVel, t);
    120127}
    121128
    122129// internal. Based on Equation 14
    123130CVector3D RNSpline::GetStartVelocity(int index)
    124131{
    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;
     132    if (index >= NodeCount - 1 || index < 0)
     133        return CVector3D(0.0f, 0.0f, 0.0f);
     134    CVector3D temp = (Node[index + 1].Position - Node[index].Position) * 3.0f * (1.0f / Node[index].Distance);
     135    return (temp - Node[index + 1].Velocity)*0.5f;
    129136}
    130137
    131138// internal. Based on Equation 15
    132139CVector3D RNSpline::GetEndVelocity(int index)
    133140{
    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;
     141    if (index >= NodeCount || index < 1)
     142        return CVector3D(0.0f, 0.0f, 0.0f);
     143    CVector3D temp = (Node[index].Position - Node[index - 1].Position) * 3.0f * (1.0f / Node[index - 1].Distance);
     144    return (temp - Node[index - 1].Velocity) * 0.5f;
    138145}
    139146
    140147/*********************************** S N S **************************************************/
     
    142149// smoothing filter.
    143150void SNSpline::Smooth()
    144151{
    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;
     152    if (NodeCount < 3)
     153        return;
     154    CVector3D newVel;
     155    CVector3D oldVel = GetStartVelocity(0);
     156    for (int i = 1; i < NodeCount - 1; ++i)
     157    {
     158        // Equation 12
     159        newVel = GetEndVelocity(i) * Node[i].Distance +
     160            GetStartVelocity(i) * Node[i - 1].Distance;
     161        newVel = newVel * (1 / (Node[i - 1].Distance + Node[i].Distance));
     162        Node[i - 1].Velocity = oldVel;
     163        oldVel = newVel;
     164    }
     165    Node[NodeCount - 1].Velocity = GetEndVelocity(NodeCount - 1);
     166    Node[NodeCount - 2].Velocity = oldVel;
    160167}
    161168
    162169/*********************************** T N S **************************************************/
     
    165172// ie time period is time from last node to this node
    166173void TNSpline::AddNode(const CVector3D &pos, const CVector3D& rotation, float timePeriod)
    167174{
    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   }
     175    if (NodeCount >= MAX_SPLINE_NODES)
     176        return;
     177    if (NodeCount == 0)
     178        MaxDistance = 0.f;
     179    else
     180    {
     181        Node[NodeCount - 1].Distance = timePeriod;
     182        MaxDistance += Node[NodeCount - 1].Distance;
     183    }
    177184
    178   SplineData temp;
    179   temp.Position = pos;
     185    SplineData temp;
     186    temp.Position = pos;
    180187
    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++;
     188    //make sure we don't end up using undefined numbers...
     189    temp.Distance = 0.0f;
     190    temp.Velocity = CVector3D(0.0f, 0.0f, 0.0f);
     191    temp.Rotation = rotation;
     192    Node.push_back(temp);
     193    NodeCount++;
    187194}
    188195
    189196//Inserts node before position
    190197void TNSpline::InsertNode(const int index, const CVector3D &pos, const CVector3D& rotation, float timePeriod)
    191198{
    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++;
     199    if (NodeCount >= MAX_SPLINE_NODES || index < NodeCount - 1)
     200        return;
     201    if (NodeCount == 0)
     202        MaxDistance = 0.f;
     203    else
     204    {
     205        Node[NodeCount - 1].Distance = timePeriod;
     206        Node[NodeCount - 1].Rotation = rotation;
     207        MaxDistance += Node[NodeCount - 1].Distance;
     208    }
     209    SplineData temp;
     210    temp.Position = pos;
     211    Node.insert(Node.begin() + index, temp);
     212    NodeCount++;
    206213}
    207214//Removes node at index
    208215void TNSpline::RemoveNode(const int index)
    209216{
    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--;
     217    if (NodeCount == 0 || index > NodeCount - 1)
     218    {
     219        return;
     220    }
     221    else
     222    {
     223        MaxDistance -= Node[index].Distance;
     224        MaxDistance -= Node[index - 1].Distance;
     225        Node[index - 1].Distance = 0.0f;
     226        Node.erase(Node.begin() + index, Node.begin() + index + 1);
     227    }
     228    NodeCount--;
    222229}
    223230void TNSpline::UpdateNodeTime(const int index, float time)
    224231{
     
    238245}
    239246void TNSpline::Constrain()
    240247{
    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   }
     248    if (NodeCount < 3)
     249        return;
     250    for (int i = 1; i < NodeCount - 1; ++i)
     251    {
     252        // Equation 13
     253        float r0 = (Node[i].Position - Node[i - 1].Position).Length() / Node[i - 1].Distance;
     254        float r1 = (Node[i + 1].Position - Node[i].Position).Length() / Node[i].Distance;
     255        Node[i].Velocity *= 4.0f*r0*r1 / ((r0 + r1)*(r0 + r1));
     256    }
    250257}
    251258
  • 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"
     
    3738class RNSpline
    3839{
    3940public:
    40    
     41
    4142    RNSpline() { NodeCount = 0; }
    4243    virtual ~RNSpline() {}
    43  
    44   void AddNode(const CVector3D &pos);
    45   void BuildSpline();
    46   CVector3D GetPosition(float time) const;
    47   CVector3D GetRotation(float time) const;
    48   const std::vector<SplineData>& GetAllNodes() const { return Node; }
    49  
    50   float MaxDistance;
    51   int NodeCount;
    5244
     45    void AddNode(const CVector3D &pos);
     46    void BuildSpline();
     47    CVector3D GetPosition(float time) const;
     48    CVector3D GetRotation(float time) const;
     49    const std::vector<SplineData>& GetAllNodes() const { return Node; }
     50
     51    float MaxDistance;
     52    int NodeCount;
     53
    5354protected:
    54   std::vector<SplineData> Node;
    55   CVector3D GetStartVelocity(int index);
    56   CVector3D GetEndVelocity(int index);
     55    std::vector<SplineData> Node;
     56    CVector3D GetStartVelocity(int index);
     57    CVector3D GetEndVelocity(int index);
    5758};
    5859
    5960class SNSpline : public RNSpline
     
    6061{
    6162public:
    6263    virtual ~SNSpline() {}
    63   void BuildSpline(){ RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }
    64   void Smooth();
     64    void BuildSpline(){ RNSpline::BuildSpline(); Smooth(); Smooth(); Smooth(); }
     65    void Smooth();
    6566};
    6667
    6768class TNSpline : public SNSpline
     
    6970public:
    7071    virtual ~TNSpline() {}
    7172
    72   void AddNode(const CVector3D& pos, const CVector3D& rotation, float timePeriod);
    73   void PushNode() { Node.push_back( SplineData() ); }
    74   void InsertNode(const int index, const CVector3D &pos, const CVector3D& rotation, float timePeriod);
    75   void RemoveNode(const int index);
    76   void UpdateNodeTime(const int index, float time);
    77   void UpdateNodePos(const int index, const CVector3D &pos);
    78  
    79   void BuildSpline(){ RNSpline::BuildSpline();  Smooth(); Smooth(); Smooth(); }
    80   void Smooth(){ for( int x=0; x<3; x++ ) { SNSpline::Smooth(); Constrain(); } }
    81   void Constrain();
     73    void AddNode(const CVector3D& pos, const CVector3D& rotation, float timePeriod);
     74    void PushNode() { Node.push_back(SplineData()); }
     75    void InsertNode(const int index, const CVector3D &pos, const CVector3D& rotation, float timePeriod);
     76    void RemoveNode(const int index);
     77    void UpdateNodeTime(const int index, float time);
     78    void UpdateNodePos(const int index, const CVector3D &pos);
     79
     80    void BuildSpline(){ RNSpline::BuildSpline();  Smooth(); Smooth(); Smooth(); }
     81    void Smooth(){ for (int x = 0; x < 3; x++) { SNSpline::Smooth(); Constrain(); } }
     82    void Constrain();
    8283};
    8384
    8485#endif // INCLUDED_NUSPLINE
  • 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)
     
    573578
    574579    in_add_handler(touch_input_handler);
    575580
     581    in_add_handler(cinema_manager_handler);
     582
    576583    // must be registered after (called before) the GUI which relies on these globals
    577584    in_add_handler(GlobalsInputHandler);
    578585}
  • source/ps/Globals.cpp

     
    2020
    2121#include "lib/external_libraries/libsdl.h"
    2222#include "network/NetClient.h"
     23
     24#include "graphics/CinemaManager.h"
     25#include "graphics/GameView.h"
     26#include "ps/Game.h"
    2327#include "ps/GameSetup/Config.h"
    2428#include "soundmanager/ISoundManager.h"
    2529
  • 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)
  • 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, bool skipped) :
     553    name(name), skipped(skipped)
     554    {
     555    }
     556
     557    CStrW name;
     558    bool skipped;
     559};
     560
    541561#endif // INCLUDED_MESSAGETYPES
  • source/simulation2/scripting/MessageTypeConversions.cpp

     
    470470    return new CMessageMinimapPing();
    471471}
    472472
     473////////////////////////////////
     474
     475JS::Value CMessageCinemaPathEnded::ToJSVal(ScriptInterface& scriptInterface) const
     476{
     477    TOJSVAL_SETUP();
     478    SET_MSG_PROPERTY(name);
     479    SET_MSG_PROPERTY(skipped);
     480    return JS::ObjectValue(*obj);
     481}
     482
     483CMessage* CMessageCinemaPathEnded::FromJSVal(ScriptInterface& scriptInterface, JS::HandleValue val)
     484{
     485    FROMJSVAL_SETUP();
     486    GET_MSG_PROPERTY(CStrW, name);
     487    GET_MSG_PROPERTY(bool, skipped);
     488    return new CMessageCinemaPathEnded(name, skipped);
     489}
     490
    473491////////////////////////////////////////////////////////////////
    474492
    475493CMessage* 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"