lua_Frustum.cpp 28 KB

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