lua_Vector3.cpp 49 KB

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