//#include //#include //#include //#include //#include //#include //#include //extern "C" { //#include //#include //#include //} //#include //#include //#include "../gameparts.hpp" //#include "cbphysbox.hpp" //#include "cbphysmodel.hpp" //#include //#include //#include //#include //using namespace irr; //using namespace scene; //using namespace core; //using namespace video; //extern IrrlichtDevice* device; //extern btDiscreteDynamicsWorld* World; //extern std::list Objects; ////newbphysmodel("graphicfile","physicfile",mass,[,{position}][,{lookat}]) //static int newbphysmodel(lua_State* L){ //printf("Creating bphysmodel\n"); //int nargs = lua_gettop(L); //double lx,ly,lz; //double x,y,z; //if(nargs > 4){ ////"graphicsfile","physicsfile",{position},{lookat} //popvector3d(L,&lx,&ly,&lz); //}else{ //lx = 1; ly = 1; lz = 1; //} //if(nargs > 3){ ////"graphicsfile","physicsfile",{position} //popvector3d(L,&x,&y,&z); //}else{ //x = 0; y = 0; z = 0; //} ////"graphicsfile","physicsfile",mass //double mass = lua_tonumber(L,-1); //const char *ppath = lua_tostring(L,-2); //const char *gpath = lua_tostring(L,-3); //lua_pop(L,3);// //ISceneManager *smgr = device->getSceneManager(); //printf("bphysnode, creating the scene node\n"); ////Create the scene node //IMesh *gmesh = smgr->getMesh(gpath); //ISceneNode *node = smgr->addMeshSceneNode(gmesh,0,-1,vector3df(x,y,z)); //printf("bphysnode, createing the physics body\n"); ////Create the physics body //lua_pushstring(L,ppath); //lua_pushnumber(L,mass); //pushvector3d(L,x,y,z); //pushvector3d(L,lx,ly,lz); //printf("About to makebphysmodel\n"); //makebphysmodel(L); //printf("done makebphysmodel\n"); //btRigidBody *rb = (btRigidBody*)lua_touserdata(L,-1); ////Create the lua representation //lua_newtable(L);// //lua_pushlightuserdata(L,rb); //lua_setfield(L,-2,"collider");//{rb=ud_rb} //lua_pushstring(L,"rigidbody"); //lua_setfield(L,-2,"type");//{rb=ud_rb, type="rigidbody"} //lua_pushlightuserdata(L,node); //lua_setfield(L,-2,"node");//{rb=ud_rb, node=ud_node, type="rigidbody"} //luaL_getmetatable(L,"phys.physmodel"); //lua_setmetatable(L,-2); //lua_getglobal(L,"phys");//{rb},{phys} //lua_getfield(L,-1,"colliders");//{rb},{phys},{colliders} //lua_pushlightuserdata(L,rb);//{rb},{phys},{colliders},ud_rb //lua_pushvalue(L,-4);//{rb},{phys},{colliders},ud_rb,{rb} //lua_settable(L,-3);//{rb},{phys},{colliders} //lua_pop(L,2);//{rb} //printf("finished creating the lua representation\n"); //return 1; //} //static const luaL_reg bphysmodel_f[] = { //{"newphysmodel", newbphysmodel}, //{0,0}, //}; //static const luaL_reg bphysmodel_m[] = { //{0, 0}, //}; //int cbphysmodel_register(lua_State* L){ ////printf("bphysmodel registered\n"); //luaL_newmetatable(L, "phys.physmodel");//{} //luaL_register(L,NULL,bcollider_m); //luaL_register(L,NULL,bphysmodel_m); //luaL_register(L,NULL,igeneric_m); //Inherit all the things to do with scene nodes //lua_getglobal(L,"phys"); //luaL_register(L,NULL,bphysmodel_f); //return 1; //}