diff options
| -rw-r--r-- | src/client/lua_api/scene/igeneric.cpp | 148 |
1 files changed, 141 insertions, 7 deletions
diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp index 38479d4..63bf4bc 100644 --- a/src/client/lua_api/scene/igeneric.cpp +++ b/src/client/lua_api/scene/igeneric.cpp @@ -14,8 +14,19 @@ using namespace core; using namespace scene; using namespace video; +/*** +@classmod iscenenode +*/ + extern IrrlichtDevice* device; + + +/*** +Get the position of a scene element. +@function iscenenode:getpos() +@treturn vector3d position The position this element is at +*/ int iscenegetpos(lua_State* L){//{node=ud_IMeshSceneNode} lua_getfield(L,-1,"node");//{node=ud_IMeshSceneNode},ud_IMeshSceneNode ISceneNode* i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_IMeshSceneNode},ud_IMeshSceneNode @@ -26,6 +37,11 @@ int iscenegetpos(lua_State* L){//{node=ud_IMeshSceneNode} return 1; } +/*** +Set the position of a scene element. +@function iscenenode:setpos(vector3d) +@tparam vector3d position The position to set this element to +*/ int iscenesetpos(lua_State* L){//{node=ISceneNode},{x,y,z} double x,y,z; popvector3d(L,&x,&y,&z);//{node=ud_ISceneNode} @@ -37,6 +53,11 @@ int iscenesetpos(lua_State* L){//{node=ISceneNode},{x,y,z} return 0; } +/*** +Set the rotation of a scene element. +@function iscenenode:getang() +@treturn angle3d The angle of this element +*/ int iscenegetangle(lua_State* L){//{node=ud-IMeshSceneNode} lua_getfield(L,-1,"node"); ISceneNode* i = (ISceneNode*)lua_touserdata(L,-1); @@ -45,6 +66,11 @@ int iscenegetangle(lua_State* L){//{node=ud-IMeshSceneNode} return 1; } +/*** +Set the rotation of a scene element. +@function iscenenode:getang() +@tparam angle3d angle The angle to set this element to +*/ int iscenesetangle(lua_State* L){//{node=ud_ISceneNode},{x,y,z} double x,y,z; popvector3d(L,&x,&y,&z); @@ -55,24 +81,132 @@ int iscenesetangle(lua_State* L){//{node=ud_ISceneNode},{x,y,z} return 0; } -//iscenesetmaterial(ud_ISceneNode,ud_itexture) -int iscenesetmaterial(lua_State* L){ +/*** +Set the mateiral of a scene element. +@function iscenenode:setmaterial() +@tparam texture texture The texture to apply to this material +*/ +//iscenesetmaterialtexture({node=ud_ISceneNode},{texture=ud_itexture},texture_number=0) +int iscenesetmaterial(lua_State *L){ printf("Calling generic iscenesetmaterial function\n"); - ITexture* txt = (ITexture*)lua_touserdata(L,-1);//ud_ISceneNode,ud_itexture - lua_pop(L,1);//ud_ISceneNode - ISceneNode* i = (ISceneNode*)lua_touserdata(L,-1);//ud_ISceneNode + int args = lua_gettop(L); + u32 layer = 0; + if(args == 3){ + layer = lua_tonumber(L,-1); + lua_pop(L,1); + } + lua_getfield(L,-1,"texture"); + ITexture *txt = (ITexture*)lua_touserdata(L,-1);//{node=ud_ISceneNode},{texture=ud_itexture},ud_itexture + lua_pop(L,2);//{node=ud_ISceneNode} + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode lua_pop(L,2);// - i->setMaterialTexture(0,txt); + i->setMaterialTexture(layer,txt); return 0; } +/*** +Set the name of a scene element. +@function iscenenode:setname() +@tparam string name The name to give this scene element. +*/ +//iscenesetname({node=ud_ISceneNode},str_name) +int iscenesetname(lua_State *L){ + const char *name = lua_tostring(L,-1); + lua_pop(L,1);//{node=ud_ISceneNode} + + lua_getfield(L,-1,"node");//{node=ud_ISceneNode},ud_ISceneNode + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode + lua_pop(L,2); + + i->setName((c8*)name); + return 0; +} + +/*** +Get the name of this scene element. +@function iscenenode:getname() +@tparam string name The name to give this scene element. +*/ +//iscenesetname({node=ud_ISceneNode}) +int iscenegetname(lua_State *L){ + lua_getfield(L,-1,"node");//{node=ud_ISceneNode},ud_ISceneNode + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode + lua_pop(L,2); + + const char *name = i->getName(); + + lua_pushstring(L,name); + return 1; +} + +/*** +Set the scale of this scene element. +@function iscenenode:setscale({x,y,z}) +@tparam vector3d scale The scale to give this scene element. +*/ +//iscenesetscale({x,y,z}) +int iscenesetscale(lua_State *L){ + double x,y,z; + popvector3d(L,&x,&y,&z); + + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode + lua_pop(L,2); + + i->setScale(vector3df(x,y,z)); + return 1; +} + +/*** +Get the scale of this scene element. +@function iscenenode:getscale() +@treturn vector3d The scale scale of this element. +*/ +//iscenegetscale() +int iscenegetscale(lua_State *L){ + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode + lua_pop(L,2); + + vector3df scale = i->getScale(); + double x,y,z; + x = scale.X; + y = scale.Y; + z = scale.Z; + + pushvector3d(L,x,y,z); + return 1; +} + +/*** +Get the scale of this scene element. +@function iscenenode:getscale() +@treturn vector3d The scale scale of this element. +*/ +//iscenenode:remove() +int isceneremove(lua_State *L){ + lua_getfield(L,-1,"node"); + ISceneNode *i = (ISceneNode*)lua_touserdata(L,-1);//{node=ud_ISceneNode},ud_ISceneNode + lua_pop(L,2); + + i->remove(); + + return 1; +} + extern const luaL_reg igeneric_m[] = { {"getpos", iscenegetpos}, {"setpos", iscenesetpos}, {"getang", iscenegetangle}, {"setang", iscenesetangle}, - {"setmaterial", iscenesetmaterial}, + {"setmaterialtexture", iscenesetmaterial}, + {"getname", iscenegetname}, + {"setname", iscenesetname}, + {"setscale", iscenesetscale}, + {"getscale", iscenegetscale}, + {"remove", isceneremove}, {0, 0}, }; |
