2
0

lua_Scene.cpp 40 KB

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