lua_Camera.cpp 48 KB

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