lua_Light.cpp 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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. namespace gameplay
  10. {
  11. void luaRegister_Light()
  12. {
  13. const luaL_Reg lua_members[] =
  14. {
  15. {"addRef", lua_Light_addRef},
  16. {"getColor", lua_Light_getColor},
  17. {"getInnerAngle", lua_Light_getInnerAngle},
  18. {"getInnerAngleCos", lua_Light_getInnerAngleCos},
  19. {"getLightType", lua_Light_getLightType},
  20. {"getNode", lua_Light_getNode},
  21. {"getOuterAngle", lua_Light_getOuterAngle},
  22. {"getOuterAngleCos", lua_Light_getOuterAngleCos},
  23. {"getRange", lua_Light_getRange},
  24. {"getRangeInverse", lua_Light_getRangeInverse},
  25. {"getRefCount", lua_Light_getRefCount},
  26. {"release", lua_Light_release},
  27. {"setColor", lua_Light_setColor},
  28. {"setInnerAngle", lua_Light_setInnerAngle},
  29. {"setOuterAngle", lua_Light_setOuterAngle},
  30. {"setRange", lua_Light_setRange},
  31. {NULL, NULL}
  32. };
  33. const luaL_Reg lua_statics[] =
  34. {
  35. {"create", lua_Light_static_create},
  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_pushnumber(state, (int)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_create(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. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  624. {
  625. // Get parameter 1 off the stack.
  626. bool param1Valid;
  627. gameplay::ScriptUtil::LuaArray<Properties> param1 = gameplay::ScriptUtil::getObjectPointer<Properties>(1, "Properties", false, &param1Valid);
  628. if (!param1Valid)
  629. {
  630. lua_pushstring(state, "Failed to convert parameter 1 to type 'Properties'.");
  631. lua_error(state);
  632. }
  633. void* returnPtr = (void*)Light::create(param1);
  634. if (returnPtr)
  635. {
  636. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  637. object->instance = returnPtr;
  638. object->owns = false;
  639. luaL_getmetatable(state, "Light");
  640. lua_setmetatable(state, -2);
  641. }
  642. else
  643. {
  644. lua_pushnil(state);
  645. }
  646. return 1;
  647. }
  648. lua_pushstring(state, "lua_Light_static_create - Failed to match the given parameters to a valid function signature.");
  649. lua_error(state);
  650. break;
  651. }
  652. default:
  653. {
  654. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  655. lua_error(state);
  656. break;
  657. }
  658. }
  659. return 0;
  660. }
  661. int lua_Light_static_createDirectional(lua_State* state)
  662. {
  663. // Get the number of parameters.
  664. int paramCount = lua_gettop(state);
  665. // Attempt to match the parameters to a valid binding.
  666. switch (paramCount)
  667. {
  668. case 1:
  669. {
  670. do
  671. {
  672. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  673. {
  674. // Get parameter 1 off the stack.
  675. bool param1Valid;
  676. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  677. if (!param1Valid)
  678. break;
  679. void* returnPtr = (void*)Light::createDirectional(*param1);
  680. if (returnPtr)
  681. {
  682. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  683. object->instance = returnPtr;
  684. object->owns = true;
  685. luaL_getmetatable(state, "Light");
  686. lua_setmetatable(state, -2);
  687. }
  688. else
  689. {
  690. lua_pushnil(state);
  691. }
  692. return 1;
  693. }
  694. } while (0);
  695. lua_pushstring(state, "lua_Light_static_createDirectional - Failed to match the given parameters to a valid function signature.");
  696. lua_error(state);
  697. break;
  698. }
  699. case 3:
  700. {
  701. do
  702. {
  703. if (lua_type(state, 1) == LUA_TNUMBER &&
  704. lua_type(state, 2) == LUA_TNUMBER &&
  705. lua_type(state, 3) == LUA_TNUMBER)
  706. {
  707. // Get parameter 1 off the stack.
  708. float param1 = (float)luaL_checknumber(state, 1);
  709. // Get parameter 2 off the stack.
  710. float param2 = (float)luaL_checknumber(state, 2);
  711. // Get parameter 3 off the stack.
  712. float param3 = (float)luaL_checknumber(state, 3);
  713. void* returnPtr = (void*)Light::createDirectional(param1, param2, param3);
  714. if (returnPtr)
  715. {
  716. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  717. object->instance = returnPtr;
  718. object->owns = true;
  719. luaL_getmetatable(state, "Light");
  720. lua_setmetatable(state, -2);
  721. }
  722. else
  723. {
  724. lua_pushnil(state);
  725. }
  726. return 1;
  727. }
  728. } while (0);
  729. lua_pushstring(state, "lua_Light_static_createDirectional - Failed to match the given parameters to a valid function signature.");
  730. lua_error(state);
  731. break;
  732. }
  733. default:
  734. {
  735. lua_pushstring(state, "Invalid number of parameters (expected 1 or 3).");
  736. lua_error(state);
  737. break;
  738. }
  739. }
  740. return 0;
  741. }
  742. int lua_Light_static_createPoint(lua_State* state)
  743. {
  744. // Get the number of parameters.
  745. int paramCount = lua_gettop(state);
  746. // Attempt to match the parameters to a valid binding.
  747. switch (paramCount)
  748. {
  749. case 2:
  750. {
  751. do
  752. {
  753. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  754. lua_type(state, 2) == LUA_TNUMBER)
  755. {
  756. // Get parameter 1 off the stack.
  757. bool param1Valid;
  758. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  759. if (!param1Valid)
  760. break;
  761. // Get parameter 2 off the stack.
  762. float param2 = (float)luaL_checknumber(state, 2);
  763. void* returnPtr = (void*)Light::createPoint(*param1, param2);
  764. if (returnPtr)
  765. {
  766. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  767. object->instance = returnPtr;
  768. object->owns = true;
  769. luaL_getmetatable(state, "Light");
  770. lua_setmetatable(state, -2);
  771. }
  772. else
  773. {
  774. lua_pushnil(state);
  775. }
  776. return 1;
  777. }
  778. } while (0);
  779. lua_pushstring(state, "lua_Light_static_createPoint - Failed to match the given parameters to a valid function signature.");
  780. lua_error(state);
  781. break;
  782. }
  783. case 4:
  784. {
  785. do
  786. {
  787. if (lua_type(state, 1) == LUA_TNUMBER &&
  788. lua_type(state, 2) == LUA_TNUMBER &&
  789. lua_type(state, 3) == LUA_TNUMBER &&
  790. lua_type(state, 4) == LUA_TNUMBER)
  791. {
  792. // Get parameter 1 off the stack.
  793. float param1 = (float)luaL_checknumber(state, 1);
  794. // Get parameter 2 off the stack.
  795. float param2 = (float)luaL_checknumber(state, 2);
  796. // Get parameter 3 off the stack.
  797. float param3 = (float)luaL_checknumber(state, 3);
  798. // Get parameter 4 off the stack.
  799. float param4 = (float)luaL_checknumber(state, 4);
  800. void* returnPtr = (void*)Light::createPoint(param1, param2, param3, param4);
  801. if (returnPtr)
  802. {
  803. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  804. object->instance = returnPtr;
  805. object->owns = true;
  806. luaL_getmetatable(state, "Light");
  807. lua_setmetatable(state, -2);
  808. }
  809. else
  810. {
  811. lua_pushnil(state);
  812. }
  813. return 1;
  814. }
  815. } while (0);
  816. lua_pushstring(state, "lua_Light_static_createPoint - Failed to match the given parameters to a valid function signature.");
  817. lua_error(state);
  818. break;
  819. }
  820. default:
  821. {
  822. lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
  823. lua_error(state);
  824. break;
  825. }
  826. }
  827. return 0;
  828. }
  829. int lua_Light_static_createSpot(lua_State* state)
  830. {
  831. // Get the number of parameters.
  832. int paramCount = lua_gettop(state);
  833. // Attempt to match the parameters to a valid binding.
  834. switch (paramCount)
  835. {
  836. case 4:
  837. {
  838. do
  839. {
  840. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  841. lua_type(state, 2) == LUA_TNUMBER &&
  842. lua_type(state, 3) == LUA_TNUMBER &&
  843. lua_type(state, 4) == LUA_TNUMBER)
  844. {
  845. // Get parameter 1 off the stack.
  846. bool param1Valid;
  847. gameplay::ScriptUtil::LuaArray<Vector3> param1 = gameplay::ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true, &param1Valid);
  848. if (!param1Valid)
  849. break;
  850. // Get parameter 2 off the stack.
  851. float param2 = (float)luaL_checknumber(state, 2);
  852. // Get parameter 3 off the stack.
  853. float param3 = (float)luaL_checknumber(state, 3);
  854. // Get parameter 4 off the stack.
  855. float param4 = (float)luaL_checknumber(state, 4);
  856. void* returnPtr = (void*)Light::createSpot(*param1, param2, param3, param4);
  857. if (returnPtr)
  858. {
  859. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  860. object->instance = returnPtr;
  861. object->owns = true;
  862. luaL_getmetatable(state, "Light");
  863. lua_setmetatable(state, -2);
  864. }
  865. else
  866. {
  867. lua_pushnil(state);
  868. }
  869. return 1;
  870. }
  871. } while (0);
  872. lua_pushstring(state, "lua_Light_static_createSpot - Failed to match the given parameters to a valid function signature.");
  873. lua_error(state);
  874. break;
  875. }
  876. case 6:
  877. {
  878. do
  879. {
  880. if (lua_type(state, 1) == LUA_TNUMBER &&
  881. lua_type(state, 2) == LUA_TNUMBER &&
  882. lua_type(state, 3) == LUA_TNUMBER &&
  883. lua_type(state, 4) == LUA_TNUMBER &&
  884. lua_type(state, 5) == LUA_TNUMBER &&
  885. lua_type(state, 6) == LUA_TNUMBER)
  886. {
  887. // Get parameter 1 off the stack.
  888. float param1 = (float)luaL_checknumber(state, 1);
  889. // Get parameter 2 off the stack.
  890. float param2 = (float)luaL_checknumber(state, 2);
  891. // Get parameter 3 off the stack.
  892. float param3 = (float)luaL_checknumber(state, 3);
  893. // Get parameter 4 off the stack.
  894. float param4 = (float)luaL_checknumber(state, 4);
  895. // Get parameter 5 off the stack.
  896. float param5 = (float)luaL_checknumber(state, 5);
  897. // Get parameter 6 off the stack.
  898. float param6 = (float)luaL_checknumber(state, 6);
  899. void* returnPtr = (void*)Light::createSpot(param1, param2, param3, param4, param5, param6);
  900. if (returnPtr)
  901. {
  902. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  903. object->instance = returnPtr;
  904. object->owns = true;
  905. luaL_getmetatable(state, "Light");
  906. lua_setmetatable(state, -2);
  907. }
  908. else
  909. {
  910. lua_pushnil(state);
  911. }
  912. return 1;
  913. }
  914. } while (0);
  915. lua_pushstring(state, "lua_Light_static_createSpot - Failed to match the given parameters to a valid function signature.");
  916. lua_error(state);
  917. break;
  918. }
  919. default:
  920. {
  921. lua_pushstring(state, "Invalid number of parameters (expected 4 or 6).");
  922. lua_error(state);
  923. break;
  924. }
  925. }
  926. return 0;
  927. }
  928. }