lua_PhysicsGenericConstraint.cpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsGenericConstraint.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Node.h"
  7. #include "PhysicsConstraint.h"
  8. #include "PhysicsGenericConstraint.h"
  9. #include "PhysicsRigidBody.h"
  10. namespace gameplay
  11. {
  12. void luaRegister_PhysicsGenericConstraint()
  13. {
  14. const luaL_Reg lua_members[] =
  15. {
  16. {"getBreakingImpulse", lua_PhysicsGenericConstraint_getBreakingImpulse},
  17. {"getRotationOffsetA", lua_PhysicsGenericConstraint_getRotationOffsetA},
  18. {"getRotationOffsetB", lua_PhysicsGenericConstraint_getRotationOffsetB},
  19. {"getTranslationOffsetA", lua_PhysicsGenericConstraint_getTranslationOffsetA},
  20. {"getTranslationOffsetB", lua_PhysicsGenericConstraint_getTranslationOffsetB},
  21. {"isEnabled", lua_PhysicsGenericConstraint_isEnabled},
  22. {"setAngularLowerLimit", lua_PhysicsGenericConstraint_setAngularLowerLimit},
  23. {"setAngularUpperLimit", lua_PhysicsGenericConstraint_setAngularUpperLimit},
  24. {"setBreakingImpulse", lua_PhysicsGenericConstraint_setBreakingImpulse},
  25. {"setEnabled", lua_PhysicsGenericConstraint_setEnabled},
  26. {"setLinearLowerLimit", lua_PhysicsGenericConstraint_setLinearLowerLimit},
  27. {"setLinearUpperLimit", lua_PhysicsGenericConstraint_setLinearUpperLimit},
  28. {"setRotationOffsetA", lua_PhysicsGenericConstraint_setRotationOffsetA},
  29. {"setRotationOffsetB", lua_PhysicsGenericConstraint_setRotationOffsetB},
  30. {"setTranslationOffsetA", lua_PhysicsGenericConstraint_setTranslationOffsetA},
  31. {"setTranslationOffsetB", lua_PhysicsGenericConstraint_setTranslationOffsetB},
  32. {NULL, NULL}
  33. };
  34. const luaL_Reg lua_statics[] =
  35. {
  36. {"centerOfMassMidpoint", lua_PhysicsGenericConstraint_static_centerOfMassMidpoint},
  37. {"getRotationOffset", lua_PhysicsGenericConstraint_static_getRotationOffset},
  38. {"getTranslationOffset", lua_PhysicsGenericConstraint_static_getTranslationOffset},
  39. {NULL, NULL}
  40. };
  41. std::vector<std::string> scopePath;
  42. ScriptUtil::registerClass("PhysicsGenericConstraint", lua_members, NULL, NULL, lua_statics, scopePath);
  43. }
  44. static PhysicsGenericConstraint* getInstance(lua_State* state)
  45. {
  46. void* userdata = luaL_checkudata(state, 1, "PhysicsGenericConstraint");
  47. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsGenericConstraint' expected.");
  48. return (PhysicsGenericConstraint*)((ScriptUtil::LuaObject*)userdata)->instance;
  49. }
  50. int lua_PhysicsGenericConstraint_getBreakingImpulse(lua_State* state)
  51. {
  52. // Get the number of parameters.
  53. int paramCount = lua_gettop(state);
  54. // Attempt to match the parameters to a valid binding.
  55. switch (paramCount)
  56. {
  57. case 1:
  58. {
  59. if ((lua_type(state, 1) == LUA_TUSERDATA))
  60. {
  61. PhysicsGenericConstraint* instance = getInstance(state);
  62. float result = instance->getBreakingImpulse();
  63. // Push the return value onto the stack.
  64. lua_pushnumber(state, result);
  65. return 1;
  66. }
  67. else
  68. {
  69. lua_pushstring(state, "lua_PhysicsGenericConstraint_getBreakingImpulse - 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 1).");
  77. lua_error(state);
  78. break;
  79. }
  80. }
  81. return 0;
  82. }
  83. int lua_PhysicsGenericConstraint_getRotationOffsetA(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 1:
  91. {
  92. if ((lua_type(state, 1) == LUA_TUSERDATA))
  93. {
  94. PhysicsGenericConstraint* instance = getInstance(state);
  95. void* returnPtr = (void*)&(instance->getRotationOffsetA());
  96. if (returnPtr)
  97. {
  98. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  99. object->instance = returnPtr;
  100. object->owns = false;
  101. luaL_getmetatable(state, "Quaternion");
  102. lua_setmetatable(state, -2);
  103. }
  104. else
  105. {
  106. lua_pushnil(state);
  107. }
  108. return 1;
  109. }
  110. else
  111. {
  112. lua_pushstring(state, "lua_PhysicsGenericConstraint_getRotationOffsetA - Failed to match the given parameters to a valid function signature.");
  113. lua_error(state);
  114. }
  115. break;
  116. }
  117. default:
  118. {
  119. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  120. lua_error(state);
  121. break;
  122. }
  123. }
  124. return 0;
  125. }
  126. int lua_PhysicsGenericConstraint_getRotationOffsetB(lua_State* state)
  127. {
  128. // Get the number of parameters.
  129. int paramCount = lua_gettop(state);
  130. // Attempt to match the parameters to a valid binding.
  131. switch (paramCount)
  132. {
  133. case 1:
  134. {
  135. if ((lua_type(state, 1) == LUA_TUSERDATA))
  136. {
  137. PhysicsGenericConstraint* instance = getInstance(state);
  138. void* returnPtr = (void*)&(instance->getRotationOffsetB());
  139. if (returnPtr)
  140. {
  141. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  142. object->instance = returnPtr;
  143. object->owns = false;
  144. luaL_getmetatable(state, "Quaternion");
  145. lua_setmetatable(state, -2);
  146. }
  147. else
  148. {
  149. lua_pushnil(state);
  150. }
  151. return 1;
  152. }
  153. else
  154. {
  155. lua_pushstring(state, "lua_PhysicsGenericConstraint_getRotationOffsetB - Failed to match the given parameters to a valid function signature.");
  156. lua_error(state);
  157. }
  158. break;
  159. }
  160. default:
  161. {
  162. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  163. lua_error(state);
  164. break;
  165. }
  166. }
  167. return 0;
  168. }
  169. int lua_PhysicsGenericConstraint_getTranslationOffsetA(lua_State* state)
  170. {
  171. // Get the number of parameters.
  172. int paramCount = lua_gettop(state);
  173. // Attempt to match the parameters to a valid binding.
  174. switch (paramCount)
  175. {
  176. case 1:
  177. {
  178. if ((lua_type(state, 1) == LUA_TUSERDATA))
  179. {
  180. PhysicsGenericConstraint* instance = getInstance(state);
  181. void* returnPtr = (void*)&(instance->getTranslationOffsetA());
  182. if (returnPtr)
  183. {
  184. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  185. object->instance = returnPtr;
  186. object->owns = false;
  187. luaL_getmetatable(state, "Vector3");
  188. lua_setmetatable(state, -2);
  189. }
  190. else
  191. {
  192. lua_pushnil(state);
  193. }
  194. return 1;
  195. }
  196. else
  197. {
  198. lua_pushstring(state, "lua_PhysicsGenericConstraint_getTranslationOffsetA - Failed to match the given parameters to a valid function signature.");
  199. lua_error(state);
  200. }
  201. break;
  202. }
  203. default:
  204. {
  205. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  206. lua_error(state);
  207. break;
  208. }
  209. }
  210. return 0;
  211. }
  212. int lua_PhysicsGenericConstraint_getTranslationOffsetB(lua_State* state)
  213. {
  214. // Get the number of parameters.
  215. int paramCount = lua_gettop(state);
  216. // Attempt to match the parameters to a valid binding.
  217. switch (paramCount)
  218. {
  219. case 1:
  220. {
  221. if ((lua_type(state, 1) == LUA_TUSERDATA))
  222. {
  223. PhysicsGenericConstraint* instance = getInstance(state);
  224. void* returnPtr = (void*)&(instance->getTranslationOffsetB());
  225. if (returnPtr)
  226. {
  227. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  228. object->instance = returnPtr;
  229. object->owns = false;
  230. luaL_getmetatable(state, "Vector3");
  231. lua_setmetatable(state, -2);
  232. }
  233. else
  234. {
  235. lua_pushnil(state);
  236. }
  237. return 1;
  238. }
  239. else
  240. {
  241. lua_pushstring(state, "lua_PhysicsGenericConstraint_getTranslationOffsetB - Failed to match the given parameters to a valid function signature.");
  242. lua_error(state);
  243. }
  244. break;
  245. }
  246. default:
  247. {
  248. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  249. lua_error(state);
  250. break;
  251. }
  252. }
  253. return 0;
  254. }
  255. int lua_PhysicsGenericConstraint_isEnabled(lua_State* state)
  256. {
  257. // Get the number of parameters.
  258. int paramCount = lua_gettop(state);
  259. // Attempt to match the parameters to a valid binding.
  260. switch (paramCount)
  261. {
  262. case 1:
  263. {
  264. if ((lua_type(state, 1) == LUA_TUSERDATA))
  265. {
  266. PhysicsGenericConstraint* instance = getInstance(state);
  267. bool result = instance->isEnabled();
  268. // Push the return value onto the stack.
  269. lua_pushboolean(state, result);
  270. return 1;
  271. }
  272. else
  273. {
  274. lua_pushstring(state, "lua_PhysicsGenericConstraint_isEnabled - Failed to match the given parameters to a valid function signature.");
  275. lua_error(state);
  276. }
  277. break;
  278. }
  279. default:
  280. {
  281. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  282. lua_error(state);
  283. break;
  284. }
  285. }
  286. return 0;
  287. }
  288. int lua_PhysicsGenericConstraint_setAngularLowerLimit(lua_State* state)
  289. {
  290. // Get the number of parameters.
  291. int paramCount = lua_gettop(state);
  292. // Attempt to match the parameters to a valid binding.
  293. switch (paramCount)
  294. {
  295. case 2:
  296. {
  297. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  298. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  299. {
  300. // Get parameter 1 off the stack.
  301. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  302. PhysicsGenericConstraint* instance = getInstance(state);
  303. instance->setAngularLowerLimit(*param1);
  304. return 0;
  305. }
  306. else
  307. {
  308. lua_pushstring(state, "lua_PhysicsGenericConstraint_setAngularLowerLimit - Failed to match the given parameters to a valid function signature.");
  309. lua_error(state);
  310. }
  311. break;
  312. }
  313. default:
  314. {
  315. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  316. lua_error(state);
  317. break;
  318. }
  319. }
  320. return 0;
  321. }
  322. int lua_PhysicsGenericConstraint_setAngularUpperLimit(lua_State* state)
  323. {
  324. // Get the number of parameters.
  325. int paramCount = lua_gettop(state);
  326. // Attempt to match the parameters to a valid binding.
  327. switch (paramCount)
  328. {
  329. case 2:
  330. {
  331. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  332. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  333. {
  334. // Get parameter 1 off the stack.
  335. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  336. PhysicsGenericConstraint* instance = getInstance(state);
  337. instance->setAngularUpperLimit(*param1);
  338. return 0;
  339. }
  340. else
  341. {
  342. lua_pushstring(state, "lua_PhysicsGenericConstraint_setAngularUpperLimit - Failed to match the given parameters to a valid function signature.");
  343. lua_error(state);
  344. }
  345. break;
  346. }
  347. default:
  348. {
  349. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  350. lua_error(state);
  351. break;
  352. }
  353. }
  354. return 0;
  355. }
  356. int lua_PhysicsGenericConstraint_setBreakingImpulse(lua_State* state)
  357. {
  358. // Get the number of parameters.
  359. int paramCount = lua_gettop(state);
  360. // Attempt to match the parameters to a valid binding.
  361. switch (paramCount)
  362. {
  363. case 2:
  364. {
  365. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  366. lua_type(state, 2) == LUA_TNUMBER)
  367. {
  368. // Get parameter 1 off the stack.
  369. float param1 = (float)luaL_checknumber(state, 2);
  370. PhysicsGenericConstraint* instance = getInstance(state);
  371. instance->setBreakingImpulse(param1);
  372. return 0;
  373. }
  374. else
  375. {
  376. lua_pushstring(state, "lua_PhysicsGenericConstraint_setBreakingImpulse - Failed to match the given parameters to a valid function signature.");
  377. lua_error(state);
  378. }
  379. break;
  380. }
  381. default:
  382. {
  383. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  384. lua_error(state);
  385. break;
  386. }
  387. }
  388. return 0;
  389. }
  390. int lua_PhysicsGenericConstraint_setEnabled(lua_State* state)
  391. {
  392. // Get the number of parameters.
  393. int paramCount = lua_gettop(state);
  394. // Attempt to match the parameters to a valid binding.
  395. switch (paramCount)
  396. {
  397. case 2:
  398. {
  399. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  400. lua_type(state, 2) == LUA_TBOOLEAN)
  401. {
  402. // Get parameter 1 off the stack.
  403. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  404. PhysicsGenericConstraint* instance = getInstance(state);
  405. instance->setEnabled(param1);
  406. return 0;
  407. }
  408. else
  409. {
  410. lua_pushstring(state, "lua_PhysicsGenericConstraint_setEnabled - Failed to match the given parameters to a valid function signature.");
  411. lua_error(state);
  412. }
  413. break;
  414. }
  415. default:
  416. {
  417. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  418. lua_error(state);
  419. break;
  420. }
  421. }
  422. return 0;
  423. }
  424. int lua_PhysicsGenericConstraint_setLinearLowerLimit(lua_State* state)
  425. {
  426. // Get the number of parameters.
  427. int paramCount = lua_gettop(state);
  428. // Attempt to match the parameters to a valid binding.
  429. switch (paramCount)
  430. {
  431. case 2:
  432. {
  433. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  434. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  435. {
  436. // Get parameter 1 off the stack.
  437. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  438. PhysicsGenericConstraint* instance = getInstance(state);
  439. instance->setLinearLowerLimit(*param1);
  440. return 0;
  441. }
  442. else
  443. {
  444. lua_pushstring(state, "lua_PhysicsGenericConstraint_setLinearLowerLimit - Failed to match the given parameters to a valid function signature.");
  445. lua_error(state);
  446. }
  447. break;
  448. }
  449. default:
  450. {
  451. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  452. lua_error(state);
  453. break;
  454. }
  455. }
  456. return 0;
  457. }
  458. int lua_PhysicsGenericConstraint_setLinearUpperLimit(lua_State* state)
  459. {
  460. // Get the number of parameters.
  461. int paramCount = lua_gettop(state);
  462. // Attempt to match the parameters to a valid binding.
  463. switch (paramCount)
  464. {
  465. case 2:
  466. {
  467. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  468. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  469. {
  470. // Get parameter 1 off the stack.
  471. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  472. PhysicsGenericConstraint* instance = getInstance(state);
  473. instance->setLinearUpperLimit(*param1);
  474. return 0;
  475. }
  476. else
  477. {
  478. lua_pushstring(state, "lua_PhysicsGenericConstraint_setLinearUpperLimit - Failed to match the given parameters to a valid function signature.");
  479. lua_error(state);
  480. }
  481. break;
  482. }
  483. default:
  484. {
  485. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  486. lua_error(state);
  487. break;
  488. }
  489. }
  490. return 0;
  491. }
  492. int lua_PhysicsGenericConstraint_setRotationOffsetA(lua_State* state)
  493. {
  494. // Get the number of parameters.
  495. int paramCount = lua_gettop(state);
  496. // Attempt to match the parameters to a valid binding.
  497. switch (paramCount)
  498. {
  499. case 2:
  500. {
  501. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  502. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  503. {
  504. // Get parameter 1 off the stack.
  505. ScriptUtil::LuaArray<Quaternion> param1 = ScriptUtil::getObjectPointer<Quaternion>(2, "Quaternion", true);
  506. PhysicsGenericConstraint* instance = getInstance(state);
  507. instance->setRotationOffsetA(*param1);
  508. return 0;
  509. }
  510. else
  511. {
  512. lua_pushstring(state, "lua_PhysicsGenericConstraint_setRotationOffsetA - Failed to match the given parameters to a valid function signature.");
  513. lua_error(state);
  514. }
  515. break;
  516. }
  517. default:
  518. {
  519. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  520. lua_error(state);
  521. break;
  522. }
  523. }
  524. return 0;
  525. }
  526. int lua_PhysicsGenericConstraint_setRotationOffsetB(lua_State* state)
  527. {
  528. // Get the number of parameters.
  529. int paramCount = lua_gettop(state);
  530. // Attempt to match the parameters to a valid binding.
  531. switch (paramCount)
  532. {
  533. case 2:
  534. {
  535. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  536. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  537. {
  538. // Get parameter 1 off the stack.
  539. ScriptUtil::LuaArray<Quaternion> param1 = ScriptUtil::getObjectPointer<Quaternion>(2, "Quaternion", true);
  540. PhysicsGenericConstraint* instance = getInstance(state);
  541. instance->setRotationOffsetB(*param1);
  542. return 0;
  543. }
  544. else
  545. {
  546. lua_pushstring(state, "lua_PhysicsGenericConstraint_setRotationOffsetB - Failed to match the given parameters to a valid function signature.");
  547. lua_error(state);
  548. }
  549. break;
  550. }
  551. default:
  552. {
  553. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  554. lua_error(state);
  555. break;
  556. }
  557. }
  558. return 0;
  559. }
  560. int lua_PhysicsGenericConstraint_setTranslationOffsetA(lua_State* state)
  561. {
  562. // Get the number of parameters.
  563. int paramCount = lua_gettop(state);
  564. // Attempt to match the parameters to a valid binding.
  565. switch (paramCount)
  566. {
  567. case 2:
  568. {
  569. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  570. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  571. {
  572. // Get parameter 1 off the stack.
  573. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  574. PhysicsGenericConstraint* instance = getInstance(state);
  575. instance->setTranslationOffsetA(*param1);
  576. return 0;
  577. }
  578. else
  579. {
  580. lua_pushstring(state, "lua_PhysicsGenericConstraint_setTranslationOffsetA - Failed to match the given parameters to a valid function signature.");
  581. lua_error(state);
  582. }
  583. break;
  584. }
  585. default:
  586. {
  587. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  588. lua_error(state);
  589. break;
  590. }
  591. }
  592. return 0;
  593. }
  594. int lua_PhysicsGenericConstraint_setTranslationOffsetB(lua_State* state)
  595. {
  596. // Get the number of parameters.
  597. int paramCount = lua_gettop(state);
  598. // Attempt to match the parameters to a valid binding.
  599. switch (paramCount)
  600. {
  601. case 2:
  602. {
  603. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  604. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  605. {
  606. // Get parameter 1 off the stack.
  607. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  608. PhysicsGenericConstraint* instance = getInstance(state);
  609. instance->setTranslationOffsetB(*param1);
  610. return 0;
  611. }
  612. else
  613. {
  614. lua_pushstring(state, "lua_PhysicsGenericConstraint_setTranslationOffsetB - Failed to match the given parameters to a valid function signature.");
  615. lua_error(state);
  616. }
  617. break;
  618. }
  619. default:
  620. {
  621. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  622. lua_error(state);
  623. break;
  624. }
  625. }
  626. return 0;
  627. }
  628. int lua_PhysicsGenericConstraint_static_centerOfMassMidpoint(lua_State* state)
  629. {
  630. // Get the number of parameters.
  631. int paramCount = lua_gettop(state);
  632. // Attempt to match the parameters to a valid binding.
  633. switch (paramCount)
  634. {
  635. case 2:
  636. {
  637. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  638. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  639. {
  640. // Get parameter 1 off the stack.
  641. ScriptUtil::LuaArray<Node> param1 = ScriptUtil::getObjectPointer<Node>(1, "Node", false);
  642. // Get parameter 2 off the stack.
  643. ScriptUtil::LuaArray<Node> param2 = ScriptUtil::getObjectPointer<Node>(2, "Node", false);
  644. void* returnPtr = (void*)new Vector3(PhysicsGenericConstraint::centerOfMassMidpoint(param1, param2));
  645. if (returnPtr)
  646. {
  647. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  648. object->instance = returnPtr;
  649. object->owns = true;
  650. luaL_getmetatable(state, "Vector3");
  651. lua_setmetatable(state, -2);
  652. }
  653. else
  654. {
  655. lua_pushnil(state);
  656. }
  657. return 1;
  658. }
  659. else
  660. {
  661. lua_pushstring(state, "lua_PhysicsGenericConstraint_static_centerOfMassMidpoint - Failed to match the given parameters to a valid function signature.");
  662. lua_error(state);
  663. }
  664. break;
  665. }
  666. default:
  667. {
  668. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  669. lua_error(state);
  670. break;
  671. }
  672. }
  673. return 0;
  674. }
  675. int lua_PhysicsGenericConstraint_static_getRotationOffset(lua_State* state)
  676. {
  677. // Get the number of parameters.
  678. int paramCount = lua_gettop(state);
  679. // Attempt to match the parameters to a valid binding.
  680. switch (paramCount)
  681. {
  682. case 2:
  683. {
  684. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  685. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  686. {
  687. // Get parameter 1 off the stack.
  688. ScriptUtil::LuaArray<Node> param1 = ScriptUtil::getObjectPointer<Node>(1, "Node", false);
  689. // Get parameter 2 off the stack.
  690. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  691. void* returnPtr = (void*)new Quaternion(PhysicsGenericConstraint::getRotationOffset(param1, *param2));
  692. if (returnPtr)
  693. {
  694. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  695. object->instance = returnPtr;
  696. object->owns = true;
  697. luaL_getmetatable(state, "Quaternion");
  698. lua_setmetatable(state, -2);
  699. }
  700. else
  701. {
  702. lua_pushnil(state);
  703. }
  704. return 1;
  705. }
  706. else
  707. {
  708. lua_pushstring(state, "lua_PhysicsGenericConstraint_static_getRotationOffset - Failed to match the given parameters to a valid function signature.");
  709. lua_error(state);
  710. }
  711. break;
  712. }
  713. default:
  714. {
  715. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  716. lua_error(state);
  717. break;
  718. }
  719. }
  720. return 0;
  721. }
  722. int lua_PhysicsGenericConstraint_static_getTranslationOffset(lua_State* state)
  723. {
  724. // Get the number of parameters.
  725. int paramCount = lua_gettop(state);
  726. // Attempt to match the parameters to a valid binding.
  727. switch (paramCount)
  728. {
  729. case 2:
  730. {
  731. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  732. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  733. {
  734. // Get parameter 1 off the stack.
  735. ScriptUtil::LuaArray<Node> param1 = ScriptUtil::getObjectPointer<Node>(1, "Node", false);
  736. // Get parameter 2 off the stack.
  737. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  738. void* returnPtr = (void*)new Vector3(PhysicsGenericConstraint::getTranslationOffset(param1, *param2));
  739. if (returnPtr)
  740. {
  741. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  742. object->instance = returnPtr;
  743. object->owns = true;
  744. luaL_getmetatable(state, "Vector3");
  745. lua_setmetatable(state, -2);
  746. }
  747. else
  748. {
  749. lua_pushnil(state);
  750. }
  751. return 1;
  752. }
  753. else
  754. {
  755. lua_pushstring(state, "lua_PhysicsGenericConstraint_static_getTranslationOffset - Failed to match the given parameters to a valid function signature.");
  756. lua_error(state);
  757. }
  758. break;
  759. }
  760. default:
  761. {
  762. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  763. lua_error(state);
  764. break;
  765. }
  766. }
  767. return 0;
  768. }
  769. }