Index: source/graphics/CinemaManager.h =================================================================== --- source/graphics/CinemaManager.h +++ source/graphics/CinemaManager.h @@ -26,6 +26,7 @@ #include "graphics/CinemaPath.h" #include "ps/CStr.h" +#include "ps/Shapes.h" /** * Class for in game playing of cinematics. Should only be instantiated in CGameView. @@ -42,6 +43,9 @@ void Render() const; void DrawBars() const; void DrawPaths() const; + void DrawSpline(const RNSpline& spline, const CColor& splineColor, int smoothness, bool lines) const; + void DrawNodes(const RNSpline& spline, const CColor& nodesColor) const; + void UpdateSessionVisibility() const; void UpdateSilhouettesVisibility() const; Index: source/graphics/CinemaManager.cpp =================================================================== --- source/graphics/CinemaManager.cpp +++ source/graphics/CinemaManager.cpp @@ -39,6 +39,7 @@ #include "ps/Game.h" #include "ps/GameSetup/Config.h" #include "ps/Hotkey.h" +#include "ps/World.h" #include "simulation2/components/ICmpCinemaManager.h" #include "simulation2/components/ICmpOverlayRenderer.h" #include "simulation2/components/ICmpRangeManager.h" @@ -111,7 +112,106 @@ return; for (const std::pair& p : cmpCinemaManager->GetPaths()) - p.second.Draw(); + { + DrawSpline(p.second, CColor(0.2f, 0.2f, 1.f, 0.9f), 100, true); + DrawNodes(p.second, CColor(0.5f, 1.0f, 0.f, 1.0f)); + + if (p.second.GetTargetSpline().GetAllNodes().empty()) + return; + + DrawSpline(p.second.GetTargetSpline(), CColor(1.0f, 0.2f, 0.2f, 0.9f), 100, true); + DrawNodes(p.second.GetTargetSpline(), CColor(1.0f, 0.5f, 0.f, 1.0f)); + } +} + +void CCinemaManager::DrawSpline(const RNSpline& spline, const CColor& splineColor, int smoothness, bool lines) const +{ + if (spline.GetAllNodes().size() < 2) + return; + if (spline.GetAllNodes().size() == 2 && lines) + smoothness = 2; + + float start = spline.MaxDistance.ToFloat() / smoothness; + float time = 0; + +#if CONFIG2_GLES + #warning TODO : do something about CCinemaPath on GLES +#else + + glEnable(GL_BLEND); + glColor4f(splineColor.r, splineColor.g, splineColor.b, splineColor.a); + if (lines) + { + glLineWidth(1.8f); + glEnable(GL_LINE_SMOOTH); + glBegin(GL_LINE_STRIP); + + for (int i = 0; i <= smoothness; ++i) + { + time = start*i / spline.MaxDistance.ToFloat(); + CVector3D tmp = spline.GetPosition(time); + glVertex3f(tmp.X, tmp.Y, tmp.Z); + } + glEnd(); + + if (g_Game && g_Game->GetWorld() && g_Game->GetWorld()->GetTerrain()) + { + glLineWidth(1.1f); + glBegin(GL_LINES); + for (int i = 0; i <= smoothness; ++i) + { + time = start*i / spline.MaxDistance.ToFloat(); + CVector3D tmp = spline.GetPosition(time); + float groundY = g_Game->GetWorld()->GetTerrain()->GetExactGroundLevel(tmp.X, tmp.Z); + glVertex3f(tmp.X, tmp.Y, tmp.Z); + glVertex3f(tmp.X, groundY, tmp.Z); + } + glEnd(); + } + + glDisable(GL_LINE_SMOOTH); + glLineWidth(1.0f); + } + else + { + smoothness /= 2; + start = spline.MaxDistance.ToFloat() / smoothness; + glEnable(GL_POINT_SMOOTH); + glPointSize(3.0f); + glBegin(GL_POINTS); + for (int i = 0; i <= smoothness; ++i) + { + time = start*i / spline.MaxDistance.ToFloat(); + CVector3D tmp = spline.GetPosition(time); + glVertex3f(tmp.X, tmp.Y, tmp.Z); + } + glEnd(); + glPointSize(1.0f); + glDisable(GL_POINT_SMOOTH); + } + glDisable(GL_BLEND); + +#endif +} + +void CCinemaManager::DrawNodes(const RNSpline& spline, const CColor& nodesColor) const +{ +#if CONFIG2_GLES + #warning TODO : do something about CCinemaPath on GLES +#else + glEnable(GL_POINT_SMOOTH); + glPointSize(5.0f); + + glColor4f(nodesColor.r, nodesColor.g, nodesColor.b, nodesColor.a); + glBegin(GL_POINTS); + const std::vector& nodes = spline.GetAllNodes(); + for (size_t i = 0; i < nodes.size(); ++i) + glVertex3f(nodes[i].Position.X.ToFloat(), nodes[i].Position.Y.ToFloat(), nodes[i].Position.Z.ToFloat()); + glEnd(); + + glPointSize(1.0f); + glDisable(GL_POINT_SMOOTH); +#endif } void CCinemaManager::DrawBars() const Index: source/graphics/CinemaPath.h =================================================================== --- source/graphics/CinemaPath.h +++ source/graphics/CinemaPath.h @@ -83,10 +83,6 @@ public: - void Draw() const; - void DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const; - void DrawNodes(const RNSpline& spline, const CVector4D& RGBA) const; - CVector3D GetNodePosition(const int index) const; fixed GetNodeDuration(const int index) const; fixed GetDuration() const; Index: source/graphics/CinemaPath.cpp =================================================================== --- source/graphics/CinemaPath.cpp +++ source/graphics/CinemaPath.cpp @@ -84,102 +84,6 @@ } } -void CCinemaPath::Draw() const -{ - DrawSpline(*this, CVector4D(0.2f, 0.2f, 1.f, 0.5f), 100, true); - DrawNodes(*this, CVector4D(0.5f, 1.0f, 0.f, 0.5f)); - - if (!m_LookAtTarget) - return; - - DrawSpline(m_TargetSpline, CVector4D(1.0f, 0.2f, 0.2f, 0.5f), 100, true); - DrawNodes(m_TargetSpline, CVector4D(1.0f, 0.5f, 0.f, 0.5f)); -} - -void CCinemaPath::DrawSpline(const RNSpline& spline, const CVector4D& RGBA, int smoothness, bool lines) const -{ - if (spline.NodeCount < 2 || DistModePtr == NULL) - return; - if (spline.NodeCount == 2 && lines) - smoothness = 2; - - float start = spline.MaxDistance.ToFloat() / smoothness; - float time = 0; - -#if CONFIG2_GLES - #warning TODO: do something about CCinemaPath on GLES -#else - - glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W); - if (lines) - { - glLineWidth(1.8f); - glEnable(GL_LINE_SMOOTH); - glBegin(GL_LINE_STRIP); - - for (int i = 0; i <= smoothness; ++i) - { - // Find distorted time - time = start*i / spline.MaxDistance.ToFloat(); - CVector3D tmp = spline.GetPosition(time); - glVertex3f(tmp.X, tmp.Y, tmp.Z); - } - glEnd(); - glDisable(GL_LINE_SMOOTH); - glLineWidth(1.0f); - } - else - { - smoothness /= 2; - start = spline.MaxDistance.ToFloat() / smoothness; - glEnable(GL_POINT_SMOOTH); - glPointSize(3.0f); - glBegin(GL_POINTS); - - for (int i = 0; i <= smoothness; ++i) - { - // Find distorted time - time = (this->*DistModePtr)(start*i / spline.MaxDistance.ToFloat()); - CVector3D tmp = spline.GetPosition(time); - glVertex3f(tmp.X, tmp.Y, tmp.Z); - } - glColor3f(1.0f, 1.0f, 0.0f); // yellow - - for (size_t i = 0; i < spline.GetAllNodes().size(); ++i) - glVertex3f( - spline.GetAllNodes()[i].Position.X.ToFloat(), - spline.GetAllNodes()[i].Position.Y.ToFloat(), - spline.GetAllNodes()[i].Position.Z.ToFloat() - ); - - glEnd(); - glPointSize(1.0f); - glDisable(GL_POINT_SMOOTH); - } - -#endif -} - -void CCinemaPath::DrawNodes(const RNSpline& spline, const CVector4D& RGBA) const -{ -#if CONFIG2_GLES - #warning TODO : do something about CCinemaPath on GLES -#else - glEnable(GL_POINT_SMOOTH); - glPointSize(5.0f); - - glColor4f(RGBA.X, RGBA.Y, RGBA.Z, RGBA.W); - glBegin(GL_POINTS); - const std::vector& nodes = spline.GetAllNodes(); - for (size_t i = 0; i < nodes.size(); ++i) - glVertex3f(nodes[i].Position.X.ToFloat(), nodes[i].Position.Y.ToFloat(), nodes[i].Position.Z.ToFloat()); - glEnd(); - - glPointSize(1.0f); - glDisable(GL_POINT_SMOOTH); -#endif -} - CVector3D CCinemaPath::GetNodePosition(const int index) const { return Node[index].Position;