lua_MeshBatch.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_MeshBatch.h"
  4. #include "Base.h"
  5. #include "Material.h"
  6. #include "MeshBatch.h"
  7. #include "lua_MeshPrimitiveType.h"
  8. namespace gameplay
  9. {
  10. void luaRegister_MeshBatch()
  11. {
  12. const luaL_Reg lua_members[] =
  13. {
  14. {"add", lua_MeshBatch_add},
  15. {"draw", lua_MeshBatch_draw},
  16. {"finish", lua_MeshBatch_finish},
  17. {"getCapacity", lua_MeshBatch_getCapacity},
  18. {"getMaterial", lua_MeshBatch_getMaterial},
  19. {"setCapacity", lua_MeshBatch_setCapacity},
  20. {"start", lua_MeshBatch_start},
  21. {NULL, NULL}
  22. };
  23. const luaL_Reg lua_statics[] =
  24. {
  25. {"create", lua_MeshBatch_static_create},
  26. {NULL, NULL}
  27. };
  28. std::vector<std::string> scopePath;
  29. ScriptUtil::registerClass("MeshBatch", lua_members, NULL, lua_MeshBatch__gc, lua_statics, scopePath);
  30. }
  31. static MeshBatch* getInstance(lua_State* state)
  32. {
  33. void* userdata = luaL_checkudata(state, 1, "MeshBatch");
  34. luaL_argcheck(state, userdata != NULL, 1, "'MeshBatch' expected.");
  35. return (MeshBatch*)((ScriptUtil::LuaObject*)userdata)->instance;
  36. }
  37. int lua_MeshBatch__gc(lua_State* state)
  38. {
  39. // Get the number of parameters.
  40. int paramCount = lua_gettop(state);
  41. // Attempt to match the parameters to a valid binding.
  42. switch (paramCount)
  43. {
  44. case 1:
  45. {
  46. if ((lua_type(state, 1) == LUA_TUSERDATA))
  47. {
  48. void* userdata = luaL_checkudata(state, 1, "MeshBatch");
  49. luaL_argcheck(state, userdata != NULL, 1, "'MeshBatch' expected.");
  50. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  51. if (object->owns)
  52. {
  53. MeshBatch* instance = (MeshBatch*)object->instance;
  54. SAFE_DELETE(instance);
  55. }
  56. return 0;
  57. }
  58. lua_pushstring(state, "lua_MeshBatch__gc - Failed to match the given parameters to a valid function signature.");
  59. lua_error(state);
  60. break;
  61. }
  62. default:
  63. {
  64. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  65. lua_error(state);
  66. break;
  67. }
  68. }
  69. return 0;
  70. }
  71. int lua_MeshBatch_add(lua_State* state)
  72. {
  73. // Get the number of parameters.
  74. int paramCount = lua_gettop(state);
  75. // Attempt to match the parameters to a valid binding.
  76. switch (paramCount)
  77. {
  78. case 3:
  79. {
  80. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  81. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  82. lua_type(state, 3) == LUA_TNUMBER)
  83. {
  84. // Get parameter 1 off the stack.
  85. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  86. // Get parameter 2 off the stack.
  87. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  88. MeshBatch* instance = getInstance(state);
  89. instance->add(param1, param2);
  90. return 0;
  91. }
  92. lua_pushstring(state, "lua_MeshBatch_add - Failed to match the given parameters to a valid function signature.");
  93. lua_error(state);
  94. break;
  95. }
  96. case 4:
  97. {
  98. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  99. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  100. lua_type(state, 3) == LUA_TNUMBER &&
  101. (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA))
  102. {
  103. // Get parameter 1 off the stack.
  104. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  105. // Get parameter 2 off the stack.
  106. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  107. // Get parameter 3 off the stack.
  108. ScriptUtil::LuaArray<unsigned short> param3 = ScriptUtil::getUnsignedShortPointer(4);
  109. MeshBatch* instance = getInstance(state);
  110. instance->add(param1, param2, param3);
  111. return 0;
  112. }
  113. lua_pushstring(state, "lua_MeshBatch_add - Failed to match the given parameters to a valid function signature.");
  114. lua_error(state);
  115. break;
  116. }
  117. case 5:
  118. {
  119. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  120. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  121. lua_type(state, 3) == LUA_TNUMBER &&
  122. (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
  123. lua_type(state, 5) == LUA_TNUMBER)
  124. {
  125. // Get parameter 1 off the stack.
  126. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  127. // Get parameter 2 off the stack.
  128. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  129. // Get parameter 3 off the stack.
  130. ScriptUtil::LuaArray<unsigned short> param3 = ScriptUtil::getUnsignedShortPointer(4);
  131. // Get parameter 4 off the stack.
  132. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
  133. MeshBatch* instance = getInstance(state);
  134. instance->add(param1, param2, param3, param4);
  135. return 0;
  136. }
  137. lua_pushstring(state, "lua_MeshBatch_add - Failed to match the given parameters to a valid function signature.");
  138. lua_error(state);
  139. break;
  140. }
  141. default:
  142. {
  143. lua_pushstring(state, "Invalid number of parameters (expected 3, 4 or 5).");
  144. lua_error(state);
  145. break;
  146. }
  147. }
  148. return 0;
  149. }
  150. int lua_MeshBatch_draw(lua_State* state)
  151. {
  152. // Get the number of parameters.
  153. int paramCount = lua_gettop(state);
  154. // Attempt to match the parameters to a valid binding.
  155. switch (paramCount)
  156. {
  157. case 1:
  158. {
  159. if ((lua_type(state, 1) == LUA_TUSERDATA))
  160. {
  161. MeshBatch* instance = getInstance(state);
  162. instance->draw();
  163. return 0;
  164. }
  165. lua_pushstring(state, "lua_MeshBatch_draw - Failed to match the given parameters to a valid function signature.");
  166. lua_error(state);
  167. break;
  168. }
  169. default:
  170. {
  171. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  172. lua_error(state);
  173. break;
  174. }
  175. }
  176. return 0;
  177. }
  178. int lua_MeshBatch_finish(lua_State* state)
  179. {
  180. // Get the number of parameters.
  181. int paramCount = lua_gettop(state);
  182. // Attempt to match the parameters to a valid binding.
  183. switch (paramCount)
  184. {
  185. case 1:
  186. {
  187. if ((lua_type(state, 1) == LUA_TUSERDATA))
  188. {
  189. MeshBatch* instance = getInstance(state);
  190. instance->finish();
  191. return 0;
  192. }
  193. lua_pushstring(state, "lua_MeshBatch_finish - Failed to match the given parameters to a valid function signature.");
  194. lua_error(state);
  195. break;
  196. }
  197. default:
  198. {
  199. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  200. lua_error(state);
  201. break;
  202. }
  203. }
  204. return 0;
  205. }
  206. int lua_MeshBatch_getCapacity(lua_State* state)
  207. {
  208. // Get the number of parameters.
  209. int paramCount = lua_gettop(state);
  210. // Attempt to match the parameters to a valid binding.
  211. switch (paramCount)
  212. {
  213. case 1:
  214. {
  215. if ((lua_type(state, 1) == LUA_TUSERDATA))
  216. {
  217. MeshBatch* instance = getInstance(state);
  218. unsigned int result = instance->getCapacity();
  219. // Push the return value onto the stack.
  220. lua_pushunsigned(state, result);
  221. return 1;
  222. }
  223. lua_pushstring(state, "lua_MeshBatch_getCapacity - Failed to match the given parameters to a valid function signature.");
  224. lua_error(state);
  225. break;
  226. }
  227. default:
  228. {
  229. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  230. lua_error(state);
  231. break;
  232. }
  233. }
  234. return 0;
  235. }
  236. int lua_MeshBatch_getMaterial(lua_State* state)
  237. {
  238. // Get the number of parameters.
  239. int paramCount = lua_gettop(state);
  240. // Attempt to match the parameters to a valid binding.
  241. switch (paramCount)
  242. {
  243. case 1:
  244. {
  245. if ((lua_type(state, 1) == LUA_TUSERDATA))
  246. {
  247. MeshBatch* instance = getInstance(state);
  248. void* returnPtr = (void*)instance->getMaterial();
  249. if (returnPtr)
  250. {
  251. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  252. object->instance = returnPtr;
  253. object->owns = false;
  254. luaL_getmetatable(state, "Material");
  255. lua_setmetatable(state, -2);
  256. }
  257. else
  258. {
  259. lua_pushnil(state);
  260. }
  261. return 1;
  262. }
  263. lua_pushstring(state, "lua_MeshBatch_getMaterial - Failed to match the given parameters to a valid function signature.");
  264. lua_error(state);
  265. break;
  266. }
  267. default:
  268. {
  269. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  270. lua_error(state);
  271. break;
  272. }
  273. }
  274. return 0;
  275. }
  276. int lua_MeshBatch_setCapacity(lua_State* state)
  277. {
  278. // Get the number of parameters.
  279. int paramCount = lua_gettop(state);
  280. // Attempt to match the parameters to a valid binding.
  281. switch (paramCount)
  282. {
  283. case 2:
  284. {
  285. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  286. lua_type(state, 2) == LUA_TNUMBER)
  287. {
  288. // Get parameter 1 off the stack.
  289. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  290. MeshBatch* instance = getInstance(state);
  291. instance->setCapacity(param1);
  292. return 0;
  293. }
  294. lua_pushstring(state, "lua_MeshBatch_setCapacity - Failed to match the given parameters to a valid function signature.");
  295. lua_error(state);
  296. break;
  297. }
  298. default:
  299. {
  300. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  301. lua_error(state);
  302. break;
  303. }
  304. }
  305. return 0;
  306. }
  307. int lua_MeshBatch_start(lua_State* state)
  308. {
  309. // Get the number of parameters.
  310. int paramCount = lua_gettop(state);
  311. // Attempt to match the parameters to a valid binding.
  312. switch (paramCount)
  313. {
  314. case 1:
  315. {
  316. if ((lua_type(state, 1) == LUA_TUSERDATA))
  317. {
  318. MeshBatch* instance = getInstance(state);
  319. instance->start();
  320. return 0;
  321. }
  322. lua_pushstring(state, "lua_MeshBatch_start - Failed to match the given parameters to a valid function signature.");
  323. lua_error(state);
  324. break;
  325. }
  326. default:
  327. {
  328. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  329. lua_error(state);
  330. break;
  331. }
  332. }
  333. return 0;
  334. }
  335. int lua_MeshBatch_static_create(lua_State* state)
  336. {
  337. // Get the number of parameters.
  338. int paramCount = lua_gettop(state);
  339. // Attempt to match the parameters to a valid binding.
  340. switch (paramCount)
  341. {
  342. case 4:
  343. {
  344. do
  345. {
  346. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  347. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  348. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  349. lua_type(state, 4) == LUA_TBOOLEAN)
  350. {
  351. // Get parameter 1 off the stack.
  352. bool param1Valid;
  353. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  354. if (!param1Valid)
  355. break;
  356. // Get parameter 2 off the stack.
  357. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  358. // Get parameter 3 off the stack.
  359. const char* param3 = ScriptUtil::getString(3, false);
  360. // Get parameter 4 off the stack.
  361. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  362. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4);
  363. if (returnPtr)
  364. {
  365. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  366. object->instance = returnPtr;
  367. object->owns = true;
  368. luaL_getmetatable(state, "MeshBatch");
  369. lua_setmetatable(state, -2);
  370. }
  371. else
  372. {
  373. lua_pushnil(state);
  374. }
  375. return 1;
  376. }
  377. } while (0);
  378. do
  379. {
  380. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  381. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  382. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) &&
  383. lua_type(state, 4) == LUA_TBOOLEAN)
  384. {
  385. // Get parameter 1 off the stack.
  386. bool param1Valid;
  387. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  388. if (!param1Valid)
  389. break;
  390. // Get parameter 2 off the stack.
  391. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  392. // Get parameter 3 off the stack.
  393. bool param3Valid;
  394. ScriptUtil::LuaArray<Material> param3 = ScriptUtil::getObjectPointer<Material>(3, "Material", false, &param3Valid);
  395. if (!param3Valid)
  396. break;
  397. // Get parameter 4 off the stack.
  398. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  399. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4);
  400. if (returnPtr)
  401. {
  402. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  403. object->instance = returnPtr;
  404. object->owns = true;
  405. luaL_getmetatable(state, "MeshBatch");
  406. lua_setmetatable(state, -2);
  407. }
  408. else
  409. {
  410. lua_pushnil(state);
  411. }
  412. return 1;
  413. }
  414. } while (0);
  415. lua_pushstring(state, "lua_MeshBatch_static_create - Failed to match the given parameters to a valid function signature.");
  416. lua_error(state);
  417. break;
  418. }
  419. case 5:
  420. {
  421. do
  422. {
  423. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  424. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  425. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  426. lua_type(state, 4) == LUA_TBOOLEAN &&
  427. lua_type(state, 5) == LUA_TNUMBER)
  428. {
  429. // Get parameter 1 off the stack.
  430. bool param1Valid;
  431. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  432. if (!param1Valid)
  433. break;
  434. // Get parameter 2 off the stack.
  435. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  436. // Get parameter 3 off the stack.
  437. const char* param3 = ScriptUtil::getString(3, false);
  438. // Get parameter 4 off the stack.
  439. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  440. // Get parameter 5 off the stack.
  441. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 5);
  442. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4, param5);
  443. if (returnPtr)
  444. {
  445. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  446. object->instance = returnPtr;
  447. object->owns = true;
  448. luaL_getmetatable(state, "MeshBatch");
  449. lua_setmetatable(state, -2);
  450. }
  451. else
  452. {
  453. lua_pushnil(state);
  454. }
  455. return 1;
  456. }
  457. } while (0);
  458. do
  459. {
  460. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  461. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  462. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) &&
  463. lua_type(state, 4) == LUA_TBOOLEAN &&
  464. lua_type(state, 5) == LUA_TNUMBER)
  465. {
  466. // Get parameter 1 off the stack.
  467. bool param1Valid;
  468. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  469. if (!param1Valid)
  470. break;
  471. // Get parameter 2 off the stack.
  472. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  473. // Get parameter 3 off the stack.
  474. bool param3Valid;
  475. ScriptUtil::LuaArray<Material> param3 = ScriptUtil::getObjectPointer<Material>(3, "Material", false, &param3Valid);
  476. if (!param3Valid)
  477. break;
  478. // Get parameter 4 off the stack.
  479. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  480. // Get parameter 5 off the stack.
  481. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 5);
  482. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4, param5);
  483. if (returnPtr)
  484. {
  485. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  486. object->instance = returnPtr;
  487. object->owns = true;
  488. luaL_getmetatable(state, "MeshBatch");
  489. lua_setmetatable(state, -2);
  490. }
  491. else
  492. {
  493. lua_pushnil(state);
  494. }
  495. return 1;
  496. }
  497. } while (0);
  498. lua_pushstring(state, "lua_MeshBatch_static_create - Failed to match the given parameters to a valid function signature.");
  499. lua_error(state);
  500. break;
  501. }
  502. case 6:
  503. {
  504. do
  505. {
  506. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  507. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  508. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  509. lua_type(state, 4) == LUA_TBOOLEAN &&
  510. lua_type(state, 5) == LUA_TNUMBER &&
  511. lua_type(state, 6) == LUA_TNUMBER)
  512. {
  513. // Get parameter 1 off the stack.
  514. bool param1Valid;
  515. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  516. if (!param1Valid)
  517. break;
  518. // Get parameter 2 off the stack.
  519. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  520. // Get parameter 3 off the stack.
  521. const char* param3 = ScriptUtil::getString(3, false);
  522. // Get parameter 4 off the stack.
  523. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  524. // Get parameter 5 off the stack.
  525. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 5);
  526. // Get parameter 6 off the stack.
  527. unsigned int param6 = (unsigned int)luaL_checkunsigned(state, 6);
  528. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4, param5, param6);
  529. if (returnPtr)
  530. {
  531. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  532. object->instance = returnPtr;
  533. object->owns = true;
  534. luaL_getmetatable(state, "MeshBatch");
  535. lua_setmetatable(state, -2);
  536. }
  537. else
  538. {
  539. lua_pushnil(state);
  540. }
  541. return 1;
  542. }
  543. } while (0);
  544. do
  545. {
  546. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  547. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  548. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL) &&
  549. lua_type(state, 4) == LUA_TBOOLEAN &&
  550. lua_type(state, 5) == LUA_TNUMBER &&
  551. lua_type(state, 6) == LUA_TNUMBER)
  552. {
  553. // Get parameter 1 off the stack.
  554. bool param1Valid;
  555. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true, &param1Valid);
  556. if (!param1Valid)
  557. break;
  558. // Get parameter 2 off the stack.
  559. Mesh::PrimitiveType param2 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  560. // Get parameter 3 off the stack.
  561. bool param3Valid;
  562. ScriptUtil::LuaArray<Material> param3 = ScriptUtil::getObjectPointer<Material>(3, "Material", false, &param3Valid);
  563. if (!param3Valid)
  564. break;
  565. // Get parameter 4 off the stack.
  566. bool param4 = ScriptUtil::luaCheckBool(state, 4);
  567. // Get parameter 5 off the stack.
  568. unsigned int param5 = (unsigned int)luaL_checkunsigned(state, 5);
  569. // Get parameter 6 off the stack.
  570. unsigned int param6 = (unsigned int)luaL_checkunsigned(state, 6);
  571. void* returnPtr = (void*)MeshBatch::create(*param1, param2, param3, param4, param5, param6);
  572. if (returnPtr)
  573. {
  574. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  575. object->instance = returnPtr;
  576. object->owns = true;
  577. luaL_getmetatable(state, "MeshBatch");
  578. lua_setmetatable(state, -2);
  579. }
  580. else
  581. {
  582. lua_pushnil(state);
  583. }
  584. return 1;
  585. }
  586. } while (0);
  587. lua_pushstring(state, "lua_MeshBatch_static_create - Failed to match the given parameters to a valid function signature.");
  588. lua_error(state);
  589. break;
  590. }
  591. default:
  592. {
  593. lua_pushstring(state, "Invalid number of parameters (expected 4, 5 or 6).");
  594. lua_error(state);
  595. break;
  596. }
  597. }
  598. return 0;
  599. }
  600. }