lua_PhysicsCollisionShape.cpp 30 KB

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