lua_Camera.cpp 45 KB

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