lua_Vector4.cpp 47 KB

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