diff options
Diffstat (limited to 'src/client/lua_api/scene/icamera.cpp')
| -rw-r--r-- | src/client/lua_api/scene/icamera.cpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/client/lua_api/scene/icamera.cpp b/src/client/lua_api/scene/icamera.cpp index ce54ef2..5a4e3a2 100644 --- a/src/client/lua_api/scene/icamera.cpp +++ b/src/client/lua_api/scene/icamera.cpp @@ -22,8 +22,8 @@ using namespace core; extern IrrlichtDevice* device; static LISceneNode* checkiscenecamera(lua_State* L, int index){ - void* ud = luaL_checkudata(L,index,"scene.icamera"); - luaL_argcheck(L,ud != NULL, index, "'scene.icamera' expected"); + void* ud = luaL_checkudata(L,index,"scene.iscenecamera"); + luaL_argcheck(L,ud != NULL, index, "'scene.iscenecamera' expected"); return (LISceneNode*) ud; } @@ -31,6 +31,42 @@ static LISceneNode* checkiscenecamera(lua_State* L){ return checkiscenecamera(L,1); } +static LISceneNode* checkismayacamera(lua_State* L, int index){ + void* ud = luaL_checkudata(L,index,"scene.iscenemayacamera"); + luaL_argcheck(L,ud != NULL, index, "'scene.iscenemayacamera' expected"); + return (LISceneNode*) ud; +} + +static LISceneNode* checkismayacamera(lua_State* L){ + return checkismayacamera(L,1); +} + +static int newiscenemayacamera(lua_State* L){ + printf("createing maya camera!\n"); + int nargs = lua_gettop(L); + ISceneManager* smgr = device->getSceneManager(); + ICameraSceneNode* cam = smgr->addCameraSceneNodeMaya(); + printf("cam is %p",cam); + LISceneNode* lcam = (LISceneNode*)lua_newuserdata(L, sizeof(LISceneNode)); + int tref = luaL_ref(L,LUA_REGISTRYINDEX); + + //Set it's metatable + luaL_getmetatable(L, "scene.iscenemayacamera"); + lua_setmetatable(L, -2); + + //Create the struct + lcam->n = cam; + lcam->funcmap = hashmap_new(); + lcam->type = "iscenemayacamera"; + + //Free up anything made in this function + //free(label); + + //Put it on top and return it + lua_rawgeti(L,LUA_REGISTRYINDEX,tref); + return 1; +} + //iscenecamera.new(Vector position, Vector lookat, parrent) static int newiscenecamera(lua_State* L){ printf("Createing camera!\n"); @@ -110,6 +146,15 @@ static const luaL_reg icamera_m[] = { {0, 0}, }; +static const luaL_reg imayacamera_f[] = { + {"new", newiscenemayacamera}, + {0,0}, +}; + +static const luaL_reg imayacamera_m[] = { + {0,0}, +}; + int icamera_register(lua_State* L, IrrlichtDevice* d){ device = d; @@ -117,7 +162,6 @@ int icamera_register(lua_State* L, IrrlichtDevice* d){ printf("icamera registered\n"); luaL_newmetatable(L, "scene.icamera"); - luaL_register(L,"icamera",icamera_f); lua_pushstring(L,"__index"); @@ -131,6 +175,11 @@ int icamera_register(lua_State* L, IrrlichtDevice* d){ lua_settable(L,-4); luaL_register(L, NULL, icamera_m); + //End of camera + + //Start of maya camera + luaL_newmetatable(L,"scene.imayacamera"); + luaL_register(L,"imayacamera",imayacamera_f); return 1; } |
