]> Dogcows Code - chaz/yoink/blobdiff - src/Scene.cc
converted tilemap scripts to lua
[chaz/yoink] / src / Scene.cc
index bd9c034c5f4f610ce59b80d93b328debfb71a848..59ece168a4167089f4f9e056122115fa2f485ae9 100644 (file)
@@ -38,9 +38,9 @@
 #include <Moof/Octree.hh>
 #include <Moof/Script.hh>
 #include <Moof/Settings.hh>
-#include <Moof/Tilemap.hh>
 
 #include "Scene.hh"
+#include "Tilemap.hh"
 
 
 struct Scene::Impl : public Mf::Mippleton<Impl>
@@ -50,7 +50,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                Mf::Scalar              vertices_[12];
                Mf::Scalar              texCoords_[8];
                
-               Mf::Tilemap             tilemap_;
+               Tilemap                 tilemap_;
 
                bool                    blending_;
                bool                    fog_;
@@ -68,7 +68,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                };
 
                Quad(const Mf::Vector3 vertices[4], const std::string& texture,
-                               Mf::Tilemap::Index tileIndex) :
+                               Tilemap::Index tileIndex) :
                        tilemap_(texture),
                        blending_(false),
                        fog_(false)
@@ -267,8 +267,6 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
 
 
 
-       Mf::Script                              script;
-
        Mf::Matrix4                             transform;
        std::string                             texture;
 
@@ -287,10 +285,6 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
        explicit Impl(const std::string& name) :
                Mf::Mippleton<Impl>(name)
        {
-               script.importStandardLibraries();
-               importLogScript(script);
-
-               importSceneBindings(script);
                loadFromFile();
        }
 
@@ -331,8 +325,13 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
 
        void loadFromFile()
        {
+               Mf::Script script;
                std::string filePath = Scene::getPath(getName());
 
+               script.importStandardLibraries();
+               importLogScript(script);
+               importSceneBindings(script);
+
                if (script.doFile(filePath) != Mf::Script::SUCCESS)
                {
                        std::string str;
@@ -487,7 +486,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
 
                if (nTiles % width != 0) table.throwError("invalid number of tiles");
 
-               std::vector< std::vector<Mf::Tilemap::Index> > indices;
+               std::vector< std::vector<Tilemap::Index> > indices;
 
                int i, w, h;
 
@@ -501,7 +500,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                i = 1;
                for (h = height - 1; h >= 0; --h)
                {
-                       std::vector<Mf::Tilemap::Index> row;
+                       std::vector<Tilemap::Index> row;
 
                        for (w = 0; w < width; ++w, ++i)
                        {
@@ -509,10 +508,10 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                                script.push(long(i));
                                tiles.pushField();
 
-                               long index;
+                               Tilemap::Index index;
                                top.get(index);
 
-                               row.push_back(Mf::Tilemap::Index(index));
+                               row.push_back(index);
                        }
 
                        indices[h] = row;
@@ -527,8 +526,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                {
                        for (int w = 0; w <= width; ++w)
                        {
-                               vertices[h][w] = Mf::Vector4(Mf::Scalar(w), Mf::Scalar(h), 0.0, 1.0) *
-                                       transposedTransform;
+                               vertices[h][w] = Mf::Vector4(w, h, 0.0, 1.0) * transposedTransform;
                        }
                }
 
@@ -536,7 +534,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                {
                        for (int w = 0; w < width; ++w)
                        {
-                               if (indices[h][w] == Mf::Tilemap::NO_TILE) continue;
+                               if (indices[h][w] == Tilemap::NO_TILE) continue;
 
                                Mf::Vector3 quadVertices[4];
 
@@ -607,7 +605,7 @@ struct Scene::Impl : public Mf::Mippleton<Impl>
                        quadVertices[2] = Mf::demote(vertices[1][w+1]);
                        quadVertices[3] = Mf::demote(vertices[1][w]);
 
-                       Quad* quad = new Quad(quadVertices, texture, Mf::Tilemap::Index(index));
+                       Quad* quad = new Quad(quadVertices, texture, Tilemap::Index(index));
                        quad->setBlending(blending);
                        quad->setFog(fog);
 
This page took 0.024094 seconds and 4 git commands to generate.