From 2b6f436cf400219170688dba9bc2dee4950d8c97 Mon Sep 17 00:00:00 2001
From: Nick Gasson <nick@nickg.me.uk>
Date: Sun, 31 May 2009 16:38:39 +0100
Subject: [PATCH] Implement two types of billboard

---
 maps/figure8.xml |  2 +-
 src/Game.cpp     |  2 ++
 src/Map.cpp      |  2 +-
 src/Train.cpp    | 12 ++++++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/maps/figure8.xml b/maps/figure8.xml
index 660efa5..03fb4a2 100644
--- a/maps/figure8.xml
+++ b/maps/figure8.xml
@@ -2,7 +2,7 @@
 <map width="32" height="32">
 <name>No Name</name>
 
-<start x="3" y="7" dirX="0" dirY="0"/>
+<start x="3" y="7" dirX="0" dirY="1"/>
 
 <heightmap>maps/figure8.bin</heightmap>
 
diff --git a/src/Game.cpp b/src/Game.cpp
index 508285d..ecb2667 100644
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -24,6 +24,7 @@
 #include "ILight.hpp"
 #include "gui/IContainer.hpp"
 #include "GameScreens.hpp"
+#include "IBillboard.hpp"
 
 #include <GL/gl.h>
 
@@ -121,6 +122,7 @@ void Game::display(IGraphicsPtr aContext) const
    position.y = myViewRadius * cosf(myVertAngle) + yCentre;
    
    aContext->lookAt(position, trainPos);
+   setBillboardCameraOrigin(position);
    
    mySun->apply();
    
diff --git a/src/Map.cpp b/src/Map.cpp
index 687c029..70dc734 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -978,7 +978,7 @@ void Map::save(const string& aFileName)
        .addAttribute("x", myStartLocation.x)
        .addAttribute("y", myStartLocation.y)
        .addAttribute("dirX", myStartDirection.x)
-       .addAttribute("dirY", myStartDirection.y));
+       .addAttribute("dirY", myStartDirection.z));
 
    // Generate the height map
    // Note: basename is deprecated (use .replace_extension() instead when
diff --git a/src/Train.cpp b/src/Train.cpp
index 2174ea1..48fd547 100644
--- a/src/Train.cpp
+++ b/src/Train.cpp
@@ -20,6 +20,9 @@
 #include "ILogger.hpp"
 #include "TrackCommon.hpp"
 
+// REMOVE
+#include "IBillboard.hpp"
+
 #include <stdexcept>
 #include <cassert>
 
@@ -71,6 +74,9 @@ private:
 
    // Seperation between waggons
    static const double SEPARATION;
+
+   // REMOVE
+   IBillboardPtr bb;
 };
 
 const double Train::SEPARATION(0.1);
@@ -87,6 +93,8 @@ Train::Train(IMapPtr aMap)
    
    for (int i = 1; i <= 5; i++)
       addPart(makeWaggon());
+
+   bb = makeSphericalBillboard(loadTexture("data/images/smoke_particle.png"));
 }
 
 void Train::addPart(IRollingStockPtr aVehicle)
@@ -180,6 +188,10 @@ void Train::render() const
       
       glPopMatrix();
    }
+
+   Vector<float> p = front();
+   bb->setPosition(p.x, p.y + 2.0f, p.z);
+   bb->render();
 }
 
 Vector<float> Train::front() const
-- 
2.39.5