lua_Light.cpp 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_Light.h"
  4. #include "Base.h"
  5. #include "Game.h"
  6. #include "Light.h"
  7. #include "Node.h"
  8. #include "Ref.h"
  9. #include "lua_LightType.h"
  10. namespace gameplay
  11. {
  12. void luaRegister_Light()
  13. {
  14. const luaL_Reg lua_members[] =
  15. {
  16. {"addRef", lua_Light_addRef},
  17. {"getColor", lua_Light_getColor},
  18. {"getInnerAngle", lua_Light_getInnerAngle},
  19. {"getInnerAngleCos", lua_Light_getInnerAngleCos},
  20. {"getLightType", lua_Light_getLightType},
  21. {"getNode", lua_Light_getNode},
  22. {"getOuterAngle", lua_Light_getOuterAngle},
  23. {"getOuterAngleCos", lua_Light_getOuterAngleCos},
  24. {"getRange", lua_Light_getRange},
  25. {"getRangeInverse", lua_Light_getRangeInverse},
  26. {"getRefCount", lua_Light_getRefCount},
  27. {"release", lua_Light_release},
  28. {"setColor", lua_Light_setColor},
  29. {"setInnerAngle", lua_Light_setInnerAngle},
  30. {"setOuterAngle", lua_Light_setOuterAngle},
  31. {"setRange", lua_Light_setRange},
  32. {NULL, NULL}
  33. };
  34. const luaL_Reg lua_statics[] =
  35. {
  36. {"createDirectional", lua_Light_static_createDirectional},
  37. {"createPoint", lua_Light_static_createPoint},
  38. {"createSpot", lua_Light_static_createSpot},
  39. {NULL, NULL}
  40. };
  41. std::vector<std::string> scopePath;
  42. gameplay::ScriptUtil::registerClass("Light", lua_members, NULL, lua_Light__gc, lua_statics, scopePath);
  43. }
  44. static Light* getInstance(lua_State* state)
  45. {
  46. void* userdata = luaL_checkudata(state, 1, "Light");
  47. luaL_argcheck(state, userdata != NULL, 1, "'Light' expected.");
  48. return (Light*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  49. }
  50. int lua_Light__gc(lua_State* state)
  51. {
  52. // Get the number of parameters.
  53. int paramCount = lua_gettop(state);
  54. // Attempt to match the parameters to a valid binding.
  55. switch (paramCount)
  56. {
  57. case 1:
  58. {
  59. if ((lua_type(state, 1) == LUA_TUSERDATA))
  60. {
  61. void* userdata = luaL_checkudata(state, 1, "Light");
  62. luaL_argcheck(state, userdata != NULL, 1, "'Light' expected.");
  63. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  64. if (object->owns)
  65. {
  66. Light* instance = (Light*)object->instance;
  67. SAFE_RELEASE(instance);
  68. }
  69. return 0;
  70. }
  71. lua_pushstring(state, "lua_Light__gc - Failed to match the given parameters to a valid function signature.");
  72. lua_error(state);
  73. break;
  74. }
  75. default:
  76. {
  77. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  78. lua_error(state);
  79. break;
  80. }
  81. }
  82. return 0;
  83. }
  84. int lua_Light_addRef(lua_State* state)
  85. {
  86. // Get the number of parameters.
  87. int paramCount = lua_gettop(state);
  88. // Attempt to match the parameters to a valid binding.
  89. switch (paramCount)
  90. {
  91. case 1:
  92. {
  93. if ((lua_type(state, 1) == LUA_TUSERDATA))
  94. {
  95. Light* instance = getInstance(state);
  96. instance->addRef();
  97. return 0;
  98. }
  99. lua_pushstring(state, "lua_Light_addRef - Failed to match the given parameters to a valid function signature.");
  100. lua_error(state);
  101. break;
  102. }
  103. default:
  104. {
  105. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  106. lua_error(state);
  107. break;
  108. }
  109. }
  110. return 0;
  111. }
  112. int lua_Light_getColor(lua_State* state)
  113. {
  114. // Get the number of parameters.
  115. int paramCount = lua_gettop(state);
  116. // Attempt to match the parameters to a valid binding.
  117. switch (paramCount)
  118. {
  119. case 1:
  120. {
  121. if ((lua_type(state, 1) == LUA_TUSERDATA))
  122. {
  123. Light* instance = getInstance(state);
  124. void* returnPtr = (void*)&(instance->getColor());
  125. if (returnPtr)
  126. {
  127. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  128. object->instance = returnPtr;
  129. object->owns = false;
  130. luaL_getmetatable(state, "Vector3");
  131. lua_setmetatable(state, -2);
  132. }
  133. else
  134. {
  135. lua_pushnil(state);
  136. }
  137. return 1;
  138. }
  139. lua_pushstring(state, "lua_Light_getColor - Failed to match the given parameters to a valid function signature.");
  140. lua_error(state);
  141. break;
  142. }
  143. default:
  144. {
  145. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  146. lua_error(state);
  147. break;
  148. }
  149. }
  150. return 0;
  151. }
  152. int lua_Light_getInnerAngle(lua_State* state)
  153. {
  154. // Get the number of parameters.
  155. int paramCount = lua_gettop(state);
  156. // Attempt to match the parameters to a valid binding.
  157. switch (paramCount)
  158. {
  159. case 1:
  160. {
  161. if ((lua_type(state, 1) == LUA_TUSERDATA))
  162. {
  163. Light* instance = getInstance(state);
  164. float result = instance->getInnerAngle();
  165. // Push the return value onto the stack.
  166. lua_pushnumber(state, result);
  167. return 1;
  168. }
  169. lua_pushstring(state, "lua_Light_getInnerAngle - Failed to match the given parameters to a valid function signature.");
  170. lua_error(state);
  171. break;
  172. }
  173. default:
  174. {
  175. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  176. lua_error(state);
  177. break;
  178. }
  179. }
  180. return 0;
  181. }
  182. int lua_Light_getInnerAngleCos(lua_State* state)
  183. {
  184. // Get the number of parameters.
  185. int paramCount = lua_gettop(state);
  186. // Attempt to match the parameters to a valid binding.
  187. switch (paramCount)
  188. {
  189. case 1:
  190. {
  191. if ((lua_type(state, 1) == LUA_TUSERDATA))
  192. {
  193. Light* instance = getInstance(state);
  194. float result = instance->getInnerAngleCos();
  195. // Push the return value onto the stack.
  196. lua_pushnumber(state, result);
  197. return 1;
  198. }
  199. lua_pushstring(state, "lua_Light_getInnerAngleCos - Failed to match the given parameters to a valid function signature.");
  200. lua_error(state);
  201. break;
  202. }
  203. default:
  204. {
  205. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  206. lua_error(state);
  207. break;
  208. }
  209. }
  210. return 0;
  211. }
  212. int lua_Light_getLightType(lua_State* state)
  213. {
  214. // Get the number of parameters.
  215. int paramCount = lua_gettop(state);
  216. // Attempt to match the parameters to a valid binding.
  217. switch (paramCount)
  218. {
  219. case 1:
  220. {
  221. if ((lua_type(state, 1) == LUA_TUSERDATA))
  222. {
  223. Light* instance = getInstance(state);
  224. Light::Type result = instance->getLightType();
  225. // Push the return value onto the stack.
  226. lua_pushstring(state, lua_stringFromEnum_LightType(result));
  227. return 1;
  228. }
  229. lua_pushstring(state, "lua_Light_getLightType - Failed to match the given parameters to a valid function signature.");
  230. lua_error(state);
  231. break;
  232. }
  233. default:
  234. {
  235. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  236. lua_error(state);
  237. break;
  238. }
  239. }
  240. return 0;
  241. }
  242. int lua_Light_getNode(lua_State* state)
  243. {
  244. // Get the number of parameters.
  245. int paramCount = lua_gettop(state);
  246. // Attempt to match the parameters to a valid binding.
  247. switch (paramCount)
  248. {
  249. case 1:
  250. {
  251. if ((lua_type(state, 1) == LUA_TUSERDATA))
  252. {
  253. Light* instance = getInstance(state);
  254. void* returnPtr = (void*)instance->getNode();
  255. if (returnPtr)
  256. {
  257. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  258. object->instance = returnPtr;
  259. object->owns = false;
  260. luaL_getmetatable(state, "Node");
  261. lua_setmetatable(state, -2);
  262. }
  263. else
  264. {
  265. lua_pushnil(state);
  266. }
  267. return 1;
  268. }
  269. lua_pushstring(state, "lua_Light_getNode - Failed to match the given parameters to a valid function signature.");
  270. lua_error(state);
  271. break;
  272. }
  273. default:
  274. {
  275. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  276. lua_error(state);
  277. break;
  278. }
  279. }
  280. return 0;
  281. }
  282. int lua_Light_getOuterAngle(lua_State* state)
  283. {
  284. // Get the number of parameters.
  285. int paramCount = lua_gettop(state);
  286. // Attempt to match the parameters to a valid binding.
  287. switch (paramCount)
  288. {
  289. case 1:
  290. {
  291. if ((lua_type(state, 1) == LUA_TUSERDATA))
  292. {
  293. Light* instance = getInstance(state);
  294. float result = instance->getOuterAngle();
  295. // Push the return value onto the stack.
  296. lua_pushnumber(state, result);
  297. return 1;
  298. }
  299. lua_pushstring(state, "lua_Light_getOuterAngle - Failed to match the given parameters to a valid function signature.");
  300. lua_error(state);
  301. break;
  302. }
  303. default:
  304. {
  305. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  306. lua_error(state);
  307. break;
  308. }
  309. }
  310. return 0;
  311. }
  312. int lua_Light_getOuterAngleCos(lua_State* state)
  313. {
  314. // Get the number of parameters.
  315. int paramCount = lua_gettop(state);
  316. // Attempt to match the parameters to a valid binding.
  317. switch (paramCount)
  318. {
  319. case 1:
  320. {
  321. if ((lua_type(state, 1) == LUA_TUSERDATA))
  322. {
  323. Light* instance = getInstance(state);
  324. float result = instance->getOuterAngleCos();
  325. // Push the return value onto the stack.
  326. lua_pushnumber(state, result);
  327. return 1;
  328. }
  329. lua_pushstring(state, "lua_Light_getOuterAngleCos - Failed to match the given parameters to a valid function signature.");
  330. lua_error(state);
  331. break;
  332. }
  333. default:
  334. {
  335. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  336. lua_error(state);
  337. break;
  338. }
  339. }
  340. return 0;
  341. }
  342. int lua_Light_getRange(lua_State* state)
  343. {
  344. // Get the number of parameters.
  345. int paramCount = lua_gettop(state);
  346. // Attempt to match the parameters to a valid binding.
  347. switch (paramCount)
  348. {
  349. case 1:
  350. {
  351. if ((lua_type(state, 1) == LUA_TUSERDATA))
  352. {
  353. Light* instance = getInstance(state);
  354. float result = instance->getRange();
  355. // Push the return value onto the stack.
  356. lua_pushnumber(state, result);
  357. return 1;
  358. }
  359. lua_pushstring(state, "lua_Light_getRange - Failed to match the given parameters to a valid function signature.");
  360. lua_error(state);
  361. break;
  362. }
  363. default:
  364. {
  365. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  366. lua_error(state);
  367. break;
  368. }
  369. }
  370. return 0;
  371. }
  372. int lua_Light_getRangeInverse(lua_State* state)
  373. {
  374. // Get the number of parameters.
  375. int paramCount = lua_gettop(state);
  376. // Attempt to match the parameters to a valid binding.
  377. switch (paramCount)
  378. {
  379. case 1:
  380. {
  381. if ((lua_type(state, 1) == LUA_TUSERDATA))
  382. {
  383. Light* instance = getInstance(state);
  384. float result = instance->getRangeInverse();
  385. // Push the return value onto the stack.
  386. lua_pushnumber(state, result);
  387. return 1;
  388. }
  389. lua_pushstring(state, "lua_Light_getRangeInverse - Failed to match the given parameters to a valid function signature.");
  390. lua_error(state);
  391. break;
  392. }
  393. default:
  394. {
  395. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  396. lua_error(state);
  397. break;
  398. }
  399. }
  400. return 0;
  401. }
  402. int lua_Light_getRefCount(lua_State* state)
  403. {
  404. // Get the number of parameters.
  405. int paramCount = lua_gettop(state);
  406. // Attempt to match the parameters to a valid binding.
  407. switch (paramCount)
  408. {
  409. case 1:
  410. {
  411. if ((lua_type(state, 1) == LUA_TUSERDATA))
  412. {
  413. Light* instance = getInstance(state);
  414. unsigned int result = instance->getRefCount();
  415. // Push the return value onto the stack.
  416. lua_pushunsigned(state, result);
  417. return 1;
  418. }
  419. lua_pushstring(state, "lua_Light_getRefCount - Failed to match the given parameters to a valid function signature.");
  420. lua_error(state);
  421. break;
  422. }
  423. default:
  424. {
  425. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  426. lua_error(state);
  427. break;
  428. }
  429. }
  430. return 0;
  431. }
  432. int lua_Light_release(lua_State* state)
  433. {
  434. // Get the number of parameters.
  435. int paramCount = lua_gettop(state);
  436. // Attempt to match the parameters to a valid binding.
  437. switch (paramCount)
  438. {
  439. case 1:
  440. {
  441. if ((lua_type(state, 1) == LUA_TUSERDATA))
  442. {
  443. Light* instance = getInstance(state);
  444. instance->release();
  445. return 0;
  446. }
  447. lua_pushstring(state, "lua_Light_release - Failed to match the given parameters to a valid function signature.");
  448. lua_error(state);
  449. break;
  450. }
  451. default:
  452. {
  453. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  454. lua_error(state);
  455. break;
  456. }
  457. }
  458. return 0;
  459. }
  460. int lua_Light_setColor(lua_State* state)
  461. {
  462. // Get the number of parameters.
  463. int paramCount = lua_gettop(state);
  464. // Attempt to match the parameters to a valid binding.
  465. switch (paramCount)
  466. {
  467. case 2:
  468. {
  469. do
  470. {
  471. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  472. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  473. {
  474. // Get parameter 1 off the stack.
  475. bool param1Valid;
  476. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param1Valid);
  477. if (!param1Valid)
  478. break;
  479. Light* instance = getInstance(state);
  480. instance->setColor(*param1);
  481. return 0;
  482. }
  483. } while (0);
  484. lua_pushstring(state, "lua_Light_setColor - Failed to match the given parameters to a valid function signature.");
  485. lua_error(state);
  486. break;
  487. }
  488. case 4:
  489. {
  490. do
  491. {
  492. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  493. lua_type(state, 2) == LUA_TNUMBER &&
  494. lua_type(state, 3) == LUA_TNUMBER &&
  495. lua_type(state, 4) == LUA_TNUMBER)
  496. {
  497. // Get parameter 1 off the stack.
  498. float param1 = (float)luaL_checknumber(state, 2);
  499. // Get parameter 2 off the stack.
  500. float param2 = (float)luaL_checknumber(state, 3);
  501. // Get parameter 3 off the stack.
  502. float param3 = (float)luaL_checknumber(state, 4);
  503. Light* instance = getInstance(state);
  504. instance->setColor(param1, param2, param3);
  505. return 0;
  506. }
  507. } while (0);
  508. lua_pushstring(state, "lua_Light_setColor - Failed to match the given parameters to a valid function signature.");
  509. lua_error(state);
  510. break;
  511. }
  512. default:
  513. {
  514. lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
  515. lua_error(state);
  516. break;
  517. }
  518. }
  519. return 0;
  520. }
  521. int lua_Light_setInnerAngle(lua_State* state)
  522. {
  523. // Get the number of parameters.
  524. int paramCount = lua_gettop(state);
  525. // Attempt to match the parameters to a valid binding.
  526. switch (paramCount)
  527. {
  528. case 2:
  529. {
  530. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  531. lua_type(state, 2) == LUA_TNUMBER)
  532. {
  533. // Get parameter 1 off the stack.
  534. float param1 = (float)luaL_checknumber(state, 2);
  535. Light* instance = getInstance(state);
  536. instance->setInnerAngle(param1);
  537. return 0;
  538. }
  539. lua_pushstring(state, "lua_Light_setInnerAngle - Failed to match the given parameters to a valid function signature.");
  540. lua_error(state);
  541. break;
  542. }
  543. default:
  544. {
  545. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  546. lua_error(state);
  547. break;
  548. }
  549. }
  550. return 0;
  551. }
  552. int lua_Light_setOuterAngle(lua_State* state)
  553. {
  554. // Get the number of parameters.
  555. int paramCount = lua_gettop(state);
  556. // Attempt to match the parameters to a valid binding.
  557. switch (paramCount)
  558. {
  559. case 2:
  560. {
  561. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  562. lua_type(state, 2) == LUA_TNUMBER)
  563. {
  564. // Get parameter 1 off the stack.
  565. float param1 = (float)luaL_checknumber(state, 2);
  566. Light* instance = getInstance(state);
  567. instance->setOuterAngle(param1);
  568. return 0;
  569. }
  570. lua_pushstring(state, "lua_Light_setOuterAngle - Failed to match the given parameters to a valid function signature.");
  571. lua_error(state);
  572. break;
  573. }
  574. default:
  575. {
  576. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  577. lua_error(state);
  578. break;
  579. }
  580. }
  581. return 0;
  582. }
  583. int lua_Light_setRange(lua_State* state)
  584. {
  585. // Get the number of parameters.
  586. int paramCount = lua_gettop(state);
  587. // Attempt to match the parameters to a valid binding.
  588. switch (paramCount)
  589. {
  590. case 2:
  591. {
  592. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  593. lua_type(state, 2) == LUA_TNUMBER)
  594. {
  595. // Get parameter 1 off the stack.
  596. float param1 = (float)luaL_checknumber(state, 2);
  597. Light* instance = getInstance(state);
  598. instance->setRange(param1);
  599. return 0;
  600. }
  601. lua_pushstring(state, "lua_Light_setRange - Failed to match the given parameters to a valid function signature.");
  602. lua_error(state);
  603. break;
  604. }
  605. default:
  606. {
  607. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  608. lua_error(state);
  609. break;
  610. }
  611. }
  612. return 0;
  613. }
  614. int lua_Light_static_createDirectional(lua_State* state)
  615. {
  616. // Get the number of parameters.
  617. int paramCount = lua_gettop(state);
  618. // Attempt to match the parameters to a valid binding.
  619. switch (paramCount)
  620. {
  621. case 1:
  622. {
  623. do
  624. {
  625. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  626. {
  627. // Get parameter 1 off the stack.
  628. bool param1Valid;
  629. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  630. if (!param1Valid)
  631. break;
  632. void* returnPtr = (void*)Light::createDirectional(*param1);
  633. if (returnPtr)
  634. {
  635. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  636. object->instance = returnPtr;
  637. object->owns = true;
  638. luaL_getmetatable(state, "Light");
  639. lua_setmetatable(state, -2);
  640. }
  641. else
  642. {
  643. lua_pushnil(state);
  644. }
  645. return 1;
  646. }
  647. } while (0);
  648. lua_pushstring(state, "lua_Light_static_createDirectional - Failed to match the given parameters to a valid function signature.");
  649. lua_error(state);
  650. break;
  651. }
  652. case 3:
  653. {
  654. do
  655. {
  656. if (lua_type(state, 1) == LUA_TNUMBER &&
  657. lua_type(state, 2) == LUA_TNUMBER &&
  658. lua_type(state, 3) == LUA_TNUMBER)
  659. {
  660. // Get parameter 1 off the stack.
  661. float param1 = (float)luaL_checknumber(state, 1);
  662. // Get parameter 2 off the stack.
  663. float param2 = (float)luaL_checknumber(state, 2);
  664. // Get parameter 3 off the stack.
  665. float param3 = (float)luaL_checknumber(state, 3);
  666. void* returnPtr = (void*)Light::createDirectional(param1, param2, param3);
  667. if (returnPtr)
  668. {
  669. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  670. object->instance = returnPtr;
  671. object->owns = true;
  672. luaL_getmetatable(state, "Light");
  673. lua_setmetatable(state, -2);
  674. }
  675. else
  676. {
  677. lua_pushnil(state);
  678. }
  679. return 1;
  680. }
  681. } while (0);
  682. lua_pushstring(state, "lua_Light_static_createDirectional - Failed to match the given parameters to a valid function signature.");
  683. lua_error(state);
  684. break;
  685. }
  686. default:
  687. {
  688. lua_pushstring(state, "Invalid number of parameters (expected 1 or 3).");
  689. lua_error(state);
  690. break;
  691. }
  692. }
  693. return 0;
  694. }
  695. int lua_Light_static_createPoint(lua_State* state)
  696. {
  697. // Get the number of parameters.
  698. int paramCount = lua_gettop(state);
  699. // Attempt to match the parameters to a valid binding.
  700. switch (paramCount)
  701. {
  702. case 2:
  703. {
  704. do
  705. {
  706. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  707. lua_type(state, 2) == LUA_TNUMBER)
  708. {
  709. // Get parameter 1 off the stack.
  710. bool param1Valid;
  711. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  712. if (!param1Valid)
  713. break;
  714. // Get parameter 2 off the stack.
  715. float param2 = (float)luaL_checknumber(state, 2);
  716. void* returnPtr = (void*)Light::createPoint(*param1, param2);
  717. if (returnPtr)
  718. {
  719. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  720. object->instance = returnPtr;
  721. object->owns = true;
  722. luaL_getmetatable(state, "Light");
  723. lua_setmetatable(state, -2);
  724. }
  725. else
  726. {
  727. lua_pushnil(state);
  728. }
  729. return 1;
  730. }
  731. } while (0);
  732. lua_pushstring(state, "lua_Light_static_createPoint - Failed to match the given parameters to a valid function signature.");
  733. lua_error(state);
  734. break;
  735. }
  736. case 4:
  737. {
  738. do
  739. {
  740. if (lua_type(state, 1) == LUA_TNUMBER &&
  741. lua_type(state, 2) == LUA_TNUMBER &&
  742. lua_type(state, 3) == LUA_TNUMBER &&
  743. lua_type(state, 4) == LUA_TNUMBER)
  744. {
  745. // Get parameter 1 off the stack.
  746. float param1 = (float)luaL_checknumber(state, 1);
  747. // Get parameter 2 off the stack.
  748. float param2 = (float)luaL_checknumber(state, 2);
  749. // Get parameter 3 off the stack.
  750. float param3 = (float)luaL_checknumber(state, 3);
  751. // Get parameter 4 off the stack.
  752. float param4 = (float)luaL_checknumber(state, 4);
  753. void* returnPtr = (void*)Light::createPoint(param1, param2, param3, param4);
  754. if (returnPtr)
  755. {
  756. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  757. object->instance = returnPtr;
  758. object->owns = true;
  759. luaL_getmetatable(state, "Light");
  760. lua_setmetatable(state, -2);
  761. }
  762. else
  763. {
  764. lua_pushnil(state);
  765. }
  766. return 1;
  767. }
  768. } while (0);
  769. lua_pushstring(state, "lua_Light_static_createPoint - Failed to match the given parameters to a valid function signature.");
  770. lua_error(state);
  771. break;
  772. }
  773. default:
  774. {
  775. lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
  776. lua_error(state);
  777. break;
  778. }
  779. }
  780. return 0;
  781. }
  782. int lua_Light_static_createSpot(lua_State* state)
  783. {
  784. // Get the number of parameters.
  785. int paramCount = lua_gettop(state);
  786. // Attempt to match the parameters to a valid binding.
  787. switch (paramCount)
  788. {
  789. case 4:
  790. {
  791. do
  792. {
  793. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  794. lua_type(state, 2) == LUA_TNUMBER &&
  795. lua_type(state, 3) == LUA_TNUMBER &&
  796. lua_type(state, 4) == LUA_TNUMBER)
  797. {
  798. // Get parameter 1 off the stack.
  799. bool param1Valid;
  800. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  801. if (!param1Valid)
  802. break;
  803. // Get parameter 2 off the stack.
  804. float param2 = (float)luaL_checknumber(state, 2);
  805. // Get parameter 3 off the stack.
  806. float param3 = (float)luaL_checknumber(state, 3);
  807. // Get parameter 4 off the stack.
  808. float param4 = (float)luaL_checknumber(state, 4);
  809. void* returnPtr = (void*)Light::createSpot(*param1, param2, param3, param4);
  810. if (returnPtr)
  811. {
  812. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  813. object->instance = returnPtr;
  814. object->owns = true;
  815. luaL_getmetatable(state, "Light");
  816. lua_setmetatable(state, -2);
  817. }
  818. else
  819. {
  820. lua_pushnil(state);
  821. }
  822. return 1;
  823. }
  824. } while (0);
  825. lua_pushstring(state, "lua_Light_static_createSpot - Failed to match the given parameters to a valid function signature.");
  826. lua_error(state);
  827. break;
  828. }
  829. case 6:
  830. {
  831. do
  832. {
  833. if (lua_type(state, 1) == LUA_TNUMBER &&
  834. lua_type(state, 2) == LUA_TNUMBER &&
  835. lua_type(state, 3) == LUA_TNUMBER &&
  836. lua_type(state, 4) == LUA_TNUMBER &&
  837. lua_type(state, 5) == LUA_TNUMBER &&
  838. lua_type(state, 6) == LUA_TNUMBER)
  839. {
  840. // Get parameter 1 off the stack.
  841. float param1 = (float)luaL_checknumber(state, 1);
  842. // Get parameter 2 off the stack.
  843. float param2 = (float)luaL_checknumber(state, 2);
  844. // Get parameter 3 off the stack.
  845. float param3 = (float)luaL_checknumber(state, 3);
  846. // Get parameter 4 off the stack.
  847. float param4 = (float)luaL_checknumber(state, 4);
  848. // Get parameter 5 off the stack.
  849. float param5 = (float)luaL_checknumber(state, 5);
  850. // Get parameter 6 off the stack.
  851. float param6 = (float)luaL_checknumber(state, 6);
  852. void* returnPtr = (void*)Light::createSpot(param1, param2, param3, param4, param5, param6);
  853. if (returnPtr)
  854. {
  855. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  856. object->instance = returnPtr;
  857. object->owns = true;
  858. luaL_getmetatable(state, "Light");
  859. lua_setmetatable(state, -2);
  860. }
  861. else
  862. {
  863. lua_pushnil(state);
  864. }
  865. return 1;
  866. }
  867. } while (0);
  868. lua_pushstring(state, "lua_Light_static_createSpot - Failed to match the given parameters to a valid function signature.");
  869. lua_error(state);
  870. break;
  871. }
  872. default:
  873. {
  874. lua_pushstring(state, "Invalid number of parameters (expected 4 or 6).");
  875. lua_error(state);
  876. break;
  877. }
  878. }
  879. return 0;
  880. }
  881. }