aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/scene/igeneric.cpp
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-12-26 00:57:52 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-12-26 00:57:52 -0500
commit35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940 (patch)
treed345f620b51ae1ad1d7923e572a6b07ed8731ee5 /src/client/lua_api/scene/igeneric.cpp
parentcc12503339004bae2f945e7f7339fc845b2a194f (diff)
downloadbrokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.tar.gz
brokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.tar.bz2
brokengine-35b7c646fd7f80b64c1ef49b6d81f9df9bc1b940.zip
Major update
Diffstat (limited to 'src/client/lua_api/scene/igeneric.cpp')
-rw-r--r--src/client/lua_api/scene/igeneric.cpp80
1 files changed, 38 insertions, 42 deletions
diff --git a/src/client/lua_api/scene/igeneric.cpp b/src/client/lua_api/scene/igeneric.cpp
index fc32e83..0d061d2 100644
--- a/src/client/lua_api/scene/igeneric.cpp
+++ b/src/client/lua_api/scene/igeneric.cpp
@@ -7,6 +7,7 @@ extern "C" {
#include <irrlicht.h>
#include "igeneric.hpp"
#include "../gameparts.hpp"
+#include "../../../shared/lua_api/common.h"
using namespace irr;
using namespace core;
@@ -15,63 +16,57 @@ using namespace video;
extern IrrlichtDevice* device;
+/*
static LISceneNode* toiscenenode(lua_State* L, int index){
LISceneNode* ret = (LISceneNode*)lua_touserdata(L,index);
if(ret == NULL)
luaL_typerror(L,index,"LISceneNode");
return ret;
}
+*/
-int iscenegetpos(lua_State* L){
- ISceneNode* i = toiscenenode(L,1)->n;
+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
vector3df pos = i->getAbsolutePosition();
+ lua_pop(L,2);
+ pushvector3d(L,pos.X,pos.Y,pos.Z);
- lua_createtable(L,3,0);
-
- lua_pushnumber(L,1);
- lua_pushnumber(L,pos.X);
- lua_settable(L,-3);
-
- lua_pushnumber(L,2);
- lua_pushnumber(L,pos.Y);
- lua_settable(L,-3);
+ return 1;
+}
- lua_pushnumber(L,3);
- lua_pushnumber(L,pos.Z);
- lua_settable(L,-3);
-
+int iscenesetpos(lua_State* L){//{node=ud_IMeshSceneNode},{x,y,z}
+ double x,y,z;
+ popvector3d(L,&x,&y,&z);//{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
+ 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);
+ lua_pop(L,2);//
+ return 0;
+}
+
+int iscenegetangle(lua_State* L){//{node=ud-IMeshSceneNode}
+ lua_getfield(L,-1,"node");
+ ISceneNode* i = (ISceneNode*)lua_touserdata(L,-1);
+ irr::core::vector3df ang = i->getRotation();
+ pushvector3d(L,ang.X, ang.Y, ang.Z);
return 1;
}
-int iscenesetpos(lua_State* L){
-
- ISceneNode* i = toiscenenode(L,1)->n;
-
- lua_pushnumber(L,1);
- lua_gettable(L,-2);
- f32 x = (f32)lua_tonumber(L,-1);
- lua_pop(L,1);
-
- lua_pushnumber(L,2);
- lua_gettable(L,-2);
- f32 y = (f32)lua_tonumber(L,-1);
- lua_pop(L,1);
-
- lua_pushnumber(L,3);
- lua_gettable(L,-2);
- f32 z = (f32)lua_tonumber(L,-1);
- lua_pop(L,1);
-
- printf("Trying to set pos of %p to %f %f %f",i,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);
-
- return 0;
+int iscenesetangle(lua_State* L){//{node=ud_ISceneNode},{x,y,z}
+ double x,y,z;
+ popvector3d(L,&x,&y,&z);
+ lua_getfield(L,-1,"node");
+ ISceneNode* i = (ISceneNode*)lua_touserdata(L,-1);
+ irr::core::vector3df ang = irr::core::vector3df(x,y,z);
+ i->setRotation(ang);
+ return 0;
}
+/*
int iscenesetmaterial(lua_State* L){
ISceneNode* i = toiscenenode(L,1)->n;
const char* s = luaL_optstring(L,2,"error.png");
@@ -81,3 +76,4 @@ int iscenesetmaterial(lua_State* L){
return 0;
}
+*/