lua_Scene.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  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. namespace gameplay
  13. {
  14. void luaRegister_Scene()
  15. {
  16. const luaL_Reg lua_members[] =
  17. {
  18. {"addNode", lua_Scene_addNode},
  19. {"addRef", lua_Scene_addRef},
  20. {"bindAudioListenerToCamera", lua_Scene_bindAudioListenerToCamera},
  21. {"drawDebug", lua_Scene_drawDebug},
  22. {"findNode", lua_Scene_findNode},
  23. {"getActiveCamera", lua_Scene_getActiveCamera},
  24. {"getAmbientColor", lua_Scene_getAmbientColor},
  25. {"getFirstNode", lua_Scene_getFirstNode},
  26. {"getId", lua_Scene_getId},
  27. {"getNodeCount", lua_Scene_getNodeCount},
  28. {"getRefCount", lua_Scene_getRefCount},
  29. {"release", lua_Scene_release},
  30. {"removeAllNodes", lua_Scene_removeAllNodes},
  31. {"removeNode", lua_Scene_removeNode},
  32. {"setActiveCamera", lua_Scene_setActiveCamera},
  33. {"setAmbientColor", lua_Scene_setAmbientColor},
  34. {"setId", lua_Scene_setId},
  35. {"visit", lua_Scene_visit},
  36. {NULL, NULL}
  37. };
  38. const luaL_Reg lua_statics[] =
  39. {
  40. {"createScene", lua_Scene_static_createScene},
  41. {"load", lua_Scene_static_load},
  42. {NULL, NULL}
  43. };
  44. std::vector<std::string> scopePath;
  45. ScriptUtil::registerClass("Scene", lua_members, NULL, lua_Scene__gc, lua_statics, scopePath);
  46. }
  47. static Scene* getInstance(lua_State* state)
  48. {
  49. void* userdata = luaL_checkudata(state, 1, "Scene");
  50. luaL_argcheck(state, userdata != NULL, 1, "'Scene' expected.");
  51. return (Scene*)((ScriptUtil::LuaObject*)userdata)->instance;
  52. }
  53. int lua_Scene__gc(lua_State* state)
  54. {
  55. // Get the number of parameters.
  56. int paramCount = lua_gettop(state);
  57. // Attempt to match the parameters to a valid binding.
  58. switch (paramCount)
  59. {
  60. case 1:
  61. {
  62. if ((lua_type(state, 1) == LUA_TUSERDATA))
  63. {
  64. void* userdata = luaL_checkudata(state, 1, "Scene");
  65. luaL_argcheck(state, userdata != NULL, 1, "'Scene' expected.");
  66. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)userdata;
  67. if (object->owns)
  68. {
  69. Scene* instance = (Scene*)object->instance;
  70. SAFE_RELEASE(instance);
  71. }
  72. return 0;
  73. }
  74. else
  75. {
  76. lua_pushstring(state, "lua_Scene__gc - Failed to match the given parameters to a valid function signature.");
  77. lua_error(state);
  78. }
  79. break;
  80. }
  81. default:
  82. {
  83. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  84. lua_error(state);
  85. break;
  86. }
  87. }
  88. return 0;
  89. }
  90. int lua_Scene_addNode(lua_State* state)
  91. {
  92. // Get the number of parameters.
  93. int paramCount = lua_gettop(state);
  94. // Attempt to match the parameters to a valid binding.
  95. switch (paramCount)
  96. {
  97. case 1:
  98. {
  99. if ((lua_type(state, 1) == LUA_TUSERDATA))
  100. {
  101. Scene* instance = getInstance(state);
  102. void* returnPtr = (void*)instance->addNode();
  103. if (returnPtr)
  104. {
  105. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  106. object->instance = returnPtr;
  107. object->owns = false;
  108. luaL_getmetatable(state, "Node");
  109. lua_setmetatable(state, -2);
  110. }
  111. else
  112. {
  113. lua_pushnil(state);
  114. }
  115. return 1;
  116. }
  117. else
  118. {
  119. lua_pushstring(state, "lua_Scene_addNode - Failed to match the given parameters to a valid function signature.");
  120. lua_error(state);
  121. }
  122. break;
  123. }
  124. case 2:
  125. {
  126. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  127. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  128. {
  129. // Get parameter 1 off the stack.
  130. const char* param1 = ScriptUtil::getString(2, false);
  131. Scene* instance = getInstance(state);
  132. void* returnPtr = (void*)instance->addNode(param1);
  133. if (returnPtr)
  134. {
  135. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  136. object->instance = returnPtr;
  137. object->owns = false;
  138. luaL_getmetatable(state, "Node");
  139. lua_setmetatable(state, -2);
  140. }
  141. else
  142. {
  143. lua_pushnil(state);
  144. }
  145. return 1;
  146. }
  147. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  148. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  149. {
  150. // Get parameter 1 off the stack.
  151. Node* param1 = ScriptUtil::getObjectPointer<Node>(2, "Node", false);
  152. Scene* instance = getInstance(state);
  153. instance->addNode(param1);
  154. return 0;
  155. }
  156. else
  157. {
  158. lua_pushstring(state, "lua_Scene_addNode - Failed to match the given parameters to a valid function signature.");
  159. lua_error(state);
  160. }
  161. break;
  162. }
  163. default:
  164. {
  165. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  166. lua_error(state);
  167. break;
  168. }
  169. }
  170. return 0;
  171. }
  172. int lua_Scene_addRef(lua_State* state)
  173. {
  174. // Get the number of parameters.
  175. int paramCount = lua_gettop(state);
  176. // Attempt to match the parameters to a valid binding.
  177. switch (paramCount)
  178. {
  179. case 1:
  180. {
  181. if ((lua_type(state, 1) == LUA_TUSERDATA))
  182. {
  183. Scene* instance = getInstance(state);
  184. instance->addRef();
  185. return 0;
  186. }
  187. else
  188. {
  189. lua_pushstring(state, "lua_Scene_addRef - Failed to match the given parameters to a valid function signature.");
  190. lua_error(state);
  191. }
  192. break;
  193. }
  194. default:
  195. {
  196. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  197. lua_error(state);
  198. break;
  199. }
  200. }
  201. return 0;
  202. }
  203. int lua_Scene_bindAudioListenerToCamera(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 2:
  211. {
  212. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  213. lua_type(state, 2) == LUA_TBOOLEAN)
  214. {
  215. // Get parameter 1 off the stack.
  216. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  217. Scene* instance = getInstance(state);
  218. instance->bindAudioListenerToCamera(param1);
  219. return 0;
  220. }
  221. else
  222. {
  223. lua_pushstring(state, "lua_Scene_bindAudioListenerToCamera - Failed to match the given parameters to a valid function signature.");
  224. lua_error(state);
  225. }
  226. break;
  227. }
  228. default:
  229. {
  230. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  231. lua_error(state);
  232. break;
  233. }
  234. }
  235. return 0;
  236. }
  237. int lua_Scene_drawDebug(lua_State* state)
  238. {
  239. // Get the number of parameters.
  240. int paramCount = lua_gettop(state);
  241. // Attempt to match the parameters to a valid binding.
  242. switch (paramCount)
  243. {
  244. case 2:
  245. {
  246. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  247. lua_type(state, 2) == LUA_TNUMBER)
  248. {
  249. // Get parameter 1 off the stack.
  250. unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
  251. Scene* instance = getInstance(state);
  252. instance->drawDebug(param1);
  253. return 0;
  254. }
  255. else
  256. {
  257. lua_pushstring(state, "lua_Scene_drawDebug - Failed to match the given parameters to a valid function signature.");
  258. lua_error(state);
  259. }
  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. else
  302. {
  303. lua_pushstring(state, "lua_Scene_findNode - Failed to match the given parameters to a valid function signature.");
  304. lua_error(state);
  305. }
  306. break;
  307. }
  308. case 3:
  309. {
  310. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  311. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  312. lua_type(state, 3) == LUA_TBOOLEAN)
  313. {
  314. // Get parameter 1 off the stack.
  315. const char* param1 = ScriptUtil::getString(2, false);
  316. // Get parameter 2 off the stack.
  317. bool param2 = ScriptUtil::luaCheckBool(state, 3);
  318. Scene* instance = getInstance(state);
  319. void* returnPtr = (void*)instance->findNode(param1, param2);
  320. if (returnPtr)
  321. {
  322. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  323. object->instance = returnPtr;
  324. object->owns = false;
  325. luaL_getmetatable(state, "Node");
  326. lua_setmetatable(state, -2);
  327. }
  328. else
  329. {
  330. lua_pushnil(state);
  331. }
  332. return 1;
  333. }
  334. else
  335. {
  336. lua_pushstring(state, "lua_Scene_findNode - Failed to match the given parameters to a valid function signature.");
  337. lua_error(state);
  338. }
  339. break;
  340. }
  341. case 4:
  342. {
  343. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  344. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  345. lua_type(state, 3) == LUA_TBOOLEAN &&
  346. lua_type(state, 4) == LUA_TBOOLEAN)
  347. {
  348. // Get parameter 1 off the stack.
  349. const char* param1 = ScriptUtil::getString(2, false);
  350. // Get parameter 2 off the stack.
  351. bool param2 = ScriptUtil::luaCheckBool(state, 3);
  352. // Get parameter 3 off the stack.
  353. bool param3 = ScriptUtil::luaCheckBool(state, 4);
  354. Scene* instance = getInstance(state);
  355. void* returnPtr = (void*)instance->findNode(param1, param2, param3);
  356. if (returnPtr)
  357. {
  358. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  359. object->instance = returnPtr;
  360. object->owns = false;
  361. luaL_getmetatable(state, "Node");
  362. lua_setmetatable(state, -2);
  363. }
  364. else
  365. {
  366. lua_pushnil(state);
  367. }
  368. return 1;
  369. }
  370. else
  371. {
  372. lua_pushstring(state, "lua_Scene_findNode - Failed to match the given parameters to a valid function signature.");
  373. lua_error(state);
  374. }
  375. break;
  376. }
  377. default:
  378. {
  379. lua_pushstring(state, "Invalid number of parameters (expected 2, 3 or 4).");
  380. lua_error(state);
  381. break;
  382. }
  383. }
  384. return 0;
  385. }
  386. int lua_Scene_getActiveCamera(lua_State* state)
  387. {
  388. // Get the number of parameters.
  389. int paramCount = lua_gettop(state);
  390. // Attempt to match the parameters to a valid binding.
  391. switch (paramCount)
  392. {
  393. case 1:
  394. {
  395. if ((lua_type(state, 1) == LUA_TUSERDATA))
  396. {
  397. Scene* instance = getInstance(state);
  398. void* returnPtr = (void*)instance->getActiveCamera();
  399. if (returnPtr)
  400. {
  401. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  402. object->instance = returnPtr;
  403. object->owns = false;
  404. luaL_getmetatable(state, "Camera");
  405. lua_setmetatable(state, -2);
  406. }
  407. else
  408. {
  409. lua_pushnil(state);
  410. }
  411. return 1;
  412. }
  413. else
  414. {
  415. lua_pushstring(state, "lua_Scene_getActiveCamera - Failed to match the given parameters to a valid function signature.");
  416. lua_error(state);
  417. }
  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_Scene_getAmbientColor(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. Scene* instance = getInstance(state);
  441. void* returnPtr = (void*)&(instance->getAmbientColor());
  442. if (returnPtr)
  443. {
  444. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  445. object->instance = returnPtr;
  446. object->owns = false;
  447. luaL_getmetatable(state, "Vector3");
  448. lua_setmetatable(state, -2);
  449. }
  450. else
  451. {
  452. lua_pushnil(state);
  453. }
  454. return 1;
  455. }
  456. else
  457. {
  458. lua_pushstring(state, "lua_Scene_getAmbientColor - Failed to match the given parameters to a valid function signature.");
  459. lua_error(state);
  460. }
  461. break;
  462. }
  463. default:
  464. {
  465. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  466. lua_error(state);
  467. break;
  468. }
  469. }
  470. return 0;
  471. }
  472. int lua_Scene_getFirstNode(lua_State* state)
  473. {
  474. // Get the number of parameters.
  475. int paramCount = lua_gettop(state);
  476. // Attempt to match the parameters to a valid binding.
  477. switch (paramCount)
  478. {
  479. case 1:
  480. {
  481. if ((lua_type(state, 1) == LUA_TUSERDATA))
  482. {
  483. Scene* instance = getInstance(state);
  484. void* returnPtr = (void*)instance->getFirstNode();
  485. if (returnPtr)
  486. {
  487. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  488. object->instance = returnPtr;
  489. object->owns = false;
  490. luaL_getmetatable(state, "Node");
  491. lua_setmetatable(state, -2);
  492. }
  493. else
  494. {
  495. lua_pushnil(state);
  496. }
  497. return 1;
  498. }
  499. else
  500. {
  501. lua_pushstring(state, "lua_Scene_getFirstNode - Failed to match the given parameters to a valid function signature.");
  502. lua_error(state);
  503. }
  504. break;
  505. }
  506. default:
  507. {
  508. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  509. lua_error(state);
  510. break;
  511. }
  512. }
  513. return 0;
  514. }
  515. int lua_Scene_getId(lua_State* state)
  516. {
  517. // Get the number of parameters.
  518. int paramCount = lua_gettop(state);
  519. // Attempt to match the parameters to a valid binding.
  520. switch (paramCount)
  521. {
  522. case 1:
  523. {
  524. if ((lua_type(state, 1) == LUA_TUSERDATA))
  525. {
  526. Scene* instance = getInstance(state);
  527. const char* result = instance->getId();
  528. // Push the return value onto the stack.
  529. lua_pushstring(state, result);
  530. return 1;
  531. }
  532. else
  533. {
  534. lua_pushstring(state, "lua_Scene_getId - Failed to match the given parameters to a valid function signature.");
  535. lua_error(state);
  536. }
  537. break;
  538. }
  539. default:
  540. {
  541. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  542. lua_error(state);
  543. break;
  544. }
  545. }
  546. return 0;
  547. }
  548. int lua_Scene_getNodeCount(lua_State* state)
  549. {
  550. // Get the number of parameters.
  551. int paramCount = lua_gettop(state);
  552. // Attempt to match the parameters to a valid binding.
  553. switch (paramCount)
  554. {
  555. case 1:
  556. {
  557. if ((lua_type(state, 1) == LUA_TUSERDATA))
  558. {
  559. Scene* instance = getInstance(state);
  560. unsigned int result = instance->getNodeCount();
  561. // Push the return value onto the stack.
  562. lua_pushunsigned(state, result);
  563. return 1;
  564. }
  565. else
  566. {
  567. lua_pushstring(state, "lua_Scene_getNodeCount - Failed to match the given parameters to a valid function signature.");
  568. lua_error(state);
  569. }
  570. break;
  571. }
  572. default:
  573. {
  574. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  575. lua_error(state);
  576. break;
  577. }
  578. }
  579. return 0;
  580. }
  581. int lua_Scene_getRefCount(lua_State* state)
  582. {
  583. // Get the number of parameters.
  584. int paramCount = lua_gettop(state);
  585. // Attempt to match the parameters to a valid binding.
  586. switch (paramCount)
  587. {
  588. case 1:
  589. {
  590. if ((lua_type(state, 1) == LUA_TUSERDATA))
  591. {
  592. Scene* instance = getInstance(state);
  593. unsigned int result = instance->getRefCount();
  594. // Push the return value onto the stack.
  595. lua_pushunsigned(state, result);
  596. return 1;
  597. }
  598. else
  599. {
  600. lua_pushstring(state, "lua_Scene_getRefCount - Failed to match the given parameters to a valid function signature.");
  601. lua_error(state);
  602. }
  603. break;
  604. }
  605. default:
  606. {
  607. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  608. lua_error(state);
  609. break;
  610. }
  611. }
  612. return 0;
  613. }
  614. int lua_Scene_release(lua_State* state)
  615. {
  616. // Get the number of parameters.
  617. int paramCount = lua_gettop(state);
  618. // Attempt to match the parameters to a valid binding.
  619. switch (paramCount)
  620. {
  621. case 1:
  622. {
  623. if ((lua_type(state, 1) == LUA_TUSERDATA))
  624. {
  625. Scene* instance = getInstance(state);
  626. instance->release();
  627. return 0;
  628. }
  629. else
  630. {
  631. lua_pushstring(state, "lua_Scene_release - Failed to match the given parameters to a valid function signature.");
  632. lua_error(state);
  633. }
  634. break;
  635. }
  636. default:
  637. {
  638. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  639. lua_error(state);
  640. break;
  641. }
  642. }
  643. return 0;
  644. }
  645. int lua_Scene_removeAllNodes(lua_State* state)
  646. {
  647. // Get the number of parameters.
  648. int paramCount = lua_gettop(state);
  649. // Attempt to match the parameters to a valid binding.
  650. switch (paramCount)
  651. {
  652. case 1:
  653. {
  654. if ((lua_type(state, 1) == LUA_TUSERDATA))
  655. {
  656. Scene* instance = getInstance(state);
  657. instance->removeAllNodes();
  658. return 0;
  659. }
  660. else
  661. {
  662. lua_pushstring(state, "lua_Scene_removeAllNodes - Failed to match the given parameters to a valid function signature.");
  663. lua_error(state);
  664. }
  665. break;
  666. }
  667. default:
  668. {
  669. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  670. lua_error(state);
  671. break;
  672. }
  673. }
  674. return 0;
  675. }
  676. int lua_Scene_removeNode(lua_State* state)
  677. {
  678. // Get the number of parameters.
  679. int paramCount = lua_gettop(state);
  680. // Attempt to match the parameters to a valid binding.
  681. switch (paramCount)
  682. {
  683. case 2:
  684. {
  685. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  686. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  687. {
  688. // Get parameter 1 off the stack.
  689. Node* param1 = ScriptUtil::getObjectPointer<Node>(2, "Node", false);
  690. Scene* instance = getInstance(state);
  691. instance->removeNode(param1);
  692. return 0;
  693. }
  694. else
  695. {
  696. lua_pushstring(state, "lua_Scene_removeNode - Failed to match the given parameters to a valid function signature.");
  697. lua_error(state);
  698. }
  699. break;
  700. }
  701. default:
  702. {
  703. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  704. lua_error(state);
  705. break;
  706. }
  707. }
  708. return 0;
  709. }
  710. int lua_Scene_setActiveCamera(lua_State* state)
  711. {
  712. // Get the number of parameters.
  713. int paramCount = lua_gettop(state);
  714. // Attempt to match the parameters to a valid binding.
  715. switch (paramCount)
  716. {
  717. case 2:
  718. {
  719. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  720. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  721. {
  722. // Get parameter 1 off the stack.
  723. Camera* param1 = ScriptUtil::getObjectPointer<Camera>(2, "Camera", false);
  724. Scene* instance = getInstance(state);
  725. instance->setActiveCamera(param1);
  726. return 0;
  727. }
  728. else
  729. {
  730. lua_pushstring(state, "lua_Scene_setActiveCamera - Failed to match the given parameters to a valid function signature.");
  731. lua_error(state);
  732. }
  733. break;
  734. }
  735. default:
  736. {
  737. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  738. lua_error(state);
  739. break;
  740. }
  741. }
  742. return 0;
  743. }
  744. int lua_Scene_setAmbientColor(lua_State* state)
  745. {
  746. // Get the number of parameters.
  747. int paramCount = lua_gettop(state);
  748. // Attempt to match the parameters to a valid binding.
  749. switch (paramCount)
  750. {
  751. case 4:
  752. {
  753. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  754. lua_type(state, 2) == LUA_TNUMBER &&
  755. lua_type(state, 3) == LUA_TNUMBER &&
  756. lua_type(state, 4) == LUA_TNUMBER)
  757. {
  758. // Get parameter 1 off the stack.
  759. float param1 = (float)luaL_checknumber(state, 2);
  760. // Get parameter 2 off the stack.
  761. float param2 = (float)luaL_checknumber(state, 3);
  762. // Get parameter 3 off the stack.
  763. float param3 = (float)luaL_checknumber(state, 4);
  764. Scene* instance = getInstance(state);
  765. instance->setAmbientColor(param1, param2, param3);
  766. return 0;
  767. }
  768. else
  769. {
  770. lua_pushstring(state, "lua_Scene_setAmbientColor - Failed to match the given parameters to a valid function signature.");
  771. lua_error(state);
  772. }
  773. break;
  774. }
  775. default:
  776. {
  777. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  778. lua_error(state);
  779. break;
  780. }
  781. }
  782. return 0;
  783. }
  784. int lua_Scene_setId(lua_State* state)
  785. {
  786. // Get the number of parameters.
  787. int paramCount = lua_gettop(state);
  788. // Attempt to match the parameters to a valid binding.
  789. switch (paramCount)
  790. {
  791. case 2:
  792. {
  793. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  794. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  795. {
  796. // Get parameter 1 off the stack.
  797. const char* param1 = ScriptUtil::getString(2, false);
  798. Scene* instance = getInstance(state);
  799. instance->setId(param1);
  800. return 0;
  801. }
  802. else
  803. {
  804. lua_pushstring(state, "lua_Scene_setId - Failed to match the given parameters to a valid function signature.");
  805. lua_error(state);
  806. }
  807. break;
  808. }
  809. default:
  810. {
  811. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  812. lua_error(state);
  813. break;
  814. }
  815. }
  816. return 0;
  817. }
  818. int lua_Scene_static_createScene(lua_State* state)
  819. {
  820. // Get the number of parameters.
  821. int paramCount = lua_gettop(state);
  822. // Attempt to match the parameters to a valid binding.
  823. switch (paramCount)
  824. {
  825. case 0:
  826. {
  827. void* returnPtr = (void*)Scene::createScene();
  828. if (returnPtr)
  829. {
  830. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  831. object->instance = returnPtr;
  832. object->owns = false;
  833. luaL_getmetatable(state, "Scene");
  834. lua_setmetatable(state, -2);
  835. }
  836. else
  837. {
  838. lua_pushnil(state);
  839. }
  840. return 1;
  841. break;
  842. }
  843. default:
  844. {
  845. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  846. lua_error(state);
  847. break;
  848. }
  849. }
  850. return 0;
  851. }
  852. int lua_Scene_static_load(lua_State* state)
  853. {
  854. // Get the number of parameters.
  855. int paramCount = lua_gettop(state);
  856. // Attempt to match the parameters to a valid binding.
  857. switch (paramCount)
  858. {
  859. case 1:
  860. {
  861. if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
  862. {
  863. // Get parameter 1 off the stack.
  864. const char* param1 = ScriptUtil::getString(1, false);
  865. void* returnPtr = (void*)Scene::load(param1);
  866. if (returnPtr)
  867. {
  868. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  869. object->instance = returnPtr;
  870. object->owns = false;
  871. luaL_getmetatable(state, "Scene");
  872. lua_setmetatable(state, -2);
  873. }
  874. else
  875. {
  876. lua_pushnil(state);
  877. }
  878. return 1;
  879. }
  880. else
  881. {
  882. lua_pushstring(state, "lua_Scene_static_load - Failed to match the given parameters to a valid function signature.");
  883. lua_error(state);
  884. }
  885. break;
  886. }
  887. default:
  888. {
  889. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  890. lua_error(state);
  891. break;
  892. }
  893. }
  894. return 0;
  895. }
  896. int lua_Scene_visit(lua_State* state)
  897. {
  898. // Get the number of parameters.
  899. int paramCount = lua_gettop(state);
  900. // Attempt to match the parameters to a valid binding.
  901. switch (paramCount)
  902. {
  903. case 2:
  904. {
  905. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  906. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  907. {
  908. // Get parameter 1 off the stack.
  909. const char* param1 = ScriptUtil::getString(2, false);
  910. Scene* instance = getInstance(state);
  911. instance->visit(param1);
  912. return 0;
  913. }
  914. else
  915. {
  916. lua_pushstring(state, "lua_Scene_visit - Failed to match the given parameters to a valid function signature.");
  917. lua_error(state);
  918. }
  919. break;
  920. }
  921. default:
  922. {
  923. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  924. lua_error(state);
  925. break;
  926. }
  927. }
  928. return 0;
  929. }
  930. }