lua_Effect.cpp 44 KB

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