lua_Terrain.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  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. instance->draw();
  173. return 0;
  174. }
  175. lua_pushstring(state, "lua_Terrain_draw - Failed to match the given parameters to a valid function signature.");
  176. lua_error(state);
  177. break;
  178. }
  179. case 2:
  180. {
  181. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  182. lua_type(state, 2) == LUA_TBOOLEAN)
  183. {
  184. // Get parameter 1 off the stack.
  185. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  186. Terrain* instance = getInstance(state);
  187. instance->draw(param1);
  188. return 0;
  189. }
  190. lua_pushstring(state, "lua_Terrain_draw - Failed to match the given parameters to a valid function signature.");
  191. lua_error(state);
  192. break;
  193. }
  194. default:
  195. {
  196. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  197. lua_error(state);
  198. break;
  199. }
  200. }
  201. return 0;
  202. }
  203. int lua_Terrain_getBoundingBox(lua_State* state)
  204. {
  205. // Get the number of parameters.
  206. int paramCount = lua_gettop(state);
  207. // Attempt to match the parameters to a valid binding.
  208. switch (paramCount)
  209. {
  210. case 1:
  211. {
  212. if ((lua_type(state, 1) == LUA_TUSERDATA))
  213. {
  214. Terrain* instance = getInstance(state);
  215. void* returnPtr = (void*)&(instance->getBoundingBox());
  216. if (returnPtr)
  217. {
  218. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  219. object->instance = returnPtr;
  220. object->owns = false;
  221. luaL_getmetatable(state, "BoundingBox");
  222. lua_setmetatable(state, -2);
  223. }
  224. else
  225. {
  226. lua_pushnil(state);
  227. }
  228. return 1;
  229. }
  230. lua_pushstring(state, "lua_Terrain_getBoundingBox - Failed to match the given parameters to a valid function signature.");
  231. lua_error(state);
  232. break;
  233. }
  234. default:
  235. {
  236. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  237. lua_error(state);
  238. break;
  239. }
  240. }
  241. return 0;
  242. }
  243. int lua_Terrain_getHeight(lua_State* state)
  244. {
  245. // Get the number of parameters.
  246. int paramCount = lua_gettop(state);
  247. // Attempt to match the parameters to a valid binding.
  248. switch (paramCount)
  249. {
  250. case 3:
  251. {
  252. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  253. lua_type(state, 2) == LUA_TNUMBER &&
  254. lua_type(state, 3) == LUA_TNUMBER)
  255. {
  256. // Get parameter 1 off the stack.
  257. float param1 = (float)luaL_checknumber(state, 2);
  258. // Get parameter 2 off the stack.
  259. float param2 = (float)luaL_checknumber(state, 3);
  260. Terrain* instance = getInstance(state);
  261. float result = instance->getHeight(param1, param2);
  262. // Push the return value onto the stack.
  263. lua_pushnumber(state, result);
  264. return 1;
  265. }
  266. lua_pushstring(state, "lua_Terrain_getHeight - Failed to match the given parameters to a valid function signature.");
  267. lua_error(state);
  268. break;
  269. }
  270. default:
  271. {
  272. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  273. lua_error(state);
  274. break;
  275. }
  276. }
  277. return 0;
  278. }
  279. int lua_Terrain_getInverseWorldMatrix(lua_State* state)
  280. {
  281. // Get the number of parameters.
  282. int paramCount = lua_gettop(state);
  283. // Attempt to match the parameters to a valid binding.
  284. switch (paramCount)
  285. {
  286. case 1:
  287. {
  288. if ((lua_type(state, 1) == LUA_TUSERDATA))
  289. {
  290. Terrain* instance = getInstance(state);
  291. void* returnPtr = (void*)&(instance->getInverseWorldMatrix());
  292. if (returnPtr)
  293. {
  294. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  295. object->instance = returnPtr;
  296. object->owns = false;
  297. luaL_getmetatable(state, "Matrix");
  298. lua_setmetatable(state, -2);
  299. }
  300. else
  301. {
  302. lua_pushnil(state);
  303. }
  304. return 1;
  305. }
  306. lua_pushstring(state, "lua_Terrain_getInverseWorldMatrix - Failed to match the given parameters to a valid function signature.");
  307. lua_error(state);
  308. break;
  309. }
  310. default:
  311. {
  312. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  313. lua_error(state);
  314. break;
  315. }
  316. }
  317. return 0;
  318. }
  319. int lua_Terrain_getNode(lua_State* state)
  320. {
  321. // Get the number of parameters.
  322. int paramCount = lua_gettop(state);
  323. // Attempt to match the parameters to a valid binding.
  324. switch (paramCount)
  325. {
  326. case 1:
  327. {
  328. if ((lua_type(state, 1) == LUA_TUSERDATA))
  329. {
  330. Terrain* instance = getInstance(state);
  331. void* returnPtr = (void*)instance->getNode();
  332. if (returnPtr)
  333. {
  334. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  335. object->instance = returnPtr;
  336. object->owns = false;
  337. luaL_getmetatable(state, "Node");
  338. lua_setmetatable(state, -2);
  339. }
  340. else
  341. {
  342. lua_pushnil(state);
  343. }
  344. return 1;
  345. }
  346. lua_pushstring(state, "lua_Terrain_getNode - Failed to match the given parameters to a valid function signature.");
  347. lua_error(state);
  348. break;
  349. }
  350. default:
  351. {
  352. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  353. lua_error(state);
  354. break;
  355. }
  356. }
  357. return 0;
  358. }
  359. int lua_Terrain_getNormalMatrix(lua_State* state)
  360. {
  361. // Get the number of parameters.
  362. int paramCount = lua_gettop(state);
  363. // Attempt to match the parameters to a valid binding.
  364. switch (paramCount)
  365. {
  366. case 1:
  367. {
  368. if ((lua_type(state, 1) == LUA_TUSERDATA))
  369. {
  370. Terrain* instance = getInstance(state);
  371. void* returnPtr = (void*)&(instance->getNormalMatrix());
  372. if (returnPtr)
  373. {
  374. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  375. object->instance = returnPtr;
  376. object->owns = false;
  377. luaL_getmetatable(state, "Matrix");
  378. lua_setmetatable(state, -2);
  379. }
  380. else
  381. {
  382. lua_pushnil(state);
  383. }
  384. return 1;
  385. }
  386. lua_pushstring(state, "lua_Terrain_getNormalMatrix - 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_Terrain_getPatchCount(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. Terrain* instance = getInstance(state);
  411. unsigned int result = instance->getPatchCount();
  412. // Push the return value onto the stack.
  413. lua_pushunsigned(state, result);
  414. return 1;
  415. }
  416. lua_pushstring(state, "lua_Terrain_getPatchCount - Failed to match the given parameters to a valid function signature.");
  417. lua_error(state);
  418. break;
  419. }
  420. default:
  421. {
  422. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  423. lua_error(state);
  424. break;
  425. }
  426. }
  427. return 0;
  428. }
  429. int lua_Terrain_getRefCount(lua_State* state)
  430. {
  431. // Get the number of parameters.
  432. int paramCount = lua_gettop(state);
  433. // Attempt to match the parameters to a valid binding.
  434. switch (paramCount)
  435. {
  436. case 1:
  437. {
  438. if ((lua_type(state, 1) == LUA_TUSERDATA))
  439. {
  440. Terrain* instance = getInstance(state);
  441. unsigned int result = instance->getRefCount();
  442. // Push the return value onto the stack.
  443. lua_pushunsigned(state, result);
  444. return 1;
  445. }
  446. lua_pushstring(state, "lua_Terrain_getRefCount - Failed to match the given parameters to a valid function signature.");
  447. lua_error(state);
  448. break;
  449. }
  450. default:
  451. {
  452. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  453. lua_error(state);
  454. break;
  455. }
  456. }
  457. return 0;
  458. }
  459. int lua_Terrain_getTriangleCount(lua_State* state)
  460. {
  461. // Get the number of parameters.
  462. int paramCount = lua_gettop(state);
  463. // Attempt to match the parameters to a valid binding.
  464. switch (paramCount)
  465. {
  466. case 1:
  467. {
  468. if ((lua_type(state, 1) == LUA_TUSERDATA))
  469. {
  470. Terrain* instance = getInstance(state);
  471. unsigned int result = instance->getTriangleCount();
  472. // Push the return value onto the stack.
  473. lua_pushunsigned(state, result);
  474. return 1;
  475. }
  476. lua_pushstring(state, "lua_Terrain_getTriangleCount - Failed to match the given parameters to a valid function signature.");
  477. lua_error(state);
  478. break;
  479. }
  480. default:
  481. {
  482. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  483. lua_error(state);
  484. break;
  485. }
  486. }
  487. return 0;
  488. }
  489. int lua_Terrain_getVisiblePatchCount(lua_State* state)
  490. {
  491. // Get the number of parameters.
  492. int paramCount = lua_gettop(state);
  493. // Attempt to match the parameters to a valid binding.
  494. switch (paramCount)
  495. {
  496. case 1:
  497. {
  498. if ((lua_type(state, 1) == LUA_TUSERDATA))
  499. {
  500. Terrain* instance = getInstance(state);
  501. unsigned int result = instance->getVisiblePatchCount();
  502. // Push the return value onto the stack.
  503. lua_pushunsigned(state, result);
  504. return 1;
  505. }
  506. lua_pushstring(state, "lua_Terrain_getVisiblePatchCount - Failed to match the given parameters to a valid function signature.");
  507. lua_error(state);
  508. break;
  509. }
  510. default:
  511. {
  512. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  513. lua_error(state);
  514. break;
  515. }
  516. }
  517. return 0;
  518. }
  519. int lua_Terrain_getVisibleTriangleCount(lua_State* state)
  520. {
  521. // Get the number of parameters.
  522. int paramCount = lua_gettop(state);
  523. // Attempt to match the parameters to a valid binding.
  524. switch (paramCount)
  525. {
  526. case 1:
  527. {
  528. if ((lua_type(state, 1) == LUA_TUSERDATA))
  529. {
  530. Terrain* instance = getInstance(state);
  531. unsigned int result = instance->getVisibleTriangleCount();
  532. // Push the return value onto the stack.
  533. lua_pushunsigned(state, result);
  534. return 1;
  535. }
  536. lua_pushstring(state, "lua_Terrain_getVisibleTriangleCount - 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_Terrain_getWorldMatrix(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. Terrain* instance = getInstance(state);
  561. void* returnPtr = (void*)&(instance->getWorldMatrix());
  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_Terrain_getWorldMatrix - 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_Terrain_getWorldViewMatrix(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. Terrain* instance = getInstance(state);
  601. void* returnPtr = (void*)&(instance->getWorldViewMatrix());
  602. if (returnPtr)
  603. {
  604. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  605. object->instance = returnPtr;
  606. object->owns = false;
  607. luaL_getmetatable(state, "Matrix");
  608. lua_setmetatable(state, -2);
  609. }
  610. else
  611. {
  612. lua_pushnil(state);
  613. }
  614. return 1;
  615. }
  616. lua_pushstring(state, "lua_Terrain_getWorldViewMatrix - Failed to match the given parameters to a valid function signature.");
  617. lua_error(state);
  618. break;
  619. }
  620. default:
  621. {
  622. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  623. lua_error(state);
  624. break;
  625. }
  626. }
  627. return 0;
  628. }
  629. int lua_Terrain_getWorldViewProjectionMatrix(lua_State* state)
  630. {
  631. // Get the number of parameters.
  632. int paramCount = lua_gettop(state);
  633. // Attempt to match the parameters to a valid binding.
  634. switch (paramCount)
  635. {
  636. case 1:
  637. {
  638. if ((lua_type(state, 1) == LUA_TUSERDATA))
  639. {
  640. Terrain* instance = getInstance(state);
  641. void* returnPtr = (void*)&(instance->getWorldViewProjectionMatrix());
  642. if (returnPtr)
  643. {
  644. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  645. object->instance = returnPtr;
  646. object->owns = false;
  647. luaL_getmetatable(state, "Matrix");
  648. lua_setmetatable(state, -2);
  649. }
  650. else
  651. {
  652. lua_pushnil(state);
  653. }
  654. return 1;
  655. }
  656. lua_pushstring(state, "lua_Terrain_getWorldViewProjectionMatrix - Failed to match the given parameters to a valid function signature.");
  657. lua_error(state);
  658. break;
  659. }
  660. default:
  661. {
  662. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  663. lua_error(state);
  664. break;
  665. }
  666. }
  667. return 0;
  668. }
  669. int lua_Terrain_isFlagSet(lua_State* state)
  670. {
  671. // Get the number of parameters.
  672. int paramCount = lua_gettop(state);
  673. // Attempt to match the parameters to a valid binding.
  674. switch (paramCount)
  675. {
  676. case 2:
  677. {
  678. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  679. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  680. {
  681. // Get parameter 1 off the stack.
  682. Terrain::Flags param1 = (Terrain::Flags)lua_enumFromString_TerrainFlags(luaL_checkstring(state, 2));
  683. Terrain* instance = getInstance(state);
  684. bool result = instance->isFlagSet(param1);
  685. // Push the return value onto the stack.
  686. lua_pushboolean(state, result);
  687. return 1;
  688. }
  689. lua_pushstring(state, "lua_Terrain_isFlagSet - Failed to match the given parameters to a valid function signature.");
  690. lua_error(state);
  691. break;
  692. }
  693. default:
  694. {
  695. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  696. lua_error(state);
  697. break;
  698. }
  699. }
  700. return 0;
  701. }
  702. int lua_Terrain_release(lua_State* state)
  703. {
  704. // Get the number of parameters.
  705. int paramCount = lua_gettop(state);
  706. // Attempt to match the parameters to a valid binding.
  707. switch (paramCount)
  708. {
  709. case 1:
  710. {
  711. if ((lua_type(state, 1) == LUA_TUSERDATA))
  712. {
  713. Terrain* instance = getInstance(state);
  714. instance->release();
  715. return 0;
  716. }
  717. lua_pushstring(state, "lua_Terrain_release - Failed to match the given parameters to a valid function signature.");
  718. lua_error(state);
  719. break;
  720. }
  721. default:
  722. {
  723. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  724. lua_error(state);
  725. break;
  726. }
  727. }
  728. return 0;
  729. }
  730. int lua_Terrain_removeListener(lua_State* state)
  731. {
  732. // Get the number of parameters.
  733. int paramCount = lua_gettop(state);
  734. // Attempt to match the parameters to a valid binding.
  735. switch (paramCount)
  736. {
  737. case 2:
  738. {
  739. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  740. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  741. {
  742. // Get parameter 1 off the stack.
  743. bool param1Valid;
  744. gameplay::ScriptUtil::LuaArray<Terrain::Listener> param1 = gameplay::ScriptUtil::getObjectPointer<Terrain::Listener>(2, "TerrainListener", false, &param1Valid);
  745. if (!param1Valid)
  746. {
  747. lua_pushstring(state, "Failed to convert parameter 1 to type 'Terrain::Listener'.");
  748. lua_error(state);
  749. }
  750. Terrain* instance = getInstance(state);
  751. instance->removeListener(param1);
  752. return 0;
  753. }
  754. lua_pushstring(state, "lua_Terrain_removeListener - Failed to match the given parameters to a valid function signature.");
  755. lua_error(state);
  756. break;
  757. }
  758. default:
  759. {
  760. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  761. lua_error(state);
  762. break;
  763. }
  764. }
  765. return 0;
  766. }
  767. int lua_Terrain_setFlag(lua_State* state)
  768. {
  769. // Get the number of parameters.
  770. int paramCount = lua_gettop(state);
  771. // Attempt to match the parameters to a valid binding.
  772. switch (paramCount)
  773. {
  774. case 3:
  775. {
  776. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  777. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  778. lua_type(state, 3) == LUA_TBOOLEAN)
  779. {
  780. // Get parameter 1 off the stack.
  781. Terrain::Flags param1 = (Terrain::Flags)lua_enumFromString_TerrainFlags(luaL_checkstring(state, 2));
  782. // Get parameter 2 off the stack.
  783. bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
  784. Terrain* instance = getInstance(state);
  785. instance->setFlag(param1, param2);
  786. return 0;
  787. }
  788. lua_pushstring(state, "lua_Terrain_setFlag - Failed to match the given parameters to a valid function signature.");
  789. lua_error(state);
  790. break;
  791. }
  792. default:
  793. {
  794. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  795. lua_error(state);
  796. break;
  797. }
  798. }
  799. return 0;
  800. }
  801. int lua_Terrain_static_create(lua_State* state)
  802. {
  803. // Get the number of parameters.
  804. int paramCount = lua_gettop(state);
  805. // Attempt to match the parameters to a valid binding.
  806. switch (paramCount)
  807. {
  808. case 1:
  809. {
  810. do
  811. {
  812. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  813. {
  814. // Get parameter 1 off the stack.
  815. const char* param1 = gameplay::ScriptUtil::getString(1, false);
  816. void* returnPtr = (void*)Terrain::create(param1);
  817. if (returnPtr)
  818. {
  819. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  820. object->instance = returnPtr;
  821. object->owns = true;
  822. luaL_getmetatable(state, "Terrain");
  823. lua_setmetatable(state, -2);
  824. }
  825. else
  826. {
  827. lua_pushnil(state);
  828. }
  829. return 1;
  830. }
  831. } while (0);
  832. do
  833. {
  834. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  835. {
  836. // Get parameter 1 off the stack.
  837. bool param1Valid;
  838. gameplay::ScriptUtil::LuaArray<Properties> param1 = gameplay::ScriptUtil::getObjectPointer<Properties>(1, "Properties", false, &param1Valid);
  839. if (!param1Valid)
  840. break;
  841. void* returnPtr = (void*)Terrain::create(param1);
  842. if (returnPtr)
  843. {
  844. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  845. object->instance = returnPtr;
  846. object->owns = true;
  847. luaL_getmetatable(state, "Terrain");
  848. lua_setmetatable(state, -2);
  849. }
  850. else
  851. {
  852. lua_pushnil(state);
  853. }
  854. return 1;
  855. }
  856. } while (0);
  857. do
  858. {
  859. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL))
  860. {
  861. // Get parameter 1 off the stack.
  862. bool param1Valid;
  863. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  864. if (!param1Valid)
  865. break;
  866. void* returnPtr = (void*)Terrain::create(param1);
  867. if (returnPtr)
  868. {
  869. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  870. object->instance = returnPtr;
  871. object->owns = true;
  872. luaL_getmetatable(state, "Terrain");
  873. lua_setmetatable(state, -2);
  874. }
  875. else
  876. {
  877. lua_pushnil(state);
  878. }
  879. return 1;
  880. }
  881. } while (0);
  882. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  883. lua_error(state);
  884. break;
  885. }
  886. case 2:
  887. {
  888. do
  889. {
  890. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  891. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  892. {
  893. // Get parameter 1 off the stack.
  894. bool param1Valid;
  895. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  896. if (!param1Valid)
  897. break;
  898. // Get parameter 2 off the stack.
  899. bool param2Valid;
  900. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  901. if (!param2Valid)
  902. break;
  903. void* returnPtr = (void*)Terrain::create(param1, *param2);
  904. if (returnPtr)
  905. {
  906. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  907. object->instance = returnPtr;
  908. object->owns = true;
  909. luaL_getmetatable(state, "Terrain");
  910. lua_setmetatable(state, -2);
  911. }
  912. else
  913. {
  914. lua_pushnil(state);
  915. }
  916. return 1;
  917. }
  918. } while (0);
  919. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  920. lua_error(state);
  921. break;
  922. }
  923. case 3:
  924. {
  925. do
  926. {
  927. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  928. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  929. lua_type(state, 3) == LUA_TNUMBER)
  930. {
  931. // Get parameter 1 off the stack.
  932. bool param1Valid;
  933. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  934. if (!param1Valid)
  935. break;
  936. // Get parameter 2 off the stack.
  937. bool param2Valid;
  938. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  939. if (!param2Valid)
  940. break;
  941. // Get parameter 3 off the stack.
  942. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  943. void* returnPtr = (void*)Terrain::create(param1, *param2, param3);
  944. if (returnPtr)
  945. {
  946. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  947. object->instance = returnPtr;
  948. object->owns = true;
  949. luaL_getmetatable(state, "Terrain");
  950. lua_setmetatable(state, -2);
  951. }
  952. else
  953. {
  954. lua_pushnil(state);
  955. }
  956. return 1;
  957. }
  958. } while (0);
  959. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  960. lua_error(state);
  961. break;
  962. }
  963. case 4:
  964. {
  965. do
  966. {
  967. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  968. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  969. lua_type(state, 3) == LUA_TNUMBER &&
  970. lua_type(state, 4) == LUA_TNUMBER)
  971. {
  972. // Get parameter 1 off the stack.
  973. bool param1Valid;
  974. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  975. if (!param1Valid)
  976. break;
  977. // Get parameter 2 off the stack.
  978. bool param2Valid;
  979. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  980. if (!param2Valid)
  981. break;
  982. // Get parameter 3 off the stack.
  983. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  984. // Get parameter 4 off the stack.
  985. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  986. void* returnPtr = (void*)Terrain::create(param1, *param2, param3, param4);
  987. if (returnPtr)
  988. {
  989. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  990. object->instance = returnPtr;
  991. object->owns = true;
  992. luaL_getmetatable(state, "Terrain");
  993. lua_setmetatable(state, -2);
  994. }
  995. else
  996. {
  997. lua_pushnil(state);
  998. }
  999. return 1;
  1000. }
  1001. } while (0);
  1002. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  1003. lua_error(state);
  1004. break;
  1005. }
  1006. case 5:
  1007. {
  1008. do
  1009. {
  1010. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  1011. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  1012. lua_type(state, 3) == LUA_TNUMBER &&
  1013. lua_type(state, 4) == LUA_TNUMBER &&
  1014. lua_type(state, 5) == LUA_TNUMBER)
  1015. {
  1016. // Get parameter 1 off the stack.
  1017. bool param1Valid;
  1018. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  1019. if (!param1Valid)
  1020. break;
  1021. // Get parameter 2 off the stack.
  1022. bool param2Valid;
  1023. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  1024. if (!param2Valid)
  1025. break;
  1026. // Get parameter 3 off the stack.
  1027. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  1028. // Get parameter 4 off the stack.
  1029. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  1030. // Get parameter 5 off the stack.
  1031. float param5 = (float)luaL_checknumber(state, 5);
  1032. void* returnPtr = (void*)Terrain::create(param1, *param2, param3, param4, param5);
  1033. if (returnPtr)
  1034. {
  1035. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1036. object->instance = returnPtr;
  1037. object->owns = true;
  1038. luaL_getmetatable(state, "Terrain");
  1039. lua_setmetatable(state, -2);
  1040. }
  1041. else
  1042. {
  1043. lua_pushnil(state);
  1044. }
  1045. return 1;
  1046. }
  1047. } while (0);
  1048. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  1049. lua_error(state);
  1050. break;
  1051. }
  1052. case 6:
  1053. {
  1054. do
  1055. {
  1056. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
  1057. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  1058. lua_type(state, 3) == LUA_TNUMBER &&
  1059. lua_type(state, 4) == LUA_TNUMBER &&
  1060. lua_type(state, 5) == LUA_TNUMBER &&
  1061. (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL))
  1062. {
  1063. // Get parameter 1 off the stack.
  1064. bool param1Valid;
  1065. gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
  1066. if (!param1Valid)
  1067. break;
  1068. // Get parameter 2 off the stack.
  1069. bool param2Valid;
  1070. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  1071. if (!param2Valid)
  1072. break;
  1073. // Get parameter 3 off the stack.
  1074. unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
  1075. // Get parameter 4 off the stack.
  1076. unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
  1077. // Get parameter 5 off the stack.
  1078. float param5 = (float)luaL_checknumber(state, 5);
  1079. // Get parameter 6 off the stack.
  1080. const char* param6 = gameplay::ScriptUtil::getString(6, false);
  1081. void* returnPtr = (void*)Terrain::create(param1, *param2, param3, param4, param5, param6);
  1082. if (returnPtr)
  1083. {
  1084. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1085. object->instance = returnPtr;
  1086. object->owns = true;
  1087. luaL_getmetatable(state, "Terrain");
  1088. lua_setmetatable(state, -2);
  1089. }
  1090. else
  1091. {
  1092. lua_pushnil(state);
  1093. }
  1094. return 1;
  1095. }
  1096. } while (0);
  1097. lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
  1098. lua_error(state);
  1099. break;
  1100. }
  1101. default:
  1102. {
  1103. lua_pushstring(state, "Invalid number of parameters (expected 1, 2, 3, 4, 5 or 6).");
  1104. lua_error(state);
  1105. break;
  1106. }
  1107. }
  1108. return 0;
  1109. }
  1110. int lua_Terrain_transformChanged(lua_State* state)
  1111. {
  1112. // Get the number of parameters.
  1113. int paramCount = lua_gettop(state);
  1114. // Attempt to match the parameters to a valid binding.
  1115. switch (paramCount)
  1116. {
  1117. case 3:
  1118. {
  1119. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1120. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  1121. lua_type(state, 3) == LUA_TNUMBER)
  1122. {
  1123. // Get parameter 1 off the stack.
  1124. bool param1Valid;
  1125. gameplay::ScriptUtil::LuaArray<Transform> param1 = gameplay::ScriptUtil::getObjectPointer<Transform>(2, "Transform", false, &param1Valid);
  1126. if (!param1Valid)
  1127. {
  1128. lua_pushstring(state, "Failed to convert parameter 1 to type 'Transform'.");
  1129. lua_error(state);
  1130. }
  1131. // Get parameter 2 off the stack.
  1132. long param2 = (long)luaL_checklong(state, 3);
  1133. Terrain* instance = getInstance(state);
  1134. instance->transformChanged(param1, param2);
  1135. return 0;
  1136. }
  1137. lua_pushstring(state, "lua_Terrain_transformChanged - Failed to match the given parameters to a valid function signature.");
  1138. lua_error(state);
  1139. break;
  1140. }
  1141. default:
  1142. {
  1143. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1144. lua_error(state);
  1145. break;
  1146. }
  1147. }
  1148. return 0;
  1149. }
  1150. }