lua_PhysicsSpringConstraint.cpp 42 KB

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