lua_PhysicsFixedConstraint.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsFixedConstraint.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Node.h"
  7. #include "PhysicsConstraint.h"
  8. #include "PhysicsFixedConstraint.h"
  9. #include "PhysicsGenericConstraint.h"
  10. #include "PhysicsRigidBody.h"
  11. namespace gameplay
  12. {
  13. void luaRegister_PhysicsFixedConstraint()
  14. {
  15. const luaL_Reg lua_members[] =
  16. {
  17. {"getBreakingImpulse", lua_PhysicsFixedConstraint_getBreakingImpulse},
  18. {"getRotationOffsetA", lua_PhysicsFixedConstraint_getRotationOffsetA},
  19. {"getRotationOffsetB", lua_PhysicsFixedConstraint_getRotationOffsetB},
  20. {"getTranslationOffsetA", lua_PhysicsFixedConstraint_getTranslationOffsetA},
  21. {"getTranslationOffsetB", lua_PhysicsFixedConstraint_getTranslationOffsetB},
  22. {"isEnabled", lua_PhysicsFixedConstraint_isEnabled},
  23. {"setBreakingImpulse", lua_PhysicsFixedConstraint_setBreakingImpulse},
  24. {"setEnabled", lua_PhysicsFixedConstraint_setEnabled},
  25. {"setRotationOffsetA", lua_PhysicsFixedConstraint_setRotationOffsetA},
  26. {"setRotationOffsetB", lua_PhysicsFixedConstraint_setRotationOffsetB},
  27. {"setTranslationOffsetA", lua_PhysicsFixedConstraint_setTranslationOffsetA},
  28. {"setTranslationOffsetB", lua_PhysicsFixedConstraint_setTranslationOffsetB},
  29. {NULL, NULL}
  30. };
  31. const luaL_Reg lua_statics[] =
  32. {
  33. {"centerOfMassMidpoint", lua_PhysicsFixedConstraint_static_centerOfMassMidpoint},
  34. {"getRotationOffset", lua_PhysicsFixedConstraint_static_getRotationOffset},
  35. {"getTranslationOffset", lua_PhysicsFixedConstraint_static_getTranslationOffset},
  36. {NULL, NULL}
  37. };
  38. std::vector<std::string> scopePath;
  39. gameplay::ScriptUtil::registerClass("PhysicsFixedConstraint", lua_members, NULL, NULL, lua_statics, scopePath);
  40. }
  41. static PhysicsFixedConstraint* getInstance(lua_State* state)
  42. {
  43. void* userdata = luaL_checkudata(state, 1, "PhysicsFixedConstraint");
  44. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsFixedConstraint' expected.");
  45. return (PhysicsFixedConstraint*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  46. }
  47. int lua_PhysicsFixedConstraint_getBreakingImpulse(lua_State* state)
  48. {
  49. // Get the number of parameters.
  50. int paramCount = lua_gettop(state);
  51. // Attempt to match the parameters to a valid binding.
  52. switch (paramCount)
  53. {
  54. case 1:
  55. {
  56. if ((lua_type(state, 1) == LUA_TUSERDATA))
  57. {
  58. PhysicsFixedConstraint* instance = getInstance(state);
  59. float result = instance->getBreakingImpulse();
  60. // Push the return value onto the stack.
  61. lua_pushnumber(state, result);
  62. return 1;
  63. }
  64. lua_pushstring(state, "lua_PhysicsFixedConstraint_getBreakingImpulse - Failed to match the given parameters to a valid function signature.");
  65. lua_error(state);
  66. break;
  67. }
  68. default:
  69. {
  70. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  71. lua_error(state);
  72. break;
  73. }
  74. }
  75. return 0;
  76. }
  77. int lua_PhysicsFixedConstraint_getRotationOffsetA(lua_State* state)
  78. {
  79. // Get the number of parameters.
  80. int paramCount = lua_gettop(state);
  81. // Attempt to match the parameters to a valid binding.
  82. switch (paramCount)
  83. {
  84. case 1:
  85. {
  86. if ((lua_type(state, 1) == LUA_TUSERDATA))
  87. {
  88. PhysicsFixedConstraint* instance = getInstance(state);
  89. void* returnPtr = (void*)&(instance->getRotationOffsetA());
  90. if (returnPtr)
  91. {
  92. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  93. object->instance = returnPtr;
  94. object->owns = false;
  95. luaL_getmetatable(state, "Quaternion");
  96. lua_setmetatable(state, -2);
  97. }
  98. else
  99. {
  100. lua_pushnil(state);
  101. }
  102. return 1;
  103. }
  104. lua_pushstring(state, "lua_PhysicsFixedConstraint_getRotationOffsetA - Failed to match the given parameters to a valid function signature.");
  105. lua_error(state);
  106. break;
  107. }
  108. default:
  109. {
  110. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  111. lua_error(state);
  112. break;
  113. }
  114. }
  115. return 0;
  116. }
  117. int lua_PhysicsFixedConstraint_getRotationOffsetB(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 1:
  125. {
  126. if ((lua_type(state, 1) == LUA_TUSERDATA))
  127. {
  128. PhysicsFixedConstraint* instance = getInstance(state);
  129. void* returnPtr = (void*)&(instance->getRotationOffsetB());
  130. if (returnPtr)
  131. {
  132. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  133. object->instance = returnPtr;
  134. object->owns = false;
  135. luaL_getmetatable(state, "Quaternion");
  136. lua_setmetatable(state, -2);
  137. }
  138. else
  139. {
  140. lua_pushnil(state);
  141. }
  142. return 1;
  143. }
  144. lua_pushstring(state, "lua_PhysicsFixedConstraint_getRotationOffsetB - Failed to match the given parameters to a valid function signature.");
  145. lua_error(state);
  146. break;
  147. }
  148. default:
  149. {
  150. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  151. lua_error(state);
  152. break;
  153. }
  154. }
  155. return 0;
  156. }
  157. int lua_PhysicsFixedConstraint_getTranslationOffsetA(lua_State* state)
  158. {
  159. // Get the number of parameters.
  160. int paramCount = lua_gettop(state);
  161. // Attempt to match the parameters to a valid binding.
  162. switch (paramCount)
  163. {
  164. case 1:
  165. {
  166. if ((lua_type(state, 1) == LUA_TUSERDATA))
  167. {
  168. PhysicsFixedConstraint* instance = getInstance(state);
  169. void* returnPtr = (void*)&(instance->getTranslationOffsetA());
  170. if (returnPtr)
  171. {
  172. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  173. object->instance = returnPtr;
  174. object->owns = false;
  175. luaL_getmetatable(state, "Vector3");
  176. lua_setmetatable(state, -2);
  177. }
  178. else
  179. {
  180. lua_pushnil(state);
  181. }
  182. return 1;
  183. }
  184. lua_pushstring(state, "lua_PhysicsFixedConstraint_getTranslationOffsetA - Failed to match the given parameters to a valid function signature.");
  185. lua_error(state);
  186. break;
  187. }
  188. default:
  189. {
  190. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  191. lua_error(state);
  192. break;
  193. }
  194. }
  195. return 0;
  196. }
  197. int lua_PhysicsFixedConstraint_getTranslationOffsetB(lua_State* state)
  198. {
  199. // Get the number of parameters.
  200. int paramCount = lua_gettop(state);
  201. // Attempt to match the parameters to a valid binding.
  202. switch (paramCount)
  203. {
  204. case 1:
  205. {
  206. if ((lua_type(state, 1) == LUA_TUSERDATA))
  207. {
  208. PhysicsFixedConstraint* instance = getInstance(state);
  209. void* returnPtr = (void*)&(instance->getTranslationOffsetB());
  210. if (returnPtr)
  211. {
  212. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  213. object->instance = returnPtr;
  214. object->owns = false;
  215. luaL_getmetatable(state, "Vector3");
  216. lua_setmetatable(state, -2);
  217. }
  218. else
  219. {
  220. lua_pushnil(state);
  221. }
  222. return 1;
  223. }
  224. lua_pushstring(state, "lua_PhysicsFixedConstraint_getTranslationOffsetB - Failed to match the given parameters to a valid function signature.");
  225. lua_error(state);
  226. break;
  227. }
  228. default:
  229. {
  230. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  231. lua_error(state);
  232. break;
  233. }
  234. }
  235. return 0;
  236. }
  237. int lua_PhysicsFixedConstraint_isEnabled(lua_State* state)
  238. {
  239. // Get the number of parameters.
  240. int paramCount = lua_gettop(state);
  241. // Attempt to match the parameters to a valid binding.
  242. switch (paramCount)
  243. {
  244. case 1:
  245. {
  246. if ((lua_type(state, 1) == LUA_TUSERDATA))
  247. {
  248. PhysicsFixedConstraint* instance = getInstance(state);
  249. bool result = instance->isEnabled();
  250. // Push the return value onto the stack.
  251. lua_pushboolean(state, result);
  252. return 1;
  253. }
  254. lua_pushstring(state, "lua_PhysicsFixedConstraint_isEnabled - Failed to match the given parameters to a valid function signature.");
  255. lua_error(state);
  256. break;
  257. }
  258. default:
  259. {
  260. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  261. lua_error(state);
  262. break;
  263. }
  264. }
  265. return 0;
  266. }
  267. int lua_PhysicsFixedConstraint_setBreakingImpulse(lua_State* state)
  268. {
  269. // Get the number of parameters.
  270. int paramCount = lua_gettop(state);
  271. // Attempt to match the parameters to a valid binding.
  272. switch (paramCount)
  273. {
  274. case 2:
  275. {
  276. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  277. lua_type(state, 2) == LUA_TNUMBER)
  278. {
  279. // Get parameter 1 off the stack.
  280. float param1 = (float)luaL_checknumber(state, 2);
  281. PhysicsFixedConstraint* instance = getInstance(state);
  282. instance->setBreakingImpulse(param1);
  283. return 0;
  284. }
  285. lua_pushstring(state, "lua_PhysicsFixedConstraint_setBreakingImpulse - Failed to match the given parameters to a valid function signature.");
  286. lua_error(state);
  287. break;
  288. }
  289. default:
  290. {
  291. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  292. lua_error(state);
  293. break;
  294. }
  295. }
  296. return 0;
  297. }
  298. int lua_PhysicsFixedConstraint_setEnabled(lua_State* state)
  299. {
  300. // Get the number of parameters.
  301. int paramCount = lua_gettop(state);
  302. // Attempt to match the parameters to a valid binding.
  303. switch (paramCount)
  304. {
  305. case 2:
  306. {
  307. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  308. lua_type(state, 2) == LUA_TBOOLEAN)
  309. {
  310. // Get parameter 1 off the stack.
  311. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  312. PhysicsFixedConstraint* instance = getInstance(state);
  313. instance->setEnabled(param1);
  314. return 0;
  315. }
  316. lua_pushstring(state, "lua_PhysicsFixedConstraint_setEnabled - Failed to match the given parameters to a valid function signature.");
  317. lua_error(state);
  318. break;
  319. }
  320. default:
  321. {
  322. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  323. lua_error(state);
  324. break;
  325. }
  326. }
  327. return 0;
  328. }
  329. int lua_PhysicsFixedConstraint_setRotationOffsetA(lua_State* state)
  330. {
  331. // Get the number of parameters.
  332. int paramCount = lua_gettop(state);
  333. // Attempt to match the parameters to a valid binding.
  334. switch (paramCount)
  335. {
  336. case 2:
  337. {
  338. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  339. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  340. {
  341. // Get parameter 1 off the stack.
  342. bool param1Valid;
  343. gameplay::ScriptUtil::LuaArray<Quaternion> param1 = gameplay::ScriptUtil::getObjectPointer<Quaternion>(2, "Quaternion", true, &param1Valid);
  344. if (!param1Valid)
  345. {
  346. lua_pushstring(state, "Failed to convert parameter 1 to type 'Quaternion'.");
  347. lua_error(state);
  348. }
  349. PhysicsFixedConstraint* instance = getInstance(state);
  350. instance->setRotationOffsetA(*param1);
  351. return 0;
  352. }
  353. lua_pushstring(state, "lua_PhysicsFixedConstraint_setRotationOffsetA - Failed to match the given parameters to a valid function signature.");
  354. lua_error(state);
  355. break;
  356. }
  357. default:
  358. {
  359. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  360. lua_error(state);
  361. break;
  362. }
  363. }
  364. return 0;
  365. }
  366. int lua_PhysicsFixedConstraint_setRotationOffsetB(lua_State* state)
  367. {
  368. // Get the number of parameters.
  369. int paramCount = lua_gettop(state);
  370. // Attempt to match the parameters to a valid binding.
  371. switch (paramCount)
  372. {
  373. case 2:
  374. {
  375. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  376. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  377. {
  378. // Get parameter 1 off the stack.
  379. bool param1Valid;
  380. gameplay::ScriptUtil::LuaArray<Quaternion> param1 = gameplay::ScriptUtil::getObjectPointer<Quaternion>(2, "Quaternion", true, &param1Valid);
  381. if (!param1Valid)
  382. {
  383. lua_pushstring(state, "Failed to convert parameter 1 to type 'Quaternion'.");
  384. lua_error(state);
  385. }
  386. PhysicsFixedConstraint* instance = getInstance(state);
  387. instance->setRotationOffsetB(*param1);
  388. return 0;
  389. }
  390. lua_pushstring(state, "lua_PhysicsFixedConstraint_setRotationOffsetB - Failed to match the given parameters to a valid function signature.");
  391. lua_error(state);
  392. break;
  393. }
  394. default:
  395. {
  396. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  397. lua_error(state);
  398. break;
  399. }
  400. }
  401. return 0;
  402. }
  403. int lua_PhysicsFixedConstraint_setTranslationOffsetA(lua_State* state)
  404. {
  405. // Get the number of parameters.
  406. int paramCount = lua_gettop(state);
  407. // Attempt to match the parameters to a valid binding.
  408. switch (paramCount)
  409. {
  410. case 2:
  411. {
  412. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  413. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  414. {
  415. // Get parameter 1 off the stack.
  416. bool param1Valid;
  417. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
  418. if (!param1Valid)
  419. {
  420. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector3'.");
  421. lua_error(state);
  422. }
  423. PhysicsFixedConstraint* instance = getInstance(state);
  424. instance->setTranslationOffsetA(*param1);
  425. return 0;
  426. }
  427. lua_pushstring(state, "lua_PhysicsFixedConstraint_setTranslationOffsetA - Failed to match the given parameters to a valid function signature.");
  428. lua_error(state);
  429. break;
  430. }
  431. default:
  432. {
  433. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  434. lua_error(state);
  435. break;
  436. }
  437. }
  438. return 0;
  439. }
  440. int lua_PhysicsFixedConstraint_setTranslationOffsetB(lua_State* state)
  441. {
  442. // Get the number of parameters.
  443. int paramCount = lua_gettop(state);
  444. // Attempt to match the parameters to a valid binding.
  445. switch (paramCount)
  446. {
  447. case 2:
  448. {
  449. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  450. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  451. {
  452. // Get parameter 1 off the stack.
  453. bool param1Valid;
  454. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
  455. if (!param1Valid)
  456. {
  457. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector3'.");
  458. lua_error(state);
  459. }
  460. PhysicsFixedConstraint* instance = getInstance(state);
  461. instance->setTranslationOffsetB(*param1);
  462. return 0;
  463. }
  464. lua_pushstring(state, "lua_PhysicsFixedConstraint_setTranslationOffsetB - Failed to match the given parameters to a valid function signature.");
  465. lua_error(state);
  466. break;
  467. }
  468. default:
  469. {
  470. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  471. lua_error(state);
  472. break;
  473. }
  474. }
  475. return 0;
  476. }
  477. int lua_PhysicsFixedConstraint_static_centerOfMassMidpoint(lua_State* state)
  478. {
  479. // Get the number of parameters.
  480. int paramCount = lua_gettop(state);
  481. // Attempt to match the parameters to a valid binding.
  482. switch (paramCount)
  483. {
  484. case 2:
  485. {
  486. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  487. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  488. {
  489. // Get parameter 1 off the stack.
  490. bool param1Valid;
  491. gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(1, "Node", false, &param1Valid);
  492. if (!param1Valid)
  493. {
  494. lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
  495. lua_error(state);
  496. }
  497. // Get parameter 2 off the stack.
  498. bool param2Valid;
  499. gameplay::ScriptUtil::LuaArray<Node> param2 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param2Valid);
  500. if (!param2Valid)
  501. {
  502. lua_pushstring(state, "Failed to convert parameter 2 to type 'Node'.");
  503. lua_error(state);
  504. }
  505. void* returnPtr = (void*)new Vector3(PhysicsFixedConstraint::centerOfMassMidpoint(param1, param2));
  506. if (returnPtr)
  507. {
  508. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  509. object->instance = returnPtr;
  510. object->owns = true;
  511. luaL_getmetatable(state, "Vector3");
  512. lua_setmetatable(state, -2);
  513. }
  514. else
  515. {
  516. lua_pushnil(state);
  517. }
  518. return 1;
  519. }
  520. lua_pushstring(state, "lua_PhysicsFixedConstraint_static_centerOfMassMidpoint - Failed to match the given parameters to a valid function signature.");
  521. lua_error(state);
  522. break;
  523. }
  524. default:
  525. {
  526. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  527. lua_error(state);
  528. break;
  529. }
  530. }
  531. return 0;
  532. }
  533. int lua_PhysicsFixedConstraint_static_getRotationOffset(lua_State* state)
  534. {
  535. // Get the number of parameters.
  536. int paramCount = lua_gettop(state);
  537. // Attempt to match the parameters to a valid binding.
  538. switch (paramCount)
  539. {
  540. case 2:
  541. {
  542. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  543. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  544. {
  545. // Get parameter 1 off the stack.
  546. bool param1Valid;
  547. gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(1, "Node", false, &param1Valid);
  548. if (!param1Valid)
  549. {
  550. lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
  551. lua_error(state);
  552. }
  553. // Get parameter 2 off the stack.
  554. bool param2Valid;
  555. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  556. if (!param2Valid)
  557. {
  558. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector3'.");
  559. lua_error(state);
  560. }
  561. void* returnPtr = (void*)new Quaternion(PhysicsFixedConstraint::getRotationOffset(param1, *param2));
  562. if (returnPtr)
  563. {
  564. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  565. object->instance = returnPtr;
  566. object->owns = true;
  567. luaL_getmetatable(state, "Quaternion");
  568. lua_setmetatable(state, -2);
  569. }
  570. else
  571. {
  572. lua_pushnil(state);
  573. }
  574. return 1;
  575. }
  576. lua_pushstring(state, "lua_PhysicsFixedConstraint_static_getRotationOffset - Failed to match the given parameters to a valid function signature.");
  577. lua_error(state);
  578. break;
  579. }
  580. default:
  581. {
  582. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  583. lua_error(state);
  584. break;
  585. }
  586. }
  587. return 0;
  588. }
  589. int lua_PhysicsFixedConstraint_static_getTranslationOffset(lua_State* state)
  590. {
  591. // Get the number of parameters.
  592. int paramCount = lua_gettop(state);
  593. // Attempt to match the parameters to a valid binding.
  594. switch (paramCount)
  595. {
  596. case 2:
  597. {
  598. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  599. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  600. {
  601. // Get parameter 1 off the stack.
  602. bool param1Valid;
  603. gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(1, "Node", false, &param1Valid);
  604. if (!param1Valid)
  605. {
  606. lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
  607. lua_error(state);
  608. }
  609. // Get parameter 2 off the stack.
  610. bool param2Valid;
  611. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  612. if (!param2Valid)
  613. {
  614. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector3'.");
  615. lua_error(state);
  616. }
  617. void* returnPtr = (void*)new Vector3(PhysicsFixedConstraint::getTranslationOffset(param1, *param2));
  618. if (returnPtr)
  619. {
  620. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  621. object->instance = returnPtr;
  622. object->owns = true;
  623. luaL_getmetatable(state, "Vector3");
  624. lua_setmetatable(state, -2);
  625. }
  626. else
  627. {
  628. lua_pushnil(state);
  629. }
  630. return 1;
  631. }
  632. lua_pushstring(state, "lua_PhysicsFixedConstraint_static_getTranslationOffset - Failed to match the given parameters to a valid function signature.");
  633. lua_error(state);
  634. break;
  635. }
  636. default:
  637. {
  638. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  639. lua_error(state);
  640. break;
  641. }
  642. }
  643. return 0;
  644. }
  645. }