diff options
Diffstat (limited to 'src/client/lua_api/scene')
| -rw-r--r-- | src/client/lua_api/scene/icamera.cpp | 65 | ||||
| -rw-r--r-- | src/client/lua_api/scene/igeneric.cpp | 2 | ||||
| -rw-r--r-- | src/client/lua_api/scene/imesh.cpp | 2 |
3 files changed, 22 insertions, 47 deletions
diff --git a/src/client/lua_api/scene/icamera.cpp b/src/client/lua_api/scene/icamera.cpp index 3c5e2b0..ec9469d 100644 --- a/src/client/lua_api/scene/icamera.cpp +++ b/src/client/lua_api/scene/icamera.cpp @@ -14,6 +14,7 @@ extern "C" { #include "../gameparts.hpp" #include "icamera.hpp" #include "igeneric.hpp" +#include "../../../shared/lua_api/common.h" using namespace irr; using namespace scene; @@ -97,60 +98,33 @@ static int newiscenefpscamera(lua_State* L){// static int newiscenecamera(lua_State* L){ printf("Createing camera!\n"); int nargs = lua_gettop(L); + double px,py,pz; + double lx,ly,lz; + + int parent = lua_tonumber(L,-1); + lua_pop(L,1); //The position of the camera - int startx = luaL_optint(L,1,0); - int starty = luaL_optint(L,2,0); - int startz = luaL_optint(L,3,0); - int endx = luaL_optint(L,4,startx+100); - int endy = luaL_optint(L,5,starty+100); - int endz = luaL_optint(L,6,startz+100); - - //Label and tooltip - wchar_t* label; - const char* labelopt = luaL_optstring(L,5,"Label"); - int bls = strlen(labelopt); - label = (wchar_t*)malloc(sizeof(wchar_t)*(bls)); - mbstowcs(label,labelopt,bls); - printf("Got the string option\n"); - + popvector3d(L,&px,&py,&pz); + printf("position of camera was %f,%f,%f\n",px,py,pz); + popvector3d(L,&lx,&ly,&lz); + printf("lookat of camera was %f,%f,%f\n",lx,ly,lz); + //If the element has a parrent - if(nargs >= 6){ - printf("got the parrent\n"); + if(nargs >= 3){ + printf("got the parrent\n"); } //Create the camera ISceneManager* smgr = device->getSceneManager(); - //IGUIEnvironment* env = device->getGUIEnvironment(); - //printf("Createing button with data %d %d %d %d, %p, %d, %s, %s\n", startx,starty,endx,endy,guielements[parent],gui_elenum,button_label,button_tooltip); - //Create the label - //IGUIStaticText* llabel = (IGUIStaticText*) env->addStaticText(label,core::rect<s32>(startx,starty,endx,endy),false,false, guielements[parent], gui_elenum++, false); - ICameraSceneNode* cam = smgr->addCameraSceneNode(0, vector3df(startx,starty,startz), vector3df(endx,endy,endz)); + ICameraSceneNode* cam = smgr->addCameraSceneNode(0, vector3df(px,py,pz), vector3df(lx,ly,lz)); printf("Registered the camera!\n"); + lua_newtable(L); + lua_pushlightuserdata(L,cam); + lua_setfield(L,-2,"node"); + luaL_getmetatable(L,"scene.icamera"); + lua_setmetatable(L,-2); - //Register it's callback - //registerguicallback(llabel,EGET_ELEMENT_HOVERED,iguilabelevent); - - //Create it's lua representation - LISceneNode* lcam = (LISceneNode*)lua_newuserdata(L, sizeof(LISceneNode)); - int tref = luaL_ref(L,LUA_REGISTRYINDEX); - //iguielements[lcam] = tref; - //lua_rawgeti(L,LUA_REGISTRYINDEX,tref);//Put it back on the stack since luaL_ref pops the object. - - //Set it's metatable - luaL_getmetatable(L, "scene.iscenecamera"); - lua_setmetatable(L, -2); - - //Create the struct - lcam->n = cam; - lcam->funcmap = hashmap_new(); - lcam->type = "iscenecamera"; - - //Free up anything made in this function - //free(label); - - //Put it on top and return it - lua_rawgeti(L,LUA_REGISTRYINDEX,tref); return 1; } @@ -167,6 +141,7 @@ static const luaL_reg imayacamera_m[] = { }; static const luaL_reg ifpscamera_m[] = { + {"getpos", iscenegetpos}, {0,0}, }; diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp index 0d061d2..8280008 100644 --- a/src/client/lua_api/scene/igeneric.cpp +++ b/src/client/lua_api/scene/igeneric.cpp @@ -43,7 +43,7 @@ int iscenesetpos(lua_State* L){//{node=ud_IMeshSceneNode},{x,y,z} i->setPosition(vector3df(x,y,z)); i->updateAbsolutePosition(); vector3df pos = i->getAbsolutePosition(); - printf("After setting pos, new pos is %f %f %f",pos.X,pos.Y,pos.Z); + //printf("After setting pos, new pos is %f %f %f",pos.X,pos.Y,pos.Z); lua_pop(L,2);// return 0; } diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp index 3f3ae24..f391431 100644 --- a/src/client/lua_api/scene/imesh.cpp +++ b/src/client/lua_api/scene/imesh.cpp @@ -71,7 +71,7 @@ void makenewiscenecube(lua_State* L){ popvector3d(L,&x,&y,&z);//{v3 size} double sx,sy,sz; popvector3d(L,&sx,&sy,&sz);//{} - IMeshSceneNode* n = device->getSceneManager()->addCubeSceneNode(10,0,-1,core::vector3df(x,y,z),core::vector3df(0,0,0),core::vector3df(sx,sy,sz)); + IMeshSceneNode* n = device->getSceneManager()->addCubeSceneNode(1,0,-1,core::vector3df(x,y,z),core::vector3df(0,0,0),core::vector3df(sx,sy,sz)); lua_pushlightuserdata(L,n); } |
