lua_Mesh.cpp 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_Mesh.h"
  4. #include "Base.h"
  5. #include "Effect.h"
  6. #include "Game.h"
  7. #include "Material.h"
  8. #include "Mesh.h"
  9. #include "MeshPart.h"
  10. #include "Model.h"
  11. #include "Ref.h"
  12. #include "lua_MeshIndexFormat.h"
  13. #include "lua_MeshPrimitiveType.h"
  14. namespace gameplay
  15. {
  16. void luaRegister_Mesh()
  17. {
  18. const luaL_Reg lua_members[] =
  19. {
  20. {"addPart", lua_Mesh_addPart},
  21. {"addRef", lua_Mesh_addRef},
  22. {"getBoundingBox", lua_Mesh_getBoundingBox},
  23. {"getBoundingSphere", lua_Mesh_getBoundingSphere},
  24. {"getPart", lua_Mesh_getPart},
  25. {"getPartCount", lua_Mesh_getPartCount},
  26. {"getPrimitiveType", lua_Mesh_getPrimitiveType},
  27. {"getRefCount", lua_Mesh_getRefCount},
  28. {"getUrl", lua_Mesh_getUrl},
  29. {"getVertexBuffer", lua_Mesh_getVertexBuffer},
  30. {"getVertexCount", lua_Mesh_getVertexCount},
  31. {"getVertexFormat", lua_Mesh_getVertexFormat},
  32. {"getVertexSize", lua_Mesh_getVertexSize},
  33. {"isDynamic", lua_Mesh_isDynamic},
  34. {"release", lua_Mesh_release},
  35. {"setBoundingBox", lua_Mesh_setBoundingBox},
  36. {"setBoundingSphere", lua_Mesh_setBoundingSphere},
  37. {"setPrimitiveType", lua_Mesh_setPrimitiveType},
  38. {"setVertexData", lua_Mesh_setVertexData},
  39. {NULL, NULL}
  40. };
  41. const luaL_Reg lua_statics[] =
  42. {
  43. {"createBoundingBox", lua_Mesh_static_createBoundingBox},
  44. {"createLines", lua_Mesh_static_createLines},
  45. {"createMesh", lua_Mesh_static_createMesh},
  46. {"createQuad", lua_Mesh_static_createQuad},
  47. {"createQuadFullscreen", lua_Mesh_static_createQuadFullscreen},
  48. {NULL, NULL}
  49. };
  50. std::vector<std::string> scopePath;
  51. ScriptUtil::registerClass("Mesh", lua_members, NULL, lua_Mesh__gc, lua_statics, scopePath);
  52. }
  53. static Mesh* getInstance(lua_State* state)
  54. {
  55. void* userdata = luaL_checkudata(state, 1, "Mesh");
  56. luaL_argcheck(state, userdata != NULL, 1, "'Mesh' expected.");
  57. return (Mesh*)((ScriptUtil::LuaObject*)userdata)->instance;
  58. }
  59. int lua_Mesh__gc(lua_State* state)
  60. {
  61. // Get the number of parameters.
  62. int paramCount = lua_gettop(state);
  63. // Attempt to match the parameters to a valid binding.
  64. switch (paramCount)
  65. {
  66. case 1:
  67. {
  68. if ((lua_type(state, 1) == LUA_TUSERDATA))
  69. {
  70. void* userdata = luaL_checkudata(state, 1, "Mesh");
  71. luaL_argcheck(state, userdata != NULL, 1, "'Mesh' expected.");
  72. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  73. if (object->owns)
  74. {
  75. Mesh* instance = (Mesh*)object->instance;
  76. SAFE_RELEASE(instance);
  77. }
  78. return 0;
  79. }
  80. else
  81. {
  82. lua_pushstring(state, "lua_Mesh__gc - Failed to match the given parameters to a valid function signature.");
  83. lua_error(state);
  84. }
  85. break;
  86. }
  87. default:
  88. {
  89. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  90. lua_error(state);
  91. break;
  92. }
  93. }
  94. return 0;
  95. }
  96. int lua_Mesh_addPart(lua_State* state)
  97. {
  98. // Get the number of parameters.
  99. int paramCount = lua_gettop(state);
  100. // Attempt to match the parameters to a valid binding.
  101. switch (paramCount)
  102. {
  103. case 4:
  104. {
  105. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  106. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  107. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  108. lua_type(state, 4) == LUA_TNUMBER)
  109. {
  110. // Get parameter 1 off the stack.
  111. Mesh::PrimitiveType param1 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  112. // Get parameter 2 off the stack.
  113. Mesh::IndexFormat param2 = (Mesh::IndexFormat)lua_enumFromString_MeshIndexFormat(luaL_checkstring(state, 3));
  114. // Get parameter 3 off the stack.
  115. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  116. Mesh* instance = getInstance(state);
  117. void* returnPtr = (void*)instance->addPart(param1, param2, param3);
  118. if (returnPtr)
  119. {
  120. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  121. object->instance = returnPtr;
  122. object->owns = false;
  123. luaL_getmetatable(state, "MeshPart");
  124. lua_setmetatable(state, -2);
  125. }
  126. else
  127. {
  128. lua_pushnil(state);
  129. }
  130. return 1;
  131. }
  132. else
  133. {
  134. lua_pushstring(state, "lua_Mesh_addPart - Failed to match the given parameters to a valid function signature.");
  135. lua_error(state);
  136. }
  137. break;
  138. }
  139. case 5:
  140. {
  141. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  142. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  143. (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL) &&
  144. lua_type(state, 4) == LUA_TNUMBER &&
  145. lua_type(state, 5) == LUA_TBOOLEAN)
  146. {
  147. // Get parameter 1 off the stack.
  148. Mesh::PrimitiveType param1 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  149. // Get parameter 2 off the stack.
  150. Mesh::IndexFormat param2 = (Mesh::IndexFormat)lua_enumFromString_MeshIndexFormat(luaL_checkstring(state, 3));
  151. // Get parameter 3 off the stack.
  152. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  153. // Get parameter 4 off the stack.
  154. bool param4 = ScriptUtil::luaCheckBool(state, 5);
  155. Mesh* instance = getInstance(state);
  156. void* returnPtr = (void*)instance->addPart(param1, param2, param3, param4);
  157. if (returnPtr)
  158. {
  159. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  160. object->instance = returnPtr;
  161. object->owns = false;
  162. luaL_getmetatable(state, "MeshPart");
  163. lua_setmetatable(state, -2);
  164. }
  165. else
  166. {
  167. lua_pushnil(state);
  168. }
  169. return 1;
  170. }
  171. else
  172. {
  173. lua_pushstring(state, "lua_Mesh_addPart - Failed to match the given parameters to a valid function signature.");
  174. lua_error(state);
  175. }
  176. break;
  177. }
  178. default:
  179. {
  180. lua_pushstring(state, "Invalid number of parameters (expected 4 or 5).");
  181. lua_error(state);
  182. break;
  183. }
  184. }
  185. return 0;
  186. }
  187. int lua_Mesh_addRef(lua_State* state)
  188. {
  189. // Get the number of parameters.
  190. int paramCount = lua_gettop(state);
  191. // Attempt to match the parameters to a valid binding.
  192. switch (paramCount)
  193. {
  194. case 1:
  195. {
  196. if ((lua_type(state, 1) == LUA_TUSERDATA))
  197. {
  198. Mesh* instance = getInstance(state);
  199. instance->addRef();
  200. return 0;
  201. }
  202. else
  203. {
  204. lua_pushstring(state, "lua_Mesh_addRef - Failed to match the given parameters to a valid function signature.");
  205. lua_error(state);
  206. }
  207. break;
  208. }
  209. default:
  210. {
  211. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  212. lua_error(state);
  213. break;
  214. }
  215. }
  216. return 0;
  217. }
  218. int lua_Mesh_getBoundingBox(lua_State* state)
  219. {
  220. // Get the number of parameters.
  221. int paramCount = lua_gettop(state);
  222. // Attempt to match the parameters to a valid binding.
  223. switch (paramCount)
  224. {
  225. case 1:
  226. {
  227. if ((lua_type(state, 1) == LUA_TUSERDATA))
  228. {
  229. Mesh* instance = getInstance(state);
  230. void* returnPtr = (void*)&(instance->getBoundingBox());
  231. if (returnPtr)
  232. {
  233. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  234. object->instance = returnPtr;
  235. object->owns = false;
  236. luaL_getmetatable(state, "BoundingBox");
  237. lua_setmetatable(state, -2);
  238. }
  239. else
  240. {
  241. lua_pushnil(state);
  242. }
  243. return 1;
  244. }
  245. else
  246. {
  247. lua_pushstring(state, "lua_Mesh_getBoundingBox - Failed to match the given parameters to a valid function signature.");
  248. lua_error(state);
  249. }
  250. break;
  251. }
  252. default:
  253. {
  254. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  255. lua_error(state);
  256. break;
  257. }
  258. }
  259. return 0;
  260. }
  261. int lua_Mesh_getBoundingSphere(lua_State* state)
  262. {
  263. // Get the number of parameters.
  264. int paramCount = lua_gettop(state);
  265. // Attempt to match the parameters to a valid binding.
  266. switch (paramCount)
  267. {
  268. case 1:
  269. {
  270. if ((lua_type(state, 1) == LUA_TUSERDATA))
  271. {
  272. Mesh* instance = getInstance(state);
  273. void* returnPtr = (void*)&(instance->getBoundingSphere());
  274. if (returnPtr)
  275. {
  276. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  277. object->instance = returnPtr;
  278. object->owns = false;
  279. luaL_getmetatable(state, "BoundingSphere");
  280. lua_setmetatable(state, -2);
  281. }
  282. else
  283. {
  284. lua_pushnil(state);
  285. }
  286. return 1;
  287. }
  288. else
  289. {
  290. lua_pushstring(state, "lua_Mesh_getBoundingSphere - Failed to match the given parameters to a valid function signature.");
  291. lua_error(state);
  292. }
  293. break;
  294. }
  295. default:
  296. {
  297. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  298. lua_error(state);
  299. break;
  300. }
  301. }
  302. return 0;
  303. }
  304. int lua_Mesh_getPart(lua_State* state)
  305. {
  306. // Get the number of parameters.
  307. int paramCount = lua_gettop(state);
  308. // Attempt to match the parameters to a valid binding.
  309. switch (paramCount)
  310. {
  311. case 2:
  312. {
  313. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  314. lua_type(state, 2) == LUA_TNUMBER)
  315. {
  316. // Get parameter 1 off the stack.
  317. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  318. Mesh* instance = getInstance(state);
  319. void* returnPtr = (void*)instance->getPart(param1);
  320. if (returnPtr)
  321. {
  322. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  323. object->instance = returnPtr;
  324. object->owns = false;
  325. luaL_getmetatable(state, "MeshPart");
  326. lua_setmetatable(state, -2);
  327. }
  328. else
  329. {
  330. lua_pushnil(state);
  331. }
  332. return 1;
  333. }
  334. else
  335. {
  336. lua_pushstring(state, "lua_Mesh_getPart - Failed to match the given parameters to a valid function signature.");
  337. lua_error(state);
  338. }
  339. break;
  340. }
  341. default:
  342. {
  343. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  344. lua_error(state);
  345. break;
  346. }
  347. }
  348. return 0;
  349. }
  350. int lua_Mesh_getPartCount(lua_State* state)
  351. {
  352. // Get the number of parameters.
  353. int paramCount = lua_gettop(state);
  354. // Attempt to match the parameters to a valid binding.
  355. switch (paramCount)
  356. {
  357. case 1:
  358. {
  359. if ((lua_type(state, 1) == LUA_TUSERDATA))
  360. {
  361. Mesh* instance = getInstance(state);
  362. unsigned int result = instance->getPartCount();
  363. // Push the return value onto the stack.
  364. lua_pushunsigned(state, result);
  365. return 1;
  366. }
  367. else
  368. {
  369. lua_pushstring(state, "lua_Mesh_getPartCount - 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 1).");
  377. lua_error(state);
  378. break;
  379. }
  380. }
  381. return 0;
  382. }
  383. int lua_Mesh_getPrimitiveType(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 1:
  391. {
  392. if ((lua_type(state, 1) == LUA_TUSERDATA))
  393. {
  394. Mesh* instance = getInstance(state);
  395. Mesh::PrimitiveType result = instance->getPrimitiveType();
  396. // Push the return value onto the stack.
  397. lua_pushstring(state, lua_stringFromEnum_MeshPrimitiveType(result));
  398. return 1;
  399. }
  400. else
  401. {
  402. lua_pushstring(state, "lua_Mesh_getPrimitiveType - Failed to match the given parameters to a valid function signature.");
  403. lua_error(state);
  404. }
  405. break;
  406. }
  407. default:
  408. {
  409. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  410. lua_error(state);
  411. break;
  412. }
  413. }
  414. return 0;
  415. }
  416. int lua_Mesh_getRefCount(lua_State* state)
  417. {
  418. // Get the number of parameters.
  419. int paramCount = lua_gettop(state);
  420. // Attempt to match the parameters to a valid binding.
  421. switch (paramCount)
  422. {
  423. case 1:
  424. {
  425. if ((lua_type(state, 1) == LUA_TUSERDATA))
  426. {
  427. Mesh* instance = getInstance(state);
  428. unsigned int result = instance->getRefCount();
  429. // Push the return value onto the stack.
  430. lua_pushunsigned(state, result);
  431. return 1;
  432. }
  433. else
  434. {
  435. lua_pushstring(state, "lua_Mesh_getRefCount - Failed to match the given parameters to a valid function signature.");
  436. lua_error(state);
  437. }
  438. break;
  439. }
  440. default:
  441. {
  442. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  443. lua_error(state);
  444. break;
  445. }
  446. }
  447. return 0;
  448. }
  449. int lua_Mesh_getUrl(lua_State* state)
  450. {
  451. // Get the number of parameters.
  452. int paramCount = lua_gettop(state);
  453. // Attempt to match the parameters to a valid binding.
  454. switch (paramCount)
  455. {
  456. case 1:
  457. {
  458. if ((lua_type(state, 1) == LUA_TUSERDATA))
  459. {
  460. Mesh* instance = getInstance(state);
  461. const char* result = instance->getUrl();
  462. // Push the return value onto the stack.
  463. lua_pushstring(state, result);
  464. return 1;
  465. }
  466. else
  467. {
  468. lua_pushstring(state, "lua_Mesh_getUrl - Failed to match the given parameters to a valid function signature.");
  469. lua_error(state);
  470. }
  471. break;
  472. }
  473. default:
  474. {
  475. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  476. lua_error(state);
  477. break;
  478. }
  479. }
  480. return 0;
  481. }
  482. int lua_Mesh_getVertexBuffer(lua_State* state)
  483. {
  484. // Get the number of parameters.
  485. int paramCount = lua_gettop(state);
  486. // Attempt to match the parameters to a valid binding.
  487. switch (paramCount)
  488. {
  489. case 1:
  490. {
  491. if ((lua_type(state, 1) == LUA_TUSERDATA))
  492. {
  493. Mesh* instance = getInstance(state);
  494. void* returnPtr = (void*)new GLuint(instance->getVertexBuffer());
  495. if (returnPtr)
  496. {
  497. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  498. object->instance = returnPtr;
  499. object->owns = true;
  500. luaL_getmetatable(state, "GLuint");
  501. lua_setmetatable(state, -2);
  502. }
  503. else
  504. {
  505. lua_pushnil(state);
  506. }
  507. return 1;
  508. }
  509. else
  510. {
  511. lua_pushstring(state, "lua_Mesh_getVertexBuffer - Failed to match the given parameters to a valid function signature.");
  512. lua_error(state);
  513. }
  514. break;
  515. }
  516. default:
  517. {
  518. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  519. lua_error(state);
  520. break;
  521. }
  522. }
  523. return 0;
  524. }
  525. int lua_Mesh_getVertexCount(lua_State* state)
  526. {
  527. // Get the number of parameters.
  528. int paramCount = lua_gettop(state);
  529. // Attempt to match the parameters to a valid binding.
  530. switch (paramCount)
  531. {
  532. case 1:
  533. {
  534. if ((lua_type(state, 1) == LUA_TUSERDATA))
  535. {
  536. Mesh* instance = getInstance(state);
  537. unsigned int result = instance->getVertexCount();
  538. // Push the return value onto the stack.
  539. lua_pushunsigned(state, result);
  540. return 1;
  541. }
  542. else
  543. {
  544. lua_pushstring(state, "lua_Mesh_getVertexCount - Failed to match the given parameters to a valid function signature.");
  545. lua_error(state);
  546. }
  547. break;
  548. }
  549. default:
  550. {
  551. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  552. lua_error(state);
  553. break;
  554. }
  555. }
  556. return 0;
  557. }
  558. int lua_Mesh_getVertexFormat(lua_State* state)
  559. {
  560. // Get the number of parameters.
  561. int paramCount = lua_gettop(state);
  562. // Attempt to match the parameters to a valid binding.
  563. switch (paramCount)
  564. {
  565. case 1:
  566. {
  567. if ((lua_type(state, 1) == LUA_TUSERDATA))
  568. {
  569. Mesh* instance = getInstance(state);
  570. void* returnPtr = (void*)&(instance->getVertexFormat());
  571. if (returnPtr)
  572. {
  573. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  574. object->instance = returnPtr;
  575. object->owns = false;
  576. luaL_getmetatable(state, "VertexFormat");
  577. lua_setmetatable(state, -2);
  578. }
  579. else
  580. {
  581. lua_pushnil(state);
  582. }
  583. return 1;
  584. }
  585. else
  586. {
  587. lua_pushstring(state, "lua_Mesh_getVertexFormat - Failed to match the given parameters to a valid function signature.");
  588. lua_error(state);
  589. }
  590. break;
  591. }
  592. default:
  593. {
  594. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  595. lua_error(state);
  596. break;
  597. }
  598. }
  599. return 0;
  600. }
  601. int lua_Mesh_getVertexSize(lua_State* state)
  602. {
  603. // Get the number of parameters.
  604. int paramCount = lua_gettop(state);
  605. // Attempt to match the parameters to a valid binding.
  606. switch (paramCount)
  607. {
  608. case 1:
  609. {
  610. if ((lua_type(state, 1) == LUA_TUSERDATA))
  611. {
  612. Mesh* instance = getInstance(state);
  613. unsigned int result = instance->getVertexSize();
  614. // Push the return value onto the stack.
  615. lua_pushunsigned(state, result);
  616. return 1;
  617. }
  618. else
  619. {
  620. lua_pushstring(state, "lua_Mesh_getVertexSize - Failed to match the given parameters to a valid function signature.");
  621. lua_error(state);
  622. }
  623. break;
  624. }
  625. default:
  626. {
  627. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  628. lua_error(state);
  629. break;
  630. }
  631. }
  632. return 0;
  633. }
  634. int lua_Mesh_isDynamic(lua_State* state)
  635. {
  636. // Get the number of parameters.
  637. int paramCount = lua_gettop(state);
  638. // Attempt to match the parameters to a valid binding.
  639. switch (paramCount)
  640. {
  641. case 1:
  642. {
  643. if ((lua_type(state, 1) == LUA_TUSERDATA))
  644. {
  645. Mesh* instance = getInstance(state);
  646. bool result = instance->isDynamic();
  647. // Push the return value onto the stack.
  648. lua_pushboolean(state, result);
  649. return 1;
  650. }
  651. else
  652. {
  653. lua_pushstring(state, "lua_Mesh_isDynamic - Failed to match the given parameters to a valid function signature.");
  654. lua_error(state);
  655. }
  656. break;
  657. }
  658. default:
  659. {
  660. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  661. lua_error(state);
  662. break;
  663. }
  664. }
  665. return 0;
  666. }
  667. int lua_Mesh_release(lua_State* state)
  668. {
  669. // Get the number of parameters.
  670. int paramCount = lua_gettop(state);
  671. // Attempt to match the parameters to a valid binding.
  672. switch (paramCount)
  673. {
  674. case 1:
  675. {
  676. if ((lua_type(state, 1) == LUA_TUSERDATA))
  677. {
  678. Mesh* instance = getInstance(state);
  679. instance->release();
  680. return 0;
  681. }
  682. else
  683. {
  684. lua_pushstring(state, "lua_Mesh_release - Failed to match the given parameters to a valid function signature.");
  685. lua_error(state);
  686. }
  687. break;
  688. }
  689. default:
  690. {
  691. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  692. lua_error(state);
  693. break;
  694. }
  695. }
  696. return 0;
  697. }
  698. int lua_Mesh_setBoundingBox(lua_State* state)
  699. {
  700. // Get the number of parameters.
  701. int paramCount = lua_gettop(state);
  702. // Attempt to match the parameters to a valid binding.
  703. switch (paramCount)
  704. {
  705. case 2:
  706. {
  707. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  708. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  709. {
  710. // Get parameter 1 off the stack.
  711. ScriptUtil::LuaArray<BoundingBox> param1 = ScriptUtil::getObjectPointer<BoundingBox>(2, "BoundingBox", true);
  712. Mesh* instance = getInstance(state);
  713. instance->setBoundingBox(*param1);
  714. return 0;
  715. }
  716. else
  717. {
  718. lua_pushstring(state, "lua_Mesh_setBoundingBox - Failed to match the given parameters to a valid function signature.");
  719. lua_error(state);
  720. }
  721. break;
  722. }
  723. default:
  724. {
  725. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  726. lua_error(state);
  727. break;
  728. }
  729. }
  730. return 0;
  731. }
  732. int lua_Mesh_setBoundingSphere(lua_State* state)
  733. {
  734. // Get the number of parameters.
  735. int paramCount = lua_gettop(state);
  736. // Attempt to match the parameters to a valid binding.
  737. switch (paramCount)
  738. {
  739. case 2:
  740. {
  741. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  742. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  743. {
  744. // Get parameter 1 off the stack.
  745. ScriptUtil::LuaArray<BoundingSphere> param1 = ScriptUtil::getObjectPointer<BoundingSphere>(2, "BoundingSphere", true);
  746. Mesh* instance = getInstance(state);
  747. instance->setBoundingSphere(*param1);
  748. return 0;
  749. }
  750. else
  751. {
  752. lua_pushstring(state, "lua_Mesh_setBoundingSphere - Failed to match the given parameters to a valid function signature.");
  753. lua_error(state);
  754. }
  755. break;
  756. }
  757. default:
  758. {
  759. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  760. lua_error(state);
  761. break;
  762. }
  763. }
  764. return 0;
  765. }
  766. int lua_Mesh_setPrimitiveType(lua_State* state)
  767. {
  768. // Get the number of parameters.
  769. int paramCount = lua_gettop(state);
  770. // Attempt to match the parameters to a valid binding.
  771. switch (paramCount)
  772. {
  773. case 2:
  774. {
  775. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  776. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  777. {
  778. // Get parameter 1 off the stack.
  779. Mesh::PrimitiveType param1 = (Mesh::PrimitiveType)lua_enumFromString_MeshPrimitiveType(luaL_checkstring(state, 2));
  780. Mesh* instance = getInstance(state);
  781. instance->setPrimitiveType(param1);
  782. return 0;
  783. }
  784. else
  785. {
  786. lua_pushstring(state, "lua_Mesh_setPrimitiveType - Failed to match the given parameters to a valid function signature.");
  787. lua_error(state);
  788. }
  789. break;
  790. }
  791. default:
  792. {
  793. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  794. lua_error(state);
  795. break;
  796. }
  797. }
  798. return 0;
  799. }
  800. int lua_Mesh_setVertexData(lua_State* state)
  801. {
  802. // Get the number of parameters.
  803. int paramCount = lua_gettop(state);
  804. // Attempt to match the parameters to a valid binding.
  805. switch (paramCount)
  806. {
  807. case 2:
  808. {
  809. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  810. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA))
  811. {
  812. // Get parameter 1 off the stack.
  813. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  814. Mesh* instance = getInstance(state);
  815. instance->setVertexData(param1);
  816. return 0;
  817. }
  818. else
  819. {
  820. lua_pushstring(state, "lua_Mesh_setVertexData - Failed to match the given parameters to a valid function signature.");
  821. lua_error(state);
  822. }
  823. break;
  824. }
  825. case 3:
  826. {
  827. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  828. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  829. lua_type(state, 3) == LUA_TNUMBER)
  830. {
  831. // Get parameter 1 off the stack.
  832. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  833. // Get parameter 2 off the stack.
  834. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  835. Mesh* instance = getInstance(state);
  836. instance->setVertexData(param1, param2);
  837. return 0;
  838. }
  839. else
  840. {
  841. lua_pushstring(state, "lua_Mesh_setVertexData - Failed to match the given parameters to a valid function signature.");
  842. lua_error(state);
  843. }
  844. break;
  845. }
  846. case 4:
  847. {
  848. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  849. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
  850. lua_type(state, 3) == LUA_TNUMBER &&
  851. lua_type(state, 4) == LUA_TNUMBER)
  852. {
  853. // Get parameter 1 off the stack.
  854. ScriptUtil::LuaArray<float> param1 = ScriptUtil::getFloatPointer(2);
  855. // Get parameter 2 off the stack.
  856. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
  857. // Get parameter 3 off the stack.
  858. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 4);
  859. Mesh* instance = getInstance(state);
  860. instance->setVertexData(param1, param2, param3);
  861. return 0;
  862. }
  863. else
  864. {
  865. lua_pushstring(state, "lua_Mesh_setVertexData - Failed to match the given parameters to a valid function signature.");
  866. lua_error(state);
  867. }
  868. break;
  869. }
  870. default:
  871. {
  872. lua_pushstring(state, "Invalid number of parameters (expected 2, 3 or 4).");
  873. lua_error(state);
  874. break;
  875. }
  876. }
  877. return 0;
  878. }
  879. int lua_Mesh_static_createBoundingBox(lua_State* state)
  880. {
  881. // Get the number of parameters.
  882. int paramCount = lua_gettop(state);
  883. // Attempt to match the parameters to a valid binding.
  884. switch (paramCount)
  885. {
  886. case 1:
  887. {
  888. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  889. {
  890. // Get parameter 1 off the stack.
  891. ScriptUtil::LuaArray<BoundingBox> param1 = ScriptUtil::getObjectPointer<BoundingBox>(1, "BoundingBox", true);
  892. void* returnPtr = (void*)Mesh::createBoundingBox(*param1);
  893. if (returnPtr)
  894. {
  895. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  896. object->instance = returnPtr;
  897. object->owns = true;
  898. luaL_getmetatable(state, "Mesh");
  899. lua_setmetatable(state, -2);
  900. }
  901. else
  902. {
  903. lua_pushnil(state);
  904. }
  905. return 1;
  906. }
  907. else
  908. {
  909. lua_pushstring(state, "lua_Mesh_static_createBoundingBox - Failed to match the given parameters to a valid function signature.");
  910. lua_error(state);
  911. }
  912. break;
  913. }
  914. default:
  915. {
  916. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  917. lua_error(state);
  918. break;
  919. }
  920. }
  921. return 0;
  922. }
  923. int lua_Mesh_static_createLines(lua_State* state)
  924. {
  925. // Get the number of parameters.
  926. int paramCount = lua_gettop(state);
  927. // Attempt to match the parameters to a valid binding.
  928. switch (paramCount)
  929. {
  930. case 2:
  931. {
  932. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  933. lua_type(state, 2) == LUA_TNUMBER)
  934. {
  935. // Get parameter 1 off the stack.
  936. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", false);
  937. // Get parameter 2 off the stack.
  938. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
  939. void* returnPtr = (void*)Mesh::createLines(param1, param2);
  940. if (returnPtr)
  941. {
  942. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  943. object->instance = returnPtr;
  944. object->owns = true;
  945. luaL_getmetatable(state, "Mesh");
  946. lua_setmetatable(state, -2);
  947. }
  948. else
  949. {
  950. lua_pushnil(state);
  951. }
  952. return 1;
  953. }
  954. else
  955. {
  956. lua_pushstring(state, "lua_Mesh_static_createLines - Failed to match the given parameters to a valid function signature.");
  957. lua_error(state);
  958. }
  959. break;
  960. }
  961. default:
  962. {
  963. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  964. lua_error(state);
  965. break;
  966. }
  967. }
  968. return 0;
  969. }
  970. int lua_Mesh_static_createMesh(lua_State* state)
  971. {
  972. // Get the number of parameters.
  973. int paramCount = lua_gettop(state);
  974. // Attempt to match the parameters to a valid binding.
  975. switch (paramCount)
  976. {
  977. case 2:
  978. {
  979. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  980. lua_type(state, 2) == LUA_TNUMBER)
  981. {
  982. // Get parameter 1 off the stack.
  983. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true);
  984. // Get parameter 2 off the stack.
  985. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
  986. void* returnPtr = (void*)Mesh::createMesh(*param1, param2);
  987. if (returnPtr)
  988. {
  989. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  990. object->instance = returnPtr;
  991. object->owns = true;
  992. luaL_getmetatable(state, "Mesh");
  993. lua_setmetatable(state, -2);
  994. }
  995. else
  996. {
  997. lua_pushnil(state);
  998. }
  999. return 1;
  1000. }
  1001. else
  1002. {
  1003. lua_pushstring(state, "lua_Mesh_static_createMesh - Failed to match the given parameters to a valid function signature.");
  1004. lua_error(state);
  1005. }
  1006. break;
  1007. }
  1008. case 3:
  1009. {
  1010. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1011. lua_type(state, 2) == LUA_TNUMBER &&
  1012. lua_type(state, 3) == LUA_TBOOLEAN)
  1013. {
  1014. // Get parameter 1 off the stack.
  1015. ScriptUtil::LuaArray<VertexFormat> param1 = ScriptUtil::getObjectPointer<VertexFormat>(1, "VertexFormat", true);
  1016. // Get parameter 2 off the stack.
  1017. unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 2);
  1018. // Get parameter 3 off the stack.
  1019. bool param3 = ScriptUtil::luaCheckBool(state, 3);
  1020. void* returnPtr = (void*)Mesh::createMesh(*param1, param2, param3);
  1021. if (returnPtr)
  1022. {
  1023. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1024. object->instance = returnPtr;
  1025. object->owns = true;
  1026. luaL_getmetatable(state, "Mesh");
  1027. lua_setmetatable(state, -2);
  1028. }
  1029. else
  1030. {
  1031. lua_pushnil(state);
  1032. }
  1033. return 1;
  1034. }
  1035. else
  1036. {
  1037. lua_pushstring(state, "lua_Mesh_static_createMesh - Failed to match the given parameters to a valid function signature.");
  1038. lua_error(state);
  1039. }
  1040. break;
  1041. }
  1042. default:
  1043. {
  1044. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  1045. lua_error(state);
  1046. break;
  1047. }
  1048. }
  1049. return 0;
  1050. }
  1051. int lua_Mesh_static_createQuad(lua_State* state)
  1052. {
  1053. // Get the number of parameters.
  1054. int paramCount = lua_gettop(state);
  1055. // Attempt to match the parameters to a valid binding.
  1056. switch (paramCount)
  1057. {
  1058. case 4:
  1059. {
  1060. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1061. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  1062. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  1063. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TNIL))
  1064. {
  1065. // Get parameter 1 off the stack.
  1066. ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(1, "Vector3", true);
  1067. // Get parameter 2 off the stack.
  1068. ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1069. // Get parameter 3 off the stack.
  1070. ScriptUtil::LuaArray<Vector3> param3 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", true);
  1071. // Get parameter 4 off the stack.
  1072. ScriptUtil::LuaArray<Vector3> param4 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", true);
  1073. void* returnPtr = (void*)Mesh::createQuad(*param1, *param2, *param3, *param4);
  1074. if (returnPtr)
  1075. {
  1076. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1077. object->instance = returnPtr;
  1078. object->owns = true;
  1079. luaL_getmetatable(state, "Mesh");
  1080. lua_setmetatable(state, -2);
  1081. }
  1082. else
  1083. {
  1084. lua_pushnil(state);
  1085. }
  1086. return 1;
  1087. }
  1088. else if (lua_type(state, 1) == LUA_TNUMBER &&
  1089. lua_type(state, 2) == LUA_TNUMBER &&
  1090. lua_type(state, 3) == LUA_TNUMBER &&
  1091. lua_type(state, 4) == LUA_TNUMBER)
  1092. {
  1093. // Get parameter 1 off the stack.
  1094. float param1 = (float)luaL_checknumber(state, 1);
  1095. // Get parameter 2 off the stack.
  1096. float param2 = (float)luaL_checknumber(state, 2);
  1097. // Get parameter 3 off the stack.
  1098. float param3 = (float)luaL_checknumber(state, 3);
  1099. // Get parameter 4 off the stack.
  1100. float param4 = (float)luaL_checknumber(state, 4);
  1101. void* returnPtr = (void*)Mesh::createQuad(param1, param2, param3, param4);
  1102. if (returnPtr)
  1103. {
  1104. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1105. object->instance = returnPtr;
  1106. object->owns = true;
  1107. luaL_getmetatable(state, "Mesh");
  1108. lua_setmetatable(state, -2);
  1109. }
  1110. else
  1111. {
  1112. lua_pushnil(state);
  1113. }
  1114. return 1;
  1115. }
  1116. else
  1117. {
  1118. lua_pushstring(state, "lua_Mesh_static_createQuad - Failed to match the given parameters to a valid function signature.");
  1119. lua_error(state);
  1120. }
  1121. break;
  1122. }
  1123. case 5:
  1124. {
  1125. if (lua_type(state, 1) == LUA_TNUMBER &&
  1126. lua_type(state, 2) == LUA_TNUMBER &&
  1127. lua_type(state, 3) == LUA_TNUMBER &&
  1128. lua_type(state, 4) == LUA_TNUMBER &&
  1129. lua_type(state, 5) == LUA_TNUMBER)
  1130. {
  1131. // Get parameter 1 off the stack.
  1132. float param1 = (float)luaL_checknumber(state, 1);
  1133. // Get parameter 2 off the stack.
  1134. float param2 = (float)luaL_checknumber(state, 2);
  1135. // Get parameter 3 off the stack.
  1136. float param3 = (float)luaL_checknumber(state, 3);
  1137. // Get parameter 4 off the stack.
  1138. float param4 = (float)luaL_checknumber(state, 4);
  1139. // Get parameter 5 off the stack.
  1140. float param5 = (float)luaL_checknumber(state, 5);
  1141. void* returnPtr = (void*)Mesh::createQuad(param1, param2, param3, param4, param5);
  1142. if (returnPtr)
  1143. {
  1144. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1145. object->instance = returnPtr;
  1146. object->owns = true;
  1147. luaL_getmetatable(state, "Mesh");
  1148. lua_setmetatable(state, -2);
  1149. }
  1150. else
  1151. {
  1152. lua_pushnil(state);
  1153. }
  1154. return 1;
  1155. }
  1156. else
  1157. {
  1158. lua_pushstring(state, "lua_Mesh_static_createQuad - Failed to match the given parameters to a valid function signature.");
  1159. lua_error(state);
  1160. }
  1161. break;
  1162. }
  1163. case 6:
  1164. {
  1165. if (lua_type(state, 1) == LUA_TNUMBER &&
  1166. lua_type(state, 2) == LUA_TNUMBER &&
  1167. lua_type(state, 3) == LUA_TNUMBER &&
  1168. lua_type(state, 4) == LUA_TNUMBER &&
  1169. lua_type(state, 5) == LUA_TNUMBER &&
  1170. lua_type(state, 6) == LUA_TNUMBER)
  1171. {
  1172. // Get parameter 1 off the stack.
  1173. float param1 = (float)luaL_checknumber(state, 1);
  1174. // Get parameter 2 off the stack.
  1175. float param2 = (float)luaL_checknumber(state, 2);
  1176. // Get parameter 3 off the stack.
  1177. float param3 = (float)luaL_checknumber(state, 3);
  1178. // Get parameter 4 off the stack.
  1179. float param4 = (float)luaL_checknumber(state, 4);
  1180. // Get parameter 5 off the stack.
  1181. float param5 = (float)luaL_checknumber(state, 5);
  1182. // Get parameter 6 off the stack.
  1183. float param6 = (float)luaL_checknumber(state, 6);
  1184. void* returnPtr = (void*)Mesh::createQuad(param1, param2, param3, param4, param5, param6);
  1185. if (returnPtr)
  1186. {
  1187. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1188. object->instance = returnPtr;
  1189. object->owns = true;
  1190. luaL_getmetatable(state, "Mesh");
  1191. lua_setmetatable(state, -2);
  1192. }
  1193. else
  1194. {
  1195. lua_pushnil(state);
  1196. }
  1197. return 1;
  1198. }
  1199. else
  1200. {
  1201. lua_pushstring(state, "lua_Mesh_static_createQuad - Failed to match the given parameters to a valid function signature.");
  1202. lua_error(state);
  1203. }
  1204. break;
  1205. }
  1206. case 7:
  1207. {
  1208. if (lua_type(state, 1) == LUA_TNUMBER &&
  1209. lua_type(state, 2) == LUA_TNUMBER &&
  1210. lua_type(state, 3) == LUA_TNUMBER &&
  1211. lua_type(state, 4) == LUA_TNUMBER &&
  1212. lua_type(state, 5) == LUA_TNUMBER &&
  1213. lua_type(state, 6) == LUA_TNUMBER &&
  1214. lua_type(state, 7) == LUA_TNUMBER)
  1215. {
  1216. // Get parameter 1 off the stack.
  1217. float param1 = (float)luaL_checknumber(state, 1);
  1218. // Get parameter 2 off the stack.
  1219. float param2 = (float)luaL_checknumber(state, 2);
  1220. // Get parameter 3 off the stack.
  1221. float param3 = (float)luaL_checknumber(state, 3);
  1222. // Get parameter 4 off the stack.
  1223. float param4 = (float)luaL_checknumber(state, 4);
  1224. // Get parameter 5 off the stack.
  1225. float param5 = (float)luaL_checknumber(state, 5);
  1226. // Get parameter 6 off the stack.
  1227. float param6 = (float)luaL_checknumber(state, 6);
  1228. // Get parameter 7 off the stack.
  1229. float param7 = (float)luaL_checknumber(state, 7);
  1230. void* returnPtr = (void*)Mesh::createQuad(param1, param2, param3, param4, param5, param6, param7);
  1231. if (returnPtr)
  1232. {
  1233. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1234. object->instance = returnPtr;
  1235. object->owns = true;
  1236. luaL_getmetatable(state, "Mesh");
  1237. lua_setmetatable(state, -2);
  1238. }
  1239. else
  1240. {
  1241. lua_pushnil(state);
  1242. }
  1243. return 1;
  1244. }
  1245. else
  1246. {
  1247. lua_pushstring(state, "lua_Mesh_static_createQuad - Failed to match the given parameters to a valid function signature.");
  1248. lua_error(state);
  1249. }
  1250. break;
  1251. }
  1252. case 8:
  1253. {
  1254. if (lua_type(state, 1) == LUA_TNUMBER &&
  1255. lua_type(state, 2) == LUA_TNUMBER &&
  1256. lua_type(state, 3) == LUA_TNUMBER &&
  1257. lua_type(state, 4) == LUA_TNUMBER &&
  1258. lua_type(state, 5) == LUA_TNUMBER &&
  1259. lua_type(state, 6) == LUA_TNUMBER &&
  1260. lua_type(state, 7) == LUA_TNUMBER &&
  1261. lua_type(state, 8) == LUA_TNUMBER)
  1262. {
  1263. // Get parameter 1 off the stack.
  1264. float param1 = (float)luaL_checknumber(state, 1);
  1265. // Get parameter 2 off the stack.
  1266. float param2 = (float)luaL_checknumber(state, 2);
  1267. // Get parameter 3 off the stack.
  1268. float param3 = (float)luaL_checknumber(state, 3);
  1269. // Get parameter 4 off the stack.
  1270. float param4 = (float)luaL_checknumber(state, 4);
  1271. // Get parameter 5 off the stack.
  1272. float param5 = (float)luaL_checknumber(state, 5);
  1273. // Get parameter 6 off the stack.
  1274. float param6 = (float)luaL_checknumber(state, 6);
  1275. // Get parameter 7 off the stack.
  1276. float param7 = (float)luaL_checknumber(state, 7);
  1277. // Get parameter 8 off the stack.
  1278. float param8 = (float)luaL_checknumber(state, 8);
  1279. void* returnPtr = (void*)Mesh::createQuad(param1, param2, param3, param4, param5, param6, param7, param8);
  1280. if (returnPtr)
  1281. {
  1282. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1283. object->instance = returnPtr;
  1284. object->owns = true;
  1285. luaL_getmetatable(state, "Mesh");
  1286. lua_setmetatable(state, -2);
  1287. }
  1288. else
  1289. {
  1290. lua_pushnil(state);
  1291. }
  1292. return 1;
  1293. }
  1294. else
  1295. {
  1296. lua_pushstring(state, "lua_Mesh_static_createQuad - Failed to match the given parameters to a valid function signature.");
  1297. lua_error(state);
  1298. }
  1299. break;
  1300. }
  1301. default:
  1302. {
  1303. lua_pushstring(state, "Invalid number of parameters (expected 4, 5, 6, 7 or 8).");
  1304. lua_error(state);
  1305. break;
  1306. }
  1307. }
  1308. return 0;
  1309. }
  1310. int lua_Mesh_static_createQuadFullscreen(lua_State* state)
  1311. {
  1312. // Get the number of parameters.
  1313. int paramCount = lua_gettop(state);
  1314. // Attempt to match the parameters to a valid binding.
  1315. switch (paramCount)
  1316. {
  1317. case 0:
  1318. {
  1319. void* returnPtr = (void*)Mesh::createQuadFullscreen();
  1320. if (returnPtr)
  1321. {
  1322. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  1323. object->instance = returnPtr;
  1324. object->owns = true;
  1325. luaL_getmetatable(state, "Mesh");
  1326. lua_setmetatable(state, -2);
  1327. }
  1328. else
  1329. {
  1330. lua_pushnil(state);
  1331. }
  1332. return 1;
  1333. break;
  1334. }
  1335. default:
  1336. {
  1337. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1338. lua_error(state);
  1339. break;
  1340. }
  1341. }
  1342. return 0;
  1343. }
  1344. }