lua_MaterialParameter.cpp 45 KB

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