lua_MaterialParameter.cpp 46 KB

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