aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/scene
diff options
context:
space:
mode:
authorAlexander <alex@cogarr.net>2019-04-24 21:16:08 -0400
committerAlexander <alex@cogarr.net>2019-04-24 21:16:08 -0400
commit3d60e1432ec43ade4aa61b5a70dd6b8975417e9f (patch)
tree954719a0f4a27fe42f9d8113844a21b79ae70f5d /src/client/lua_api/scene
parent42bedce123739287339a95626675ffda3a1ce8e7 (diff)
downloadbrokengine-3d60e1432ec43ade4aa61b5a70dd6b8975417e9f.tar.gz
brokengine-3d60e1432ec43ade4aa61b5a70dd6b8975417e9f.tar.bz2
brokengine-3d60e1432ec43ade4aa61b5a70dd6b8975417e9f.zip
updates
Diffstat (limited to 'src/client/lua_api/scene')
-rw-r--r--src/client/lua_api/scene/icamera.cpp51
-rw-r--r--src/client/lua_api/scene/imesh.cpp7
2 files changed, 47 insertions, 11 deletions
diff --git a/src/client/lua_api/scene/icamera.cpp b/src/client/lua_api/scene/icamera.cpp
index 482bf31..003f2ad 100644
--- a/src/client/lua_api/scene/icamera.cpp
+++ b/src/client/lua_api/scene/icamera.cpp
@@ -42,6 +42,7 @@ static int newiscenemayacamera(lua_State* L){
static int newiscenefpscamera(lua_State* L){//
ISceneManager* smgr = device->getSceneManager();
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS();
+ //cam->bindTargetAndRotation(false);
lua_newtable(L);//{}
lua_pushlightuserdata(L,cam);//{},ud_cam
lua_setfield(L,-2,"node");
@@ -97,21 +98,52 @@ static int newiscenecamera(lua_State* L){
return 1;
}
+//camera:bind_target(bool) :: nil
+static int icamerabindtarget(lua_State *L){
+ int should_bind = lua_toboolean(L,-1);//{node=ud_cam},bool_shouldbind
+ printf("Bind target called %d\n",should_bind);
+ lua_pop(L,1);//{node=ud_cam}
+ lua_getfield(L,-1,"node");//{node=ud_cam},ud_cam
+ ICameraSceneNode *cam = (ICameraSceneNode*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+ cam->bindTargetAndRotation(should_bind == 1);
+ return 0;
+}
+
+//camera:gettarget() :: v3f
+static int icameragettarget(lua_State *L){
+ lua_getfield(L,-1,"node");
+ ICameraSceneNode *cam = (ICameraSceneNode*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+ vector3df targ = cam->getTarget();
+ pushvector3d(L,targ.X, targ.Y, targ.Z);
+ return 1;
+}
+
+//camera:settarget(v3f)
+static int icamerasettarget(lua_State *L){
+ double x,y,z;
+ popvector3d(L,&x,&y,&z);
+ lua_getfield(L,-1,"node");
+ ICameraSceneNode *cam = (ICameraSceneNode*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+ cam->setTarget(vector3df(x,y,z));
+ return 0;
+}
+
static const luaL_reg icamera_m[] = {
- {"getpos", iscenegetpos},
- {"setpos", iscenesetpos},
- {"getangle", iscenegetangle},
- {"setangle", iscenesetangle},
- {0, 0},
+ {"bindtarget", icamerabindtarget},
+ {"gettarget", icameragettarget},
+ {"settarget", icamerasettarget},
+ {0,0},
};
static const luaL_reg imayacamera_m[] = {
- {0,0},
+ {0,0},
};
static const luaL_reg ifpscamera_m[] = {
- {"getpos", iscenegetpos},
- {0,0},
+ {0,0},
};
void icamera_register(lua_State* L){
@@ -119,6 +151,7 @@ void icamera_register(lua_State* L){
luaL_newmetatable(L, "scene.icamera");//scene.icamera
lua_newtable(L);//scene.icamera, {}
luaL_register(L,NULL,icamera_m);//scene.icamera, {}
+ luaL_register(L,NULL,igeneric_m);//scene.icamera, {}
lua_setfield(L,-2,"__index");//scene.icamera
lua_pop(L,1);//
@@ -126,6 +159,7 @@ void icamera_register(lua_State* L){
lua_newtable(L);//scene.imayascamera,{}
luaL_register(L,NULL,imayacamera_m);//scene.imayascamera,{}
luaL_register(L,NULL,icamera_m);//scene.imayascamera,{}
+ luaL_register(L,NULL,igeneric_m);
lua_setfield(L,-2,"__index");//scene.imayascamera
lua_pop(L,1);//
@@ -133,6 +167,7 @@ void icamera_register(lua_State* L){
lua_newtable(L);//scene.ifpscamera, {}
luaL_register(L,NULL,ifpscamera_m);//scene.ifpscamera,{}
luaL_register(L,NULL,icamera_m);//scene.ifpscamera,{}
+ luaL_register(L,NULL,igeneric_m);
lua_setfield(L,-2,"__index");//scene.ifpscamera
lua_pop(L,1);//
diff --git a/src/client/lua_api/scene/imesh.cpp b/src/client/lua_api/scene/imesh.cpp
index c6ced65..7a72edf 100644
--- a/src/client/lua_api/scene/imesh.cpp
+++ b/src/client/lua_api/scene/imesh.cpp
@@ -82,9 +82,9 @@ int newiscenecube(lua_State* L){//{v3 size}, {v3 origin}
}
static const luaL_reg imesh_m[] = {
- {"setMaterial", iscenesetmaterial},
- {"getpos", iscenegetpos},
- {"setpos", iscenesetpos},
+ //{"setMaterial", iscenesetmaterial},
+ //{"getpos", iscenegetpos},
+ //{"setpos", iscenesetpos},
// {"remove", removeiguielement},
{0, 0},
};
@@ -98,6 +98,7 @@ void imesh_register(lua_State* L){
luaL_newmetatable(L, "scene.imesh");//scene.icamera
lua_newtable(L);//scene.icamera,{}
luaL_register(L,NULL,imesh_m);//scene.icamera,{}
+ luaL_register(L,NULL,igeneric_m);
lua_setfield(L,-2,"__index");//scene.icamera
lua_pop(L,1);//