diff options
author | chai <chaifix@163.com> | 2019-01-14 16:40:14 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-14 16:40:14 +0800 |
commit | 98c9825c49a1674f59eafb3253829ca7d5cac3c1 (patch) | |
tree | bdd2a6da72fc998ff884b011a2260dc72537c25f /src/libjin-lua/modules/graphics/je_lua_mesh.cpp | |
parent | 8b00d67febf133e89f6a0bfabc41feed555dc4a9 (diff) |
*rename source file
Diffstat (limited to 'src/libjin-lua/modules/graphics/je_lua_mesh.cpp')
-rw-r--r-- | src/libjin-lua/modules/graphics/je_lua_mesh.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/src/libjin-lua/modules/graphics/je_lua_mesh.cpp b/src/libjin-lua/modules/graphics/je_lua_mesh.cpp deleted file mode 100644 index fc42096..0000000 --- a/src/libjin-lua/modules/graphics/je_lua_mesh.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "common/je_lua_object.h" -#include "common/je_lua_common.h" -#include "libjin/jin.h" -#include "je_lua_mesh.h" -#include "je_lua_texture.h" - -using namespace JinEngine::Math; -using namespace JinEngine::Graphics; - -namespace JinEngine -{ - namespace Lua - { - - const char* Jin_Lua_Mesh = "Mesh"; - - LUA_IMPLEMENT inline Mesh* checkMesh(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - return luaObj->getObject<Mesh>(); - } - - LUA_IMPLEMENT int l_getBound(lua_State* L) - { - Mesh* mesh = checkMesh(L); - BBox bbox = mesh->getBound(); - luax_pushnumber(L, bbox.l); - luax_pushnumber(L, bbox.r); - luax_pushnumber(L, bbox.t); - luax_pushnumber(L, bbox.b); - return 4; - } - - LUA_IMPLEMENT int l_setGraphic(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - Mesh* mesh = luaObj->getObject<Mesh>(); - luaObj->removeDependency((int)MeshDependency::DEP_GRAPHIC); - LuaObject* obj = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Texture); - mesh->setGraphic(obj->getObject<Texture>()); - luaObj->setDependency((int)MeshDependency::DEP_GRAPHIC, obj); - return 0; - } - - // x, y, u, v, color_table - LUA_IMPLEMENT int l_pushVertex(lua_State* L) - { - Mesh* mesh = checkMesh(L); - float x = luax_checknumber(L, 2); - float y = luax_checknumber(L, 3); - float u = luax_checknumber(L, 4); - float v = luax_checknumber(L, 5); - if (!luax_istable(L, 6)) - { - luax_typerror(L, 6, "color table"); - return 1; - } - Color c; - c.r = luax_rawgetnumberthenpop(L, -1, 1); - c.g = luax_rawgetnumberthenpop(L, -1, 2); - c.b = luax_rawgetnumberthenpop(L, -1, 3); - c.a = luax_rawgetnumberthenpop(L, -1, 4); - mesh->pushVertex(x, y, u, v, c); - return 0; - } - - LUA_IMPLEMENT int l_gc(lua_State* L) - { - LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Mesh); - luaObj->release(); - return 0; - } - - LUA_EXPORT void luaopen_Mesh(lua_State* L) - { - luaL_Reg methods[] = { - { "__gc", l_gc }, - { "getBound", l_getBound }, - { "setGraphic", l_setGraphic }, - { "pushVertex", l_pushVertex }, - { 0, 0 } - }; - luax_newtype(L, Jin_Lua_Mesh, methods); - } - - } // namespace Lua -} // namespace JinEngine
\ No newline at end of file |