lua_Terrain.cpp 45 KB

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