From 0a42ee69a425df2abe52f9e6893917dcdcdc8d9e Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 1 Aug 2010 20:07:47 +0100 Subject: [PATCH] Scenery and track implement shared IRenderable interface --- include/IRenderable.hpp | 33 +++++++++++++++++++++++++++++++++ include/IScenery.hpp | 4 ++-- include/ITrackSegment.hpp | 6 ++---- src/Building.cpp | 2 +- src/SmokeTrail.cpp | 2 +- 5 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 include/IRenderable.hpp diff --git a/include/IRenderable.hpp b/include/IRenderable.hpp new file mode 100644 index 0000000..754274a --- /dev/null +++ b/include/IRenderable.hpp @@ -0,0 +1,33 @@ +// +// Copyright (C) 2009-2010 Nick Gasson +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INC_IRENDERABLE_HPP +#define INC_IRENDERABLE_HPP + +#include "Platform.hpp" + +// Anything that can be rendered, but mostly used for objects on +// the map +struct IRenderable { + virtual ~IRenderable() {} + + virtual void render() const = 0; +}; + +typedef shared_ptr IRenderablePtr; + +#endif diff --git a/include/IScenery.hpp b/include/IScenery.hpp index 78273e1..88331ee 100644 --- a/include/IScenery.hpp +++ b/include/IScenery.hpp @@ -21,12 +21,12 @@ #include "Platform.hpp" #include "IXMLSerialisable.hpp" #include "IMesh.hpp" +#include "IRenderable.hpp" // Static scenery such as trees -struct IScenery : IXMLSerialisable { +struct IScenery : IXMLSerialisable, IRenderable { virtual ~IScenery() {} - virtual void render() const = 0; virtual void set_position(float x, float y, float z) = 0; virtual void set_angle(float angle) = 0; virtual void merge(IMeshBufferPtr buf) = 0; diff --git a/include/ITrackSegment.hpp b/include/ITrackSegment.hpp index 5190627..7d70471 100644 --- a/include/ITrackSegment.hpp +++ b/include/ITrackSegment.hpp @@ -22,6 +22,7 @@ #include "Maths.hpp" #include "IXMLSerialisable.hpp" #include "IMesh.hpp" +#include "IRenderable.hpp" #include #include @@ -93,12 +94,9 @@ typedef shared_ptr ITrackSegmentPtr; // A segment of track which fits over a number of tiles // Each track segment has an origin and one or more exits -struct ITrackSegment : IXMLSerialisable { +struct ITrackSegment : IXMLSerialisable, IRenderable { virtual ~ITrackSegment() {} - // Render the track with the origin in the centre - virtual void render() const = 0; - // Merge this track segment's mesh into a scenery mesh buffer virtual void merge(IMeshBufferPtr buf) const = 0; diff --git a/src/Building.cpp b/src/Building.cpp index 042b0b2..268b16f 100644 --- a/src/Building.cpp +++ b/src/Building.cpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2009 Nick Gasson +// Copyright (C) 2009-2010 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/SmokeTrail.cpp b/src/SmokeTrail.cpp index 3a2ed7c..15a3520 100644 --- a/src/SmokeTrail.cpp +++ b/src/SmokeTrail.cpp @@ -79,7 +79,7 @@ bool SmokeTrail::move_particle(Particle& p, int a_delta) const float slowdown = 0.1f; const float x_wind = 0.02f; const float z_wind = 0.01f; - + const float time = static_cast(a_delta) / 1000.0f; p.x += p.xv + (x_wind * time); -- 2.39.2