lua_PhysicsController.cpp 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsController.h"
  4. #include "Base.h"
  5. #include "Bundle.h"
  6. #include "Game.h"
  7. #include "MeshPart.h"
  8. #include "PhysicsCharacter.h"
  9. #include "PhysicsController.h"
  10. #include "PhysicsRigidBody.h"
  11. #include "ScriptController.h"
  12. #include "ScriptTarget.h"
  13. #include "lua_PhysicsControllerListenerEventType.h"
  14. namespace gameplay
  15. {
  16. void luaRegister_PhysicsController()
  17. {
  18. const luaL_Reg lua_members[] =
  19. {
  20. {"addScriptCallback", lua_PhysicsController_addScriptCallback},
  21. {"addStatusListener", lua_PhysicsController_addStatusListener},
  22. {"createFixedConstraint", lua_PhysicsController_createFixedConstraint},
  23. {"createGenericConstraint", lua_PhysicsController_createGenericConstraint},
  24. {"createHingeConstraint", lua_PhysicsController_createHingeConstraint},
  25. {"createSocketConstraint", lua_PhysicsController_createSocketConstraint},
  26. {"createSpringConstraint", lua_PhysicsController_createSpringConstraint},
  27. {"drawDebug", lua_PhysicsController_drawDebug},
  28. {"getGravity", lua_PhysicsController_getGravity},
  29. {"rayTest", lua_PhysicsController_rayTest},
  30. {"removeScriptCallback", lua_PhysicsController_removeScriptCallback},
  31. {"removeStatusListener", lua_PhysicsController_removeStatusListener},
  32. {"setGravity", lua_PhysicsController_setGravity},
  33. {"sweepTest", lua_PhysicsController_sweepTest},
  34. {NULL, NULL}
  35. };
  36. const luaL_Reg* lua_statics = NULL;
  37. std::vector<std::string> scopePath;
  38. ScriptUtil::registerClass("PhysicsController", lua_members, NULL, NULL, lua_statics, scopePath);
  39. }
  40. static PhysicsController* getInstance(lua_State* state)
  41. {
  42. void* userdata = luaL_checkudata(state, 1, "PhysicsController");
  43. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsController' expected.");
  44. return (PhysicsController*)((ScriptUtil::LuaObject*)userdata)->instance;
  45. }
  46. int lua_PhysicsController_addScriptCallback(lua_State* state)
  47. {
  48. // Get the number of parameters.
  49. int paramCount = lua_gettop(state);
  50. // Attempt to match the parameters to a valid binding.
  51. switch (paramCount)
  52. {
  53. case 3:
  54. {
  55. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  56. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  57. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  58. {
  59. // Get parameter 1 off the stack.
  60. std::string param1 = ScriptUtil::getString(2, true);
  61. // Get parameter 2 off the stack.
  62. std::string param2 = ScriptUtil::getString(3, true);
  63. PhysicsController* instance = getInstance(state);
  64. instance->addScriptCallback(param1, param2);
  65. return 0;
  66. }
  67. else
  68. {
  69. lua_pushstring(state, "lua_PhysicsController_addScriptCallback - Failed to match the given parameters to a valid function signature.");
  70. lua_error(state);
  71. }
  72. break;
  73. }
  74. default:
  75. {
  76. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  77. lua_error(state);
  78. break;
  79. }
  80. }
  81. return 0;
  82. }
  83. int lua_PhysicsController_addStatusListener(lua_State* state)
  84. {
  85. // Get the number of parameters.
  86. int paramCount = lua_gettop(state);
  87. // Attempt to match the parameters to a valid binding.
  88. switch (paramCount)
  89. {
  90. case 2:
  91. {
  92. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  93. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  94. {
  95. // Get parameter 1 off the stack.
  96. ScriptUtil::LuaArray<PhysicsController::Listener> param1 = ScriptUtil::getObjectPointer<PhysicsController::Listener>(2, "PhysicsControllerListener", false);
  97. PhysicsController* instance = getInstance(state);
  98. instance->addStatusListener(param1);
  99. return 0;
  100. }
  101. else
  102. {
  103. lua_pushstring(state, "lua_PhysicsController_addStatusListener - Failed to match the given parameters to a valid function signature.");
  104. lua_error(state);
  105. }
  106. break;
  107. }
  108. default:
  109. {
  110. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  111. lua_error(state);
  112. break;
  113. }
  114. }
  115. return 0;
  116. }
  117. int lua_PhysicsController_createFixedConstraint(lua_State* state)
  118. {
  119. // Get the number of parameters.
  120. int paramCount = lua_gettop(state);
  121. // Attempt to match the parameters to a valid binding.
  122. switch (paramCount)
  123. {
  124. case 2:
  125. {
  126. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  127. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  128. {
  129. // Get parameter 1 off the stack.
  130. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  131. PhysicsController* instance = getInstance(state);
  132. void* returnPtr = (void*)instance->createFixedConstraint(param1);
  133. if (returnPtr)
  134. {
  135. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  136. object->instance = returnPtr;
  137. object->owns = false;
  138. luaL_getmetatable(state, "PhysicsFixedConstraint");
  139. lua_setmetatable(state, -2);
  140. }
  141. else
  142. {
  143. lua_pushnil(state);
  144. }
  145. return 1;
  146. }
  147. else
  148. {
  149. lua_pushstring(state, "lua_PhysicsController_createFixedConstraint - Failed to match the given parameters to a valid function signature.");
  150. lua_error(state);
  151. }
  152. break;
  153. }
  154. case 3:
  155. {
  156. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  157. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  158. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  159. {
  160. // Get parameter 1 off the stack.
  161. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  162. // Get parameter 2 off the stack.
  163. ScriptUtil::LuaArray<PhysicsRigidBody> param2 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(3, "PhysicsRigidBody", false);
  164. PhysicsController* instance = getInstance(state);
  165. void* returnPtr = (void*)instance->createFixedConstraint(param1, param2);
  166. if (returnPtr)
  167. {
  168. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  169. object->instance = returnPtr;
  170. object->owns = false;
  171. luaL_getmetatable(state, "PhysicsFixedConstraint");
  172. lua_setmetatable(state, -2);
  173. }
  174. else
  175. {
  176. lua_pushnil(state);
  177. }
  178. return 1;
  179. }
  180. else
  181. {
  182. lua_pushstring(state, "lua_PhysicsController_createFixedConstraint - Failed to match the given parameters to a valid function signature.");
  183. lua_error(state);
  184. }
  185. break;
  186. }
  187. default:
  188. {
  189. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  190. lua_error(state);
  191. break;
  192. }
  193. }
  194. return 0;
  195. }
  196. int lua_PhysicsController_createGenericConstraint(lua_State* state)
  197. {
  198. // Get the number of parameters.
  199. int paramCount = lua_gettop(state);
  200. // Attempt to match the parameters to a valid binding.
  201. switch (paramCount)
  202. {
  203. case 2:
  204. {
  205. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  206. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  207. {
  208. // Get parameter 1 off the stack.
  209. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  210. PhysicsController* instance = getInstance(state);
  211. void* returnPtr = (void*)instance->createGenericConstraint(param1);
  212. if (returnPtr)
  213. {
  214. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  215. object->instance = returnPtr;
  216. object->owns = false;
  217. luaL_getmetatable(state, "PhysicsGenericConstraint");
  218. lua_setmetatable(state, -2);
  219. }
  220. else
  221. {
  222. lua_pushnil(state);
  223. }
  224. return 1;
  225. }
  226. else
  227. {
  228. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  229. lua_error(state);
  230. }
  231. break;
  232. }
  233. case 3:
  234. {
  235. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  236. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  237. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  238. {
  239. // Get parameter 1 off the stack.
  240. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  241. // Get parameter 2 off the stack.
  242. ScriptUtil::LuaArray<PhysicsRigidBody> param2 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(3, "PhysicsRigidBody", false);
  243. PhysicsController* instance = getInstance(state);
  244. void* returnPtr = (void*)instance->createGenericConstraint(param1, param2);
  245. if (returnPtr)
  246. {
  247. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  248. object->instance = returnPtr;
  249. object->owns = false;
  250. luaL_getmetatable(state, "PhysicsGenericConstraint");
  251. lua_setmetatable(state, -2);
  252. }
  253. else
  254. {
  255. lua_pushnil(state);
  256. }
  257. return 1;
  258. }
  259. else
  260. {
  261. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  262. lua_error(state);
  263. }
  264. break;
  265. }
  266. case 4:
  267. {
  268. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  269. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  270. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  271. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  272. {
  273. // Get parameter 1 off the stack.
  274. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  275. // Get parameter 2 off the stack.
  276. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  277. // Get parameter 3 off the stack.
  278. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  279. PhysicsController* instance = getInstance(state);
  280. void* returnPtr = (void*)instance->createGenericConstraint(param1, *param2, *param3);
  281. if (returnPtr)
  282. {
  283. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  284. object->instance = returnPtr;
  285. object->owns = false;
  286. luaL_getmetatable(state, "PhysicsGenericConstraint");
  287. lua_setmetatable(state, -2);
  288. }
  289. else
  290. {
  291. lua_pushnil(state);
  292. }
  293. return 1;
  294. }
  295. else
  296. {
  297. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  298. lua_error(state);
  299. }
  300. break;
  301. }
  302. case 5:
  303. {
  304. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  305. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  306. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  307. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  308. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL))
  309. {
  310. // Get parameter 1 off the stack.
  311. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  312. // Get parameter 2 off the stack.
  313. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  314. // Get parameter 3 off the stack.
  315. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  316. // Get parameter 4 off the stack.
  317. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  318. PhysicsController* instance = getInstance(state);
  319. void* returnPtr = (void*)instance->createGenericConstraint(param1, *param2, *param3, param4);
  320. if (returnPtr)
  321. {
  322. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  323. object->instance = returnPtr;
  324. object->owns = false;
  325. luaL_getmetatable(state, "PhysicsGenericConstraint");
  326. lua_setmetatable(state, -2);
  327. }
  328. else
  329. {
  330. lua_pushnil(state);
  331. }
  332. return 1;
  333. }
  334. else
  335. {
  336. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  337. lua_error(state);
  338. }
  339. break;
  340. }
  341. case 6:
  342. {
  343. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  344. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  345. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  346. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  347. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL) &&
  348. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL))
  349. {
  350. // Get parameter 1 off the stack.
  351. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  352. // Get parameter 2 off the stack.
  353. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  354. // Get parameter 3 off the stack.
  355. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  356. // Get parameter 4 off the stack.
  357. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  358. // Get parameter 5 off the stack.
  359. ScriptUtil::LuaArray<Quaternion> param5 = ScriptUtil::getObjectPointer<Quaternion>(6, "Quaternion", true);
  360. PhysicsController* instance = getInstance(state);
  361. void* returnPtr = (void*)instance->createGenericConstraint(param1, *param2, *param3, param4, *param5);
  362. if (returnPtr)
  363. {
  364. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  365. object->instance = returnPtr;
  366. object->owns = false;
  367. luaL_getmetatable(state, "PhysicsGenericConstraint");
  368. lua_setmetatable(state, -2);
  369. }
  370. else
  371. {
  372. lua_pushnil(state);
  373. }
  374. return 1;
  375. }
  376. else
  377. {
  378. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  379. lua_error(state);
  380. }
  381. break;
  382. }
  383. case 7:
  384. {
  385. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  386. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  387. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  388. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  389. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL) &&
  390. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  391. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL))
  392. {
  393. // Get parameter 1 off the stack.
  394. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  395. // Get parameter 2 off the stack.
  396. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  397. // Get parameter 3 off the stack.
  398. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  399. // Get parameter 4 off the stack.
  400. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  401. // Get parameter 5 off the stack.
  402. ScriptUtil::LuaArray<Quaternion> param5 = ScriptUtil::getObjectPointer<Quaternion>(6, "Quaternion", true);
  403. // Get parameter 6 off the stack.
  404. ScriptUtil::LuaArray<Vector3> param6 = ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true);
  405. PhysicsController* instance = getInstance(state);
  406. void* returnPtr = (void*)instance->createGenericConstraint(param1, *param2, *param3, param4, *param5, *param6);
  407. if (returnPtr)
  408. {
  409. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  410. object->instance = returnPtr;
  411. object->owns = false;
  412. luaL_getmetatable(state, "PhysicsGenericConstraint");
  413. lua_setmetatable(state, -2);
  414. }
  415. else
  416. {
  417. lua_pushnil(state);
  418. }
  419. return 1;
  420. }
  421. else
  422. {
  423. lua_pushstring(state, "lua_PhysicsController_createGenericConstraint - Failed to match the given parameters to a valid function signature.");
  424. lua_error(state);
  425. }
  426. break;
  427. }
  428. default:
  429. {
  430. lua_pushstring(state, "Invalid number of parameters (expected 2, 3, 4, 5, 6 or 7).");
  431. lua_error(state);
  432. break;
  433. }
  434. }
  435. return 0;
  436. }
  437. int lua_PhysicsController_createHingeConstraint(lua_State* state)
  438. {
  439. // Get the number of parameters.
  440. int paramCount = lua_gettop(state);
  441. // Attempt to match the parameters to a valid binding.
  442. switch (paramCount)
  443. {
  444. case 4:
  445. {
  446. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  447. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  448. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  449. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  450. {
  451. // Get parameter 1 off the stack.
  452. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  453. // Get parameter 2 off the stack.
  454. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  455. // Get parameter 3 off the stack.
  456. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  457. PhysicsController* instance = getInstance(state);
  458. void* returnPtr = (void*)instance->createHingeConstraint(param1, *param2, *param3);
  459. if (returnPtr)
  460. {
  461. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  462. object->instance = returnPtr;
  463. object->owns = false;
  464. luaL_getmetatable(state, "PhysicsHingeConstraint");
  465. lua_setmetatable(state, -2);
  466. }
  467. else
  468. {
  469. lua_pushnil(state);
  470. }
  471. return 1;
  472. }
  473. else
  474. {
  475. lua_pushstring(state, "lua_PhysicsController_createHingeConstraint - Failed to match the given parameters to a valid function signature.");
  476. lua_error(state);
  477. }
  478. break;
  479. }
  480. case 5:
  481. {
  482. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  483. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  484. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  485. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  486. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL))
  487. {
  488. // Get parameter 1 off the stack.
  489. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  490. // Get parameter 2 off the stack.
  491. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  492. // Get parameter 3 off the stack.
  493. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  494. // Get parameter 4 off the stack.
  495. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  496. PhysicsController* instance = getInstance(state);
  497. void* returnPtr = (void*)instance->createHingeConstraint(param1, *param2, *param3, param4);
  498. if (returnPtr)
  499. {
  500. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  501. object->instance = returnPtr;
  502. object->owns = false;
  503. luaL_getmetatable(state, "PhysicsHingeConstraint");
  504. lua_setmetatable(state, -2);
  505. }
  506. else
  507. {
  508. lua_pushnil(state);
  509. }
  510. return 1;
  511. }
  512. else
  513. {
  514. lua_pushstring(state, "lua_PhysicsController_createHingeConstraint - Failed to match the given parameters to a valid function signature.");
  515. lua_error(state);
  516. }
  517. break;
  518. }
  519. case 6:
  520. {
  521. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  522. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  523. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  524. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  525. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL) &&
  526. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL))
  527. {
  528. // Get parameter 1 off the stack.
  529. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  530. // Get parameter 2 off the stack.
  531. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  532. // Get parameter 3 off the stack.
  533. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  534. // Get parameter 4 off the stack.
  535. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  536. // Get parameter 5 off the stack.
  537. ScriptUtil::LuaArray<Quaternion> param5 = ScriptUtil::getObjectPointer<Quaternion>(6, "Quaternion", true);
  538. PhysicsController* instance = getInstance(state);
  539. void* returnPtr = (void*)instance->createHingeConstraint(param1, *param2, *param3, param4, *param5);
  540. if (returnPtr)
  541. {
  542. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  543. object->instance = returnPtr;
  544. object->owns = false;
  545. luaL_getmetatable(state, "PhysicsHingeConstraint");
  546. lua_setmetatable(state, -2);
  547. }
  548. else
  549. {
  550. lua_pushnil(state);
  551. }
  552. return 1;
  553. }
  554. else
  555. {
  556. lua_pushstring(state, "lua_PhysicsController_createHingeConstraint - Failed to match the given parameters to a valid function signature.");
  557. lua_error(state);
  558. }
  559. break;
  560. }
  561. case 7:
  562. {
  563. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  564. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  565. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  566. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  567. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL) &&
  568. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  569. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL))
  570. {
  571. // Get parameter 1 off the stack.
  572. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  573. // Get parameter 2 off the stack.
  574. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  575. // Get parameter 3 off the stack.
  576. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  577. // Get parameter 4 off the stack.
  578. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  579. // Get parameter 5 off the stack.
  580. ScriptUtil::LuaArray<Quaternion> param5 = ScriptUtil::getObjectPointer<Quaternion>(6, "Quaternion", true);
  581. // Get parameter 6 off the stack.
  582. ScriptUtil::LuaArray<Vector3> param6 = ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true);
  583. PhysicsController* instance = getInstance(state);
  584. void* returnPtr = (void*)instance->createHingeConstraint(param1, *param2, *param3, param4, *param5, *param6);
  585. if (returnPtr)
  586. {
  587. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  588. object->instance = returnPtr;
  589. object->owns = false;
  590. luaL_getmetatable(state, "PhysicsHingeConstraint");
  591. lua_setmetatable(state, -2);
  592. }
  593. else
  594. {
  595. lua_pushnil(state);
  596. }
  597. return 1;
  598. }
  599. else
  600. {
  601. lua_pushstring(state, "lua_PhysicsController_createHingeConstraint - Failed to match the given parameters to a valid function signature.");
  602. lua_error(state);
  603. }
  604. break;
  605. }
  606. default:
  607. {
  608. lua_pushstring(state, "Invalid number of parameters (expected 4, 5, 6 or 7).");
  609. lua_error(state);
  610. break;
  611. }
  612. }
  613. return 0;
  614. }
  615. int lua_PhysicsController_createSocketConstraint(lua_State* state)
  616. {
  617. // Get the number of parameters.
  618. int paramCount = lua_gettop(state);
  619. // Attempt to match the parameters to a valid binding.
  620. switch (paramCount)
  621. {
  622. case 2:
  623. {
  624. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  625. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  626. {
  627. // Get parameter 1 off the stack.
  628. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  629. PhysicsController* instance = getInstance(state);
  630. void* returnPtr = (void*)instance->createSocketConstraint(param1);
  631. if (returnPtr)
  632. {
  633. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  634. object->instance = returnPtr;
  635. object->owns = false;
  636. luaL_getmetatable(state, "PhysicsSocketConstraint");
  637. lua_setmetatable(state, -2);
  638. }
  639. else
  640. {
  641. lua_pushnil(state);
  642. }
  643. return 1;
  644. }
  645. else
  646. {
  647. lua_pushstring(state, "lua_PhysicsController_createSocketConstraint - Failed to match the given parameters to a valid function signature.");
  648. lua_error(state);
  649. }
  650. break;
  651. }
  652. case 3:
  653. {
  654. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  655. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  656. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  657. {
  658. // Get parameter 1 off the stack.
  659. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  660. // Get parameter 2 off the stack.
  661. ScriptUtil::LuaArray<PhysicsRigidBody> param2 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(3, "PhysicsRigidBody", false);
  662. PhysicsController* instance = getInstance(state);
  663. void* returnPtr = (void*)instance->createSocketConstraint(param1, param2);
  664. if (returnPtr)
  665. {
  666. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  667. object->instance = returnPtr;
  668. object->owns = false;
  669. luaL_getmetatable(state, "PhysicsSocketConstraint");
  670. lua_setmetatable(state, -2);
  671. }
  672. else
  673. {
  674. lua_pushnil(state);
  675. }
  676. return 1;
  677. }
  678. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  679. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  680. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  681. {
  682. // Get parameter 1 off the stack.
  683. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  684. // Get parameter 2 off the stack.
  685. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  686. PhysicsController* instance = getInstance(state);
  687. void* returnPtr = (void*)instance->createSocketConstraint(param1, *param2);
  688. if (returnPtr)
  689. {
  690. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  691. object->instance = returnPtr;
  692. object->owns = false;
  693. luaL_getmetatable(state, "PhysicsSocketConstraint");
  694. lua_setmetatable(state, -2);
  695. }
  696. else
  697. {
  698. lua_pushnil(state);
  699. }
  700. return 1;
  701. }
  702. else
  703. {
  704. lua_pushstring(state, "lua_PhysicsController_createSocketConstraint - Failed to match the given parameters to a valid function signature.");
  705. lua_error(state);
  706. }
  707. break;
  708. }
  709. case 4:
  710. {
  711. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  712. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  713. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  714. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL))
  715. {
  716. // Get parameter 1 off the stack.
  717. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  718. // Get parameter 2 off the stack.
  719. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  720. // Get parameter 3 off the stack.
  721. ScriptUtil::LuaArray<PhysicsRigidBody> param3 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(4, "PhysicsRigidBody", false);
  722. PhysicsController* instance = getInstance(state);
  723. void* returnPtr = (void*)instance->createSocketConstraint(param1, *param2, param3);
  724. if (returnPtr)
  725. {
  726. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  727. object->instance = returnPtr;
  728. object->owns = false;
  729. luaL_getmetatable(state, "PhysicsSocketConstraint");
  730. lua_setmetatable(state, -2);
  731. }
  732. else
  733. {
  734. lua_pushnil(state);
  735. }
  736. return 1;
  737. }
  738. else
  739. {
  740. lua_pushstring(state, "lua_PhysicsController_createSocketConstraint - Failed to match the given parameters to a valid function signature.");
  741. lua_error(state);
  742. }
  743. break;
  744. }
  745. case 5:
  746. {
  747. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  748. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  749. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  750. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL) &&
  751. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TNIL))
  752. {
  753. // Get parameter 1 off the stack.
  754. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  755. // Get parameter 2 off the stack.
  756. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  757. // Get parameter 3 off the stack.
  758. ScriptUtil::LuaArray<PhysicsRigidBody> param3 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(4, "PhysicsRigidBody", false);
  759. // Get parameter 4 off the stack.
  760. ScriptUtil::LuaArray<Vector3> param4 = ScriptUtil::getObjectPointer<Vector3>(5, "Vector3", true);
  761. PhysicsController* instance = getInstance(state);
  762. void* returnPtr = (void*)instance->createSocketConstraint(param1, *param2, param3, *param4);
  763. if (returnPtr)
  764. {
  765. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  766. object->instance = returnPtr;
  767. object->owns = false;
  768. luaL_getmetatable(state, "PhysicsSocketConstraint");
  769. lua_setmetatable(state, -2);
  770. }
  771. else
  772. {
  773. lua_pushnil(state);
  774. }
  775. return 1;
  776. }
  777. else
  778. {
  779. lua_pushstring(state, "lua_PhysicsController_createSocketConstraint - Failed to match the given parameters to a valid function signature.");
  780. lua_error(state);
  781. }
  782. break;
  783. }
  784. default:
  785. {
  786. lua_pushstring(state, "Invalid number of parameters (expected 2, 3, 4 or 5).");
  787. lua_error(state);
  788. break;
  789. }
  790. }
  791. return 0;
  792. }
  793. int lua_PhysicsController_createSpringConstraint(lua_State* state)
  794. {
  795. // Get the number of parameters.
  796. int paramCount = lua_gettop(state);
  797. // Attempt to match the parameters to a valid binding.
  798. switch (paramCount)
  799. {
  800. case 3:
  801. {
  802. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  803. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  804. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  805. {
  806. // Get parameter 1 off the stack.
  807. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  808. // Get parameter 2 off the stack.
  809. ScriptUtil::LuaArray<PhysicsRigidBody> param2 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(3, "PhysicsRigidBody", false);
  810. PhysicsController* instance = getInstance(state);
  811. void* returnPtr = (void*)instance->createSpringConstraint(param1, param2);
  812. if (returnPtr)
  813. {
  814. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  815. object->instance = returnPtr;
  816. object->owns = false;
  817. luaL_getmetatable(state, "PhysicsSpringConstraint");
  818. lua_setmetatable(state, -2);
  819. }
  820. else
  821. {
  822. lua_pushnil(state);
  823. }
  824. return 1;
  825. }
  826. else
  827. {
  828. lua_pushstring(state, "lua_PhysicsController_createSpringConstraint - Failed to match the given parameters to a valid function signature.");
  829. lua_error(state);
  830. }
  831. break;
  832. }
  833. case 7:
  834. {
  835. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  836. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  837. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  838. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL) &&
  839. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL) &&
  840. (lua_type(state, 6) == LUA_TUSERDATA || lua_type(state, 6) == LUA_TNIL) &&
  841. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL))
  842. {
  843. // Get parameter 1 off the stack.
  844. ScriptUtil::LuaArray<PhysicsRigidBody> param1 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(2, "PhysicsRigidBody", false);
  845. // Get parameter 2 off the stack.
  846. ScriptUtil::LuaArray<Quaternion> param2 = ScriptUtil::getObjectPointer<Quaternion>(3, "Quaternion", true);
  847. // Get parameter 3 off the stack.
  848. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  849. // Get parameter 4 off the stack.
  850. ScriptUtil::LuaArray<PhysicsRigidBody> param4 = ScriptUtil::getObjectPointer<PhysicsRigidBody>(5, "PhysicsRigidBody", false);
  851. // Get parameter 5 off the stack.
  852. ScriptUtil::LuaArray<Quaternion> param5 = ScriptUtil::getObjectPointer<Quaternion>(6, "Quaternion", true);
  853. // Get parameter 6 off the stack.
  854. ScriptUtil::LuaArray<Vector3> param6 = ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true);
  855. PhysicsController* instance = getInstance(state);
  856. void* returnPtr = (void*)instance->createSpringConstraint(param1, *param2, *param3, param4, *param5, *param6);
  857. if (returnPtr)
  858. {
  859. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  860. object->instance = returnPtr;
  861. object->owns = false;
  862. luaL_getmetatable(state, "PhysicsSpringConstraint");
  863. lua_setmetatable(state, -2);
  864. }
  865. else
  866. {
  867. lua_pushnil(state);
  868. }
  869. return 1;
  870. }
  871. else
  872. {
  873. lua_pushstring(state, "lua_PhysicsController_createSpringConstraint - Failed to match the given parameters to a valid function signature.");
  874. lua_error(state);
  875. }
  876. break;
  877. }
  878. default:
  879. {
  880. lua_pushstring(state, "Invalid number of parameters (expected 3 or 7).");
  881. lua_error(state);
  882. break;
  883. }
  884. }
  885. return 0;
  886. }
  887. int lua_PhysicsController_drawDebug(lua_State* state)
  888. {
  889. // Get the number of parameters.
  890. int paramCount = lua_gettop(state);
  891. // Attempt to match the parameters to a valid binding.
  892. switch (paramCount)
  893. {
  894. case 2:
  895. {
  896. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  897. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  898. {
  899. // Get parameter 1 off the stack.
  900. ScriptUtil::LuaArray<Matrix> param1 = ScriptUtil::getObjectPointer<Matrix>(2, "Matrix", true);
  901. PhysicsController* instance = getInstance(state);
  902. instance->drawDebug(*param1);
  903. return 0;
  904. }
  905. else
  906. {
  907. lua_pushstring(state, "lua_PhysicsController_drawDebug - Failed to match the given parameters to a valid function signature.");
  908. lua_error(state);
  909. }
  910. break;
  911. }
  912. default:
  913. {
  914. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  915. lua_error(state);
  916. break;
  917. }
  918. }
  919. return 0;
  920. }
  921. int lua_PhysicsController_getGravity(lua_State* state)
  922. {
  923. // Get the number of parameters.
  924. int paramCount = lua_gettop(state);
  925. // Attempt to match the parameters to a valid binding.
  926. switch (paramCount)
  927. {
  928. case 1:
  929. {
  930. if ((lua_type(state, 1) == LUA_TUSERDATA))
  931. {
  932. PhysicsController* instance = getInstance(state);
  933. void* returnPtr = (void*)&(instance->getGravity());
  934. if (returnPtr)
  935. {
  936. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  937. object->instance = returnPtr;
  938. object->owns = false;
  939. luaL_getmetatable(state, "Vector3");
  940. lua_setmetatable(state, -2);
  941. }
  942. else
  943. {
  944. lua_pushnil(state);
  945. }
  946. return 1;
  947. }
  948. else
  949. {
  950. lua_pushstring(state, "lua_PhysicsController_getGravity - Failed to match the given parameters to a valid function signature.");
  951. lua_error(state);
  952. }
  953. break;
  954. }
  955. default:
  956. {
  957. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  958. lua_error(state);
  959. break;
  960. }
  961. }
  962. return 0;
  963. }
  964. int lua_PhysicsController_rayTest(lua_State* state)
  965. {
  966. // Get the number of parameters.
  967. int paramCount = lua_gettop(state);
  968. // Attempt to match the parameters to a valid binding.
  969. switch (paramCount)
  970. {
  971. case 3:
  972. {
  973. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  974. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  975. lua_type(state, 3) == LUA_TNUMBER)
  976. {
  977. // Get parameter 1 off the stack.
  978. ScriptUtil::LuaArray<Ray> param1 = ScriptUtil::getObjectPointer<Ray>(2, "Ray", true);
  979. // Get parameter 2 off the stack.
  980. float param2 = (float)luaL_checknumber(state, 3);
  981. PhysicsController* instance = getInstance(state);
  982. bool result = instance->rayTest(*param1, param2);
  983. // Push the return value onto the stack.
  984. lua_pushboolean(state, result);
  985. return 1;
  986. }
  987. else
  988. {
  989. lua_pushstring(state, "lua_PhysicsController_rayTest - Failed to match the given parameters to a valid function signature.");
  990. lua_error(state);
  991. }
  992. break;
  993. }
  994. case 4:
  995. {
  996. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  997. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  998. lua_type(state, 3) == LUA_TNUMBER &&
  999. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL))
  1000. {
  1001. // Get parameter 1 off the stack.
  1002. ScriptUtil::LuaArray<Ray> param1 = ScriptUtil::getObjectPointer<Ray>(2, "Ray", true);
  1003. // Get parameter 2 off the stack.
  1004. float param2 = (float)luaL_checknumber(state, 3);
  1005. // Get parameter 3 off the stack.
  1006. ScriptUtil::LuaArray<PhysicsController::HitResult> param3 = ScriptUtil::getObjectPointer<PhysicsController::HitResult>(4, "PhysicsControllerHitResult", false);
  1007. PhysicsController* instance = getInstance(state);
  1008. bool result = instance->rayTest(*param1, param2, param3);
  1009. // Push the return value onto the stack.
  1010. lua_pushboolean(state, result);
  1011. return 1;
  1012. }
  1013. else
  1014. {
  1015. lua_pushstring(state, "lua_PhysicsController_rayTest - Failed to match the given parameters to a valid function signature.");
  1016. lua_error(state);
  1017. }
  1018. break;
  1019. }
  1020. case 5:
  1021. {
  1022. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1023. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  1024. lua_type(state, 3) == LUA_TNUMBER &&
  1025. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL) &&
  1026. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL))
  1027. {
  1028. // Get parameter 1 off the stack.
  1029. ScriptUtil::LuaArray<Ray> param1 = ScriptUtil::getObjectPointer<Ray>(2, "Ray", true);
  1030. // Get parameter 2 off the stack.
  1031. float param2 = (float)luaL_checknumber(state, 3);
  1032. // Get parameter 3 off the stack.
  1033. ScriptUtil::LuaArray<PhysicsController::HitResult> param3 = ScriptUtil::getObjectPointer<PhysicsController::HitResult>(4, "PhysicsControllerHitResult", false);
  1034. // Get parameter 4 off the stack.
  1035. ScriptUtil::LuaArray<PhysicsController::HitFilter> param4 = ScriptUtil::getObjectPointer<PhysicsController::HitFilter>(5, "PhysicsControllerHitFilter", false);
  1036. PhysicsController* instance = getInstance(state);
  1037. bool result = instance->rayTest(*param1, param2, param3, param4);
  1038. // Push the return value onto the stack.
  1039. lua_pushboolean(state, result);
  1040. return 1;
  1041. }
  1042. else
  1043. {
  1044. lua_pushstring(state, "lua_PhysicsController_rayTest - Failed to match the given parameters to a valid function signature.");
  1045. lua_error(state);
  1046. }
  1047. break;
  1048. }
  1049. default:
  1050. {
  1051. lua_pushstring(state, "Invalid number of parameters (expected 3, 4 or 5).");
  1052. lua_error(state);
  1053. break;
  1054. }
  1055. }
  1056. return 0;
  1057. }
  1058. int lua_PhysicsController_removeScriptCallback(lua_State* state)
  1059. {
  1060. // Get the number of parameters.
  1061. int paramCount = lua_gettop(state);
  1062. // Attempt to match the parameters to a valid binding.
  1063. switch (paramCount)
  1064. {
  1065. case 3:
  1066. {
  1067. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1068. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1069. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
  1070. {
  1071. // Get parameter 1 off the stack.
  1072. std::string param1 = ScriptUtil::getString(2, true);
  1073. // Get parameter 2 off the stack.
  1074. std::string param2 = ScriptUtil::getString(3, true);
  1075. PhysicsController* instance = getInstance(state);
  1076. instance->removeScriptCallback(param1, param2);
  1077. return 0;
  1078. }
  1079. else
  1080. {
  1081. lua_pushstring(state, "lua_PhysicsController_removeScriptCallback - Failed to match the given parameters to a valid function signature.");
  1082. lua_error(state);
  1083. }
  1084. break;
  1085. }
  1086. default:
  1087. {
  1088. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1089. lua_error(state);
  1090. break;
  1091. }
  1092. }
  1093. return 0;
  1094. }
  1095. int lua_PhysicsController_removeStatusListener(lua_State* state)
  1096. {
  1097. // Get the number of parameters.
  1098. int paramCount = lua_gettop(state);
  1099. // Attempt to match the parameters to a valid binding.
  1100. switch (paramCount)
  1101. {
  1102. case 2:
  1103. {
  1104. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1105. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  1106. {
  1107. // Get parameter 1 off the stack.
  1108. ScriptUtil::LuaArray<PhysicsController::Listener> param1 = ScriptUtil::getObjectPointer<PhysicsController::Listener>(2, "PhysicsControllerListener", false);
  1109. PhysicsController* instance = getInstance(state);
  1110. instance->removeStatusListener(param1);
  1111. return 0;
  1112. }
  1113. else
  1114. {
  1115. lua_pushstring(state, "lua_PhysicsController_removeStatusListener - Failed to match the given parameters to a valid function signature.");
  1116. lua_error(state);
  1117. }
  1118. break;
  1119. }
  1120. default:
  1121. {
  1122. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1123. lua_error(state);
  1124. break;
  1125. }
  1126. }
  1127. return 0;
  1128. }
  1129. int lua_PhysicsController_setGravity(lua_State* state)
  1130. {
  1131. // Get the number of parameters.
  1132. int paramCount = lua_gettop(state);
  1133. // Attempt to match the parameters to a valid binding.
  1134. switch (paramCount)
  1135. {
  1136. case 2:
  1137. {
  1138. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1139. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1140. {
  1141. // Get parameter 1 off the stack.
  1142. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1143. PhysicsController* instance = getInstance(state);
  1144. instance->setGravity(*param1);
  1145. return 0;
  1146. }
  1147. else
  1148. {
  1149. lua_pushstring(state, "lua_PhysicsController_setGravity - Failed to match the given parameters to a valid function signature.");
  1150. lua_error(state);
  1151. }
  1152. break;
  1153. }
  1154. default:
  1155. {
  1156. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1157. lua_error(state);
  1158. break;
  1159. }
  1160. }
  1161. return 0;
  1162. }
  1163. int lua_PhysicsController_sweepTest(lua_State* state)
  1164. {
  1165. // Get the number of parameters.
  1166. int paramCount = lua_gettop(state);
  1167. // Attempt to match the parameters to a valid binding.
  1168. switch (paramCount)
  1169. {
  1170. case 3:
  1171. {
  1172. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1173. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  1174. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  1175. {
  1176. // Get parameter 1 off the stack.
  1177. ScriptUtil::LuaArray<PhysicsCollisionObject> param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(2, "PhysicsCollisionObject", false);
  1178. // Get parameter 2 off the stack.
  1179. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  1180. PhysicsController* instance = getInstance(state);
  1181. bool result = instance->sweepTest(param1, *param2);
  1182. // Push the return value onto the stack.
  1183. lua_pushboolean(state, result);
  1184. return 1;
  1185. }
  1186. else
  1187. {
  1188. lua_pushstring(state, "lua_PhysicsController_sweepTest - Failed to match the given parameters to a valid function signature.");
  1189. lua_error(state);
  1190. }
  1191. break;
  1192. }
  1193. case 4:
  1194. {
  1195. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1196. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  1197. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1198. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL))
  1199. {
  1200. // Get parameter 1 off the stack.
  1201. ScriptUtil::LuaArray<PhysicsCollisionObject> param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(2, "PhysicsCollisionObject", false);
  1202. // Get parameter 2 off the stack.
  1203. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  1204. // Get parameter 3 off the stack.
  1205. ScriptUtil::LuaArray<PhysicsController::HitResult> param3 = ScriptUtil::getObjectPointer<PhysicsController::HitResult>(4, "PhysicsControllerHitResult", false);
  1206. PhysicsController* instance = getInstance(state);
  1207. bool result = instance->sweepTest(param1, *param2, param3);
  1208. // Push the return value onto the stack.
  1209. lua_pushboolean(state, result);
  1210. return 1;
  1211. }
  1212. else
  1213. {
  1214. lua_pushstring(state, "lua_PhysicsController_sweepTest - Failed to match the given parameters to a valid function signature.");
  1215. lua_error(state);
  1216. }
  1217. break;
  1218. }
  1219. case 5:
  1220. {
  1221. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1222. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  1223. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1224. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL) &&
  1225. (lua_type(state, 5) == LUA_TUSERDATA || lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TNIL))
  1226. {
  1227. // Get parameter 1 off the stack.
  1228. ScriptUtil::LuaArray<PhysicsCollisionObject> param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(2, "PhysicsCollisionObject", false);
  1229. // Get parameter 2 off the stack.
  1230. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  1231. // Get parameter 3 off the stack.
  1232. ScriptUtil::LuaArray<PhysicsController::HitResult> param3 = ScriptUtil::getObjectPointer<PhysicsController::HitResult>(4, "PhysicsControllerHitResult", false);
  1233. // Get parameter 4 off the stack.
  1234. ScriptUtil::LuaArray<PhysicsController::HitFilter> param4 = ScriptUtil::getObjectPointer<PhysicsController::HitFilter>(5, "PhysicsControllerHitFilter", false);
  1235. PhysicsController* instance = getInstance(state);
  1236. bool result = instance->sweepTest(param1, *param2, param3, param4);
  1237. // Push the return value onto the stack.
  1238. lua_pushboolean(state, result);
  1239. return 1;
  1240. }
  1241. else
  1242. {
  1243. lua_pushstring(state, "lua_PhysicsController_sweepTest - Failed to match the given parameters to a valid function signature.");
  1244. lua_error(state);
  1245. }
  1246. break;
  1247. }
  1248. default:
  1249. {
  1250. lua_pushstring(state, "Invalid number of parameters (expected 3, 4 or 5).");
  1251. lua_error(state);
  1252. break;
  1253. }
  1254. }
  1255. return 0;
  1256. }
  1257. }