lua_Material.cpp 32 KB

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