lua_Frustum.cpp 25 KB

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