X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FScene.cc;h=af54c28768cfa92af735ccb9858d211f0a0789b2;hp=2d8f12025d3c8fd119d99d86e58368f03793a876;hb=1d4aa0d34b0410c7bc60a24bad7abb55eacc850a;hpb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c diff --git a/src/Scene.cc b/src/Scene.cc index 2d8f120..af54c28 100644 --- a/src/Scene.cc +++ b/src/Scene.cc @@ -18,9 +18,10 @@ #include #include #include +#include #include #include -#include +#include #include "Character.hh" #include "Scene.hh" @@ -39,9 +40,9 @@ struct Scene::impl : public moof::manager }; Quad(const moof::vector3* vertices[4], - const std::string& texture, + const moof::image_handle& texture, int tileIndex) : - mTilemap(texture), + mTilemap(texture, tileIndex), mBlending(false), mFog(false), mSurface(NONE) @@ -55,17 +56,6 @@ struct Scene::impl : public moof::manager //} } - if (!mTilemap.tile_coordinates(tileIndex, mTexCoords)) - { - moof::log_warning << "no index " << tileIndex << - " in texture " << texture << std::endl; - - mTexCoords[0] = mTexCoords[1] = - mTexCoords[3] = mTexCoords[6] = 0.0; - mTexCoords[2] = mTexCoords[4] = - mTexCoords[5] = mTexCoords[7] = 1.0; - } - aabb_.enclose_vertices(mVertices, 4); sphere_.point = aabb_.center(); sphere_.radius = (aabb_.min - sphere_.point).length(); @@ -106,12 +96,7 @@ struct Scene::impl : public moof::manager } //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - mTilemap.bind(); - - glVertexPointer(3, GL_SCALAR, 0, mVertices[0].data()); - glTexCoordPointer(2, GL_SCALAR, 0, mTexCoords); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + mTilemap.draw(mVertices); glDisable(GL_BLEND); glDisable(GL_FOG); @@ -123,10 +108,9 @@ struct Scene::impl : public moof::manager } - moof::vector3 mVertices[4]; - moof::scalar mTexCoords[8]; + moof::vector3 mVertices[4]; - moof::texture mTilemap; + moof::sprite mTilemap; bool mBlending; bool mFog; @@ -135,8 +119,8 @@ struct Scene::impl : public moof::manager - moof::matrix4 mTransform; - std::string mTexture; + moof::matrix4 mTransform; + moof::image_handle mTexture; std::list< boost::shared_ptr > mObjects; std::list mLines; @@ -194,8 +178,8 @@ struct Scene::impl : public moof::manager moof::script::status load(moof::settings& settings, moof::script& script) { - std::string path(name()); - if (!resource::find(path)) + std::string path = moof::resource::find_file("scenes/"+name(), "lua"); + if (path.empty()) { script.push("the scene file could not be found"); return moof::script::file_error; @@ -208,8 +192,8 @@ struct Scene::impl : public moof::manager static int loadBox(moof::script& script, moof::aabb3& aabb) { - script[1].require_table(); - script[2].require_table(); + script[1].require_table("point"); + script[2].require_table("point"); script[1].push_field(1).get(aabb.min[0]); script[1].push_field(2).get(aabb.min[1]); @@ -223,8 +207,7 @@ struct Scene::impl : public moof::manager int setBounds(moof::script& script) { - int ret = loadBox(script, mBounds); - return ret; + return loadBox(script, mBounds); } int resetTransform(moof::script& script) @@ -281,10 +264,10 @@ struct Scene::impl : public moof::manager int rotate(moof::script& script) { - size_t index = 0; - script[1].require_number().get(index); + size_t index = 0; + moof::scalar value; - moof::scalar value; + script[1].require_number().get(index); script[2].require_number().get(value); moof::matrix_rotate_about_world_axis(mTransform, index, @@ -295,7 +278,9 @@ struct Scene::impl : public moof::manager int setTexture(moof::script& script) { - script[1].require_string().get(mTexture); + std::string texture_name; + script[1].require_string().get(texture_name); + mTexture = moof::resource::load(texture_name, "png"); return 0; } @@ -348,7 +333,7 @@ struct Scene::impl : public moof::manager vertices[h][wPlus1] = moof::demote(mTransform * moof::vector4(wPlus1, h, 0.0, 1.0)); - if (index == moof::texture::no_tile) continue; + if (index == moof::image::no_tile) continue; const moof::vector3* corners[4] = { &vertices[h][w],