From 35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 26 Dec 2017 00:57:52 -0500 Subject: Major update --- src/client/lua_api/scene/icube.cpp | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/client/lua_api/scene/icube.cpp (limited to 'src/client/lua_api/scene/icube.cpp') diff --git a/src/client/lua_api/scene/icube.cpp b/src/client/lua_api/scene/icube.cpp new file mode 100644 index 0000000..d18db2a --- /dev/null +++ b/src/client/lua_api/scene/icube.cpp @@ -0,0 +1,68 @@ + +extern "C" { + #include + #include + #include +} +#include + +extern IrrlichtDevice* device; + +using namespace irr; + +// {} :: scene.newcube(num_size, {v3 pos}) +int newiscenecube(lua_StatE* L){//num_size, {v3 pos} + double x,y,z; + popvector3d(L,&x, &y, &z);//num_size + double size = lua_tonumber(L,-1);//num_size + lua_pop(L,1);// + IMeshSceneNode* n = device->getSceneManager()->addCubeSceneNode(size,0,-1,core::vector3df(x,y,z)); + + lua_newtable(L);//{} + lua_pushlightuserdata(L,n);//{},ud_node + lua_setfield(L,-2,"node");//{} + + luaL_getmetatable(L,"scene.inode");//{},sene.inode + lua_setmetatable(L,-2); + + return 1; +} + +static const luaL_reg iscenenode_m[] = { + {"getpos", iscenegetpos}, + {"setpos", iscenesetpos}, +// {"remove", removeiguielement}, + {0, 0}, +}; + +void icube_register(lua_State* L){ + + luaL_newmetatable(L, "scene.icamera");//scene.icamera + lua_newtable(L);//scene.icamera, {} + luaL_register(L,NULL,icamera_m);//scene.icamera, {} + lua_setfield(L,-2,"__index");//scene.icamera + lua_pop(L,1);// + + luaL_newmetatable(L, "scene.imayacamera");//scene.imayacamera + lua_newtable(L);//scene.imayascamera,{} + luaL_register(L,NULL,imayacamera_m);//scene.imayascamera,{} + lua_setfield(L,-2,"__index");//scene.imayascamera + lua_pop(L,1);// + + luaL_newmetatable(L,"scene.ifpscamera");//scene.ifpscamera + lua_newtable(L);//scene.ifpscamera, {} + luaL_register(L,NULL,ifpscamera_m);//scene.ifpscamera,{} + luaL_register(L,NULL,icamera_m);//scene.ifpscamera,{} + lua_setfield(L,-2,"__index");//scene.ifpscamera + lua_pop(L,1);// + + lua_getglobal(L,"scene");//{} + lua_pushcfunction(L,newiscenecamera);//{},newiscenecamera() + lua_setfield(L,-2,"newcamera");//{} + lua_pushcfunction(L,newiscenefpscamera);//{},newiscenefpscamera() + lua_setfield(L,-2,"newfpscamera");//{} + lua_pushcfunction(L,newiscenemayacamera);//{},newiscenemayacamera() + lua_setfield(L,-2,"newmayacamera");//{} + printf("\"scene\" was set!\n"); + //lua_pop(L,1); +} -- cgit v1.2.3-70-g09d2