lua_Vector3.cpp 57 KB

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