2
0

lua_AnimationClip.cpp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_AnimationClip.h"
  4. #include "Animation.h"
  5. #include "AnimationClip.h"
  6. #include "AnimationTarget.h"
  7. #include "Base.h"
  8. #include "Game.h"
  9. #include "Quaternion.h"
  10. #include "Ref.h"
  11. #include "lua_AnimationClipListenerEventType.h"
  12. namespace gameplay
  13. {
  14. void luaRegister_AnimationClip()
  15. {
  16. ScriptController* sc = ScriptController::getInstance();
  17. const luaL_Reg lua_members[] =
  18. {
  19. {"addBeginListener", lua_AnimationClip_addBeginListener},
  20. {"addEndListener", lua_AnimationClip_addEndListener},
  21. {"addListener", lua_AnimationClip_addListener},
  22. {"addRef", lua_AnimationClip_addRef},
  23. {"crossFade", lua_AnimationClip_crossFade},
  24. {"getActiveDuration", lua_AnimationClip_getActiveDuration},
  25. {"getAnimation", lua_AnimationClip_getAnimation},
  26. {"getBlendWeight", lua_AnimationClip_getBlendWeight},
  27. {"getDuration", lua_AnimationClip_getDuration},
  28. {"getElaspedTime", lua_AnimationClip_getElaspedTime},
  29. {"getEndTime", lua_AnimationClip_getEndTime},
  30. {"getId", lua_AnimationClip_getId},
  31. {"getRefCount", lua_AnimationClip_getRefCount},
  32. {"getRepeatCount", lua_AnimationClip_getRepeatCount},
  33. {"getSpeed", lua_AnimationClip_getSpeed},
  34. {"getStartTime", lua_AnimationClip_getStartTime},
  35. {"isPlaying", lua_AnimationClip_isPlaying},
  36. {"pause", lua_AnimationClip_pause},
  37. {"play", lua_AnimationClip_play},
  38. {"release", lua_AnimationClip_release},
  39. {"setActiveDuration", lua_AnimationClip_setActiveDuration},
  40. {"setBlendWeight", lua_AnimationClip_setBlendWeight},
  41. {"setRepeatCount", lua_AnimationClip_setRepeatCount},
  42. {"setSpeed", lua_AnimationClip_setSpeed},
  43. {"stop", lua_AnimationClip_stop},
  44. {NULL, NULL}
  45. };
  46. const luaL_Reg lua_statics[] =
  47. {
  48. {"REPEAT_INDEFINITE", lua_AnimationClip_static_REPEAT_INDEFINITE},
  49. {NULL, NULL}
  50. };
  51. std::vector<std::string> scopePath;
  52. sc->registerClass("AnimationClip", lua_members, NULL, lua_AnimationClip__gc, lua_statics, scopePath);
  53. }
  54. static AnimationClip* getInstance(lua_State* state)
  55. {
  56. void* userdata = luaL_checkudata(state, 1, "AnimationClip");
  57. luaL_argcheck(state, userdata != NULL, 1, "'AnimationClip' expected.");
  58. return (AnimationClip*)((ScriptController::LuaObject*)userdata)->instance;
  59. }
  60. int lua_AnimationClip__gc(lua_State* state)
  61. {
  62. // Get the number of parameters.
  63. int paramCount = lua_gettop(state);
  64. // Attempt to match the parameters to a valid binding.
  65. switch (paramCount)
  66. {
  67. case 1:
  68. {
  69. if ((lua_type(state, 1) == LUA_TUSERDATA))
  70. {
  71. void* userdata = luaL_checkudata(state, 1, "AnimationClip");
  72. luaL_argcheck(state, userdata != NULL, 1, "'AnimationClip' expected.");
  73. ScriptController::LuaObject* object = (ScriptController::LuaObject*)userdata;
  74. if (object->owns)
  75. {
  76. AnimationClip* instance = (AnimationClip*)object->instance;
  77. SAFE_RELEASE(instance);
  78. }
  79. return 0;
  80. }
  81. else
  82. {
  83. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  84. lua_error(state);
  85. }
  86. break;
  87. }
  88. default:
  89. {
  90. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  91. lua_error(state);
  92. break;
  93. }
  94. }
  95. return 0;
  96. }
  97. int lua_AnimationClip_addBeginListener(lua_State* state)
  98. {
  99. // Get the number of parameters.
  100. int paramCount = lua_gettop(state);
  101. // Attempt to match the parameters to a valid binding.
  102. switch (paramCount)
  103. {
  104. case 2:
  105. {
  106. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  107. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  108. {
  109. // Get parameter 1 off the stack.
  110. AnimationClip::Listener* param1 = ScriptController::getInstance()->getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false);
  111. AnimationClip* instance = getInstance(state);
  112. instance->addBeginListener(param1);
  113. return 0;
  114. }
  115. else
  116. {
  117. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  118. lua_error(state);
  119. }
  120. break;
  121. }
  122. default:
  123. {
  124. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  125. lua_error(state);
  126. break;
  127. }
  128. }
  129. return 0;
  130. }
  131. int lua_AnimationClip_addEndListener(lua_State* state)
  132. {
  133. // Get the number of parameters.
  134. int paramCount = lua_gettop(state);
  135. // Attempt to match the parameters to a valid binding.
  136. switch (paramCount)
  137. {
  138. case 2:
  139. {
  140. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  141. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  142. {
  143. // Get parameter 1 off the stack.
  144. AnimationClip::Listener* param1 = ScriptController::getInstance()->getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false);
  145. AnimationClip* instance = getInstance(state);
  146. instance->addEndListener(param1);
  147. return 0;
  148. }
  149. else
  150. {
  151. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  152. lua_error(state);
  153. }
  154. break;
  155. }
  156. default:
  157. {
  158. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  159. lua_error(state);
  160. break;
  161. }
  162. }
  163. return 0;
  164. }
  165. int lua_AnimationClip_addListener(lua_State* state)
  166. {
  167. // Get the number of parameters.
  168. int paramCount = lua_gettop(state);
  169. // Attempt to match the parameters to a valid binding.
  170. switch (paramCount)
  171. {
  172. case 3:
  173. {
  174. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  175. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  176. lua_type(state, 3) == LUA_TNUMBER)
  177. {
  178. // Get parameter 1 off the stack.
  179. AnimationClip::Listener* param1 = ScriptController::getInstance()->getObjectPointer<AnimationClip::Listener>(2, "AnimationClipListener", false);
  180. // Get parameter 2 off the stack.
  181. unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
  182. AnimationClip* instance = getInstance(state);
  183. instance->addListener(param1, param2);
  184. return 0;
  185. }
  186. else
  187. {
  188. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  189. lua_error(state);
  190. }
  191. break;
  192. }
  193. default:
  194. {
  195. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  196. lua_error(state);
  197. break;
  198. }
  199. }
  200. return 0;
  201. }
  202. int lua_AnimationClip_addRef(lua_State* state)
  203. {
  204. // Get the number of parameters.
  205. int paramCount = lua_gettop(state);
  206. // Attempt to match the parameters to a valid binding.
  207. switch (paramCount)
  208. {
  209. case 1:
  210. {
  211. if ((lua_type(state, 1) == LUA_TUSERDATA))
  212. {
  213. AnimationClip* instance = getInstance(state);
  214. instance->addRef();
  215. return 0;
  216. }
  217. else
  218. {
  219. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  220. lua_error(state);
  221. }
  222. break;
  223. }
  224. default:
  225. {
  226. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  227. lua_error(state);
  228. break;
  229. }
  230. }
  231. return 0;
  232. }
  233. int lua_AnimationClip_crossFade(lua_State* state)
  234. {
  235. // Get the number of parameters.
  236. int paramCount = lua_gettop(state);
  237. // Attempt to match the parameters to a valid binding.
  238. switch (paramCount)
  239. {
  240. case 3:
  241. {
  242. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  243. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  244. lua_type(state, 3) == LUA_TNUMBER)
  245. {
  246. // Get parameter 1 off the stack.
  247. AnimationClip* param1 = ScriptController::getInstance()->getObjectPointer<AnimationClip>(2, "AnimationClip", false);
  248. // Get parameter 2 off the stack.
  249. unsigned long param2 = (unsigned long)luaL_checkunsigned(state, 3);
  250. AnimationClip* instance = getInstance(state);
  251. instance->crossFade(param1, param2);
  252. return 0;
  253. }
  254. else
  255. {
  256. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  257. lua_error(state);
  258. }
  259. break;
  260. }
  261. default:
  262. {
  263. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  264. lua_error(state);
  265. break;
  266. }
  267. }
  268. return 0;
  269. }
  270. int lua_AnimationClip_getActiveDuration(lua_State* state)
  271. {
  272. // Get the number of parameters.
  273. int paramCount = lua_gettop(state);
  274. // Attempt to match the parameters to a valid binding.
  275. switch (paramCount)
  276. {
  277. case 1:
  278. {
  279. if ((lua_type(state, 1) == LUA_TUSERDATA))
  280. {
  281. AnimationClip* instance = getInstance(state);
  282. unsigned long result = instance->getActiveDuration();
  283. // Push the return value onto the stack.
  284. lua_pushunsigned(state, result);
  285. return 1;
  286. }
  287. else
  288. {
  289. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  290. lua_error(state);
  291. }
  292. break;
  293. }
  294. default:
  295. {
  296. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  297. lua_error(state);
  298. break;
  299. }
  300. }
  301. return 0;
  302. }
  303. int lua_AnimationClip_getAnimation(lua_State* state)
  304. {
  305. // Get the number of parameters.
  306. int paramCount = lua_gettop(state);
  307. // Attempt to match the parameters to a valid binding.
  308. switch (paramCount)
  309. {
  310. case 1:
  311. {
  312. if ((lua_type(state, 1) == LUA_TUSERDATA))
  313. {
  314. AnimationClip* instance = getInstance(state);
  315. void* returnPtr = (void*)instance->getAnimation();
  316. if (returnPtr)
  317. {
  318. ScriptController::LuaObject* object = (ScriptController::LuaObject*)lua_newuserdata(state, sizeof(ScriptController::LuaObject));
  319. object->instance = returnPtr;
  320. object->owns = false;
  321. luaL_getmetatable(state, "Animation");
  322. lua_setmetatable(state, -2);
  323. }
  324. else
  325. {
  326. lua_pushnil(state);
  327. }
  328. return 1;
  329. }
  330. else
  331. {
  332. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  333. lua_error(state);
  334. }
  335. break;
  336. }
  337. default:
  338. {
  339. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  340. lua_error(state);
  341. break;
  342. }
  343. }
  344. return 0;
  345. }
  346. int lua_AnimationClip_getBlendWeight(lua_State* state)
  347. {
  348. // Get the number of parameters.
  349. int paramCount = lua_gettop(state);
  350. // Attempt to match the parameters to a valid binding.
  351. switch (paramCount)
  352. {
  353. case 1:
  354. {
  355. if ((lua_type(state, 1) == LUA_TUSERDATA))
  356. {
  357. AnimationClip* instance = getInstance(state);
  358. float result = instance->getBlendWeight();
  359. // Push the return value onto the stack.
  360. lua_pushnumber(state, result);
  361. return 1;
  362. }
  363. else
  364. {
  365. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  366. lua_error(state);
  367. }
  368. break;
  369. }
  370. default:
  371. {
  372. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  373. lua_error(state);
  374. break;
  375. }
  376. }
  377. return 0;
  378. }
  379. int lua_AnimationClip_getDuration(lua_State* state)
  380. {
  381. // Get the number of parameters.
  382. int paramCount = lua_gettop(state);
  383. // Attempt to match the parameters to a valid binding.
  384. switch (paramCount)
  385. {
  386. case 1:
  387. {
  388. if ((lua_type(state, 1) == LUA_TUSERDATA))
  389. {
  390. AnimationClip* instance = getInstance(state);
  391. unsigned long result = instance->getDuration();
  392. // Push the return value onto the stack.
  393. lua_pushunsigned(state, result);
  394. return 1;
  395. }
  396. else
  397. {
  398. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  399. lua_error(state);
  400. }
  401. break;
  402. }
  403. default:
  404. {
  405. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  406. lua_error(state);
  407. break;
  408. }
  409. }
  410. return 0;
  411. }
  412. int lua_AnimationClip_getElaspedTime(lua_State* state)
  413. {
  414. // Get the number of parameters.
  415. int paramCount = lua_gettop(state);
  416. // Attempt to match the parameters to a valid binding.
  417. switch (paramCount)
  418. {
  419. case 1:
  420. {
  421. if ((lua_type(state, 1) == LUA_TUSERDATA))
  422. {
  423. AnimationClip* instance = getInstance(state);
  424. float result = instance->getElaspedTime();
  425. // Push the return value onto the stack.
  426. lua_pushnumber(state, result);
  427. return 1;
  428. }
  429. else
  430. {
  431. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  432. lua_error(state);
  433. }
  434. break;
  435. }
  436. default:
  437. {
  438. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  439. lua_error(state);
  440. break;
  441. }
  442. }
  443. return 0;
  444. }
  445. int lua_AnimationClip_getEndTime(lua_State* state)
  446. {
  447. // Get the number of parameters.
  448. int paramCount = lua_gettop(state);
  449. // Attempt to match the parameters to a valid binding.
  450. switch (paramCount)
  451. {
  452. case 1:
  453. {
  454. if ((lua_type(state, 1) == LUA_TUSERDATA))
  455. {
  456. AnimationClip* instance = getInstance(state);
  457. unsigned long result = instance->getEndTime();
  458. // Push the return value onto the stack.
  459. lua_pushunsigned(state, result);
  460. return 1;
  461. }
  462. else
  463. {
  464. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  465. lua_error(state);
  466. }
  467. break;
  468. }
  469. default:
  470. {
  471. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  472. lua_error(state);
  473. break;
  474. }
  475. }
  476. return 0;
  477. }
  478. int lua_AnimationClip_getId(lua_State* state)
  479. {
  480. // Get the number of parameters.
  481. int paramCount = lua_gettop(state);
  482. // Attempt to match the parameters to a valid binding.
  483. switch (paramCount)
  484. {
  485. case 1:
  486. {
  487. if ((lua_type(state, 1) == LUA_TUSERDATA))
  488. {
  489. AnimationClip* instance = getInstance(state);
  490. const char* result = instance->getId();
  491. // Push the return value onto the stack.
  492. lua_pushstring(state, result);
  493. return 1;
  494. }
  495. else
  496. {
  497. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  498. lua_error(state);
  499. }
  500. break;
  501. }
  502. default:
  503. {
  504. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  505. lua_error(state);
  506. break;
  507. }
  508. }
  509. return 0;
  510. }
  511. int lua_AnimationClip_getRefCount(lua_State* state)
  512. {
  513. // Get the number of parameters.
  514. int paramCount = lua_gettop(state);
  515. // Attempt to match the parameters to a valid binding.
  516. switch (paramCount)
  517. {
  518. case 1:
  519. {
  520. if ((lua_type(state, 1) == LUA_TUSERDATA))
  521. {
  522. AnimationClip* instance = getInstance(state);
  523. unsigned int result = instance->getRefCount();
  524. // Push the return value onto the stack.
  525. lua_pushunsigned(state, result);
  526. return 1;
  527. }
  528. else
  529. {
  530. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  531. lua_error(state);
  532. }
  533. break;
  534. }
  535. default:
  536. {
  537. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  538. lua_error(state);
  539. break;
  540. }
  541. }
  542. return 0;
  543. }
  544. int lua_AnimationClip_getRepeatCount(lua_State* state)
  545. {
  546. // Get the number of parameters.
  547. int paramCount = lua_gettop(state);
  548. // Attempt to match the parameters to a valid binding.
  549. switch (paramCount)
  550. {
  551. case 1:
  552. {
  553. if ((lua_type(state, 1) == LUA_TUSERDATA))
  554. {
  555. AnimationClip* instance = getInstance(state);
  556. float result = instance->getRepeatCount();
  557. // Push the return value onto the stack.
  558. lua_pushnumber(state, result);
  559. return 1;
  560. }
  561. else
  562. {
  563. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  564. lua_error(state);
  565. }
  566. break;
  567. }
  568. default:
  569. {
  570. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  571. lua_error(state);
  572. break;
  573. }
  574. }
  575. return 0;
  576. }
  577. int lua_AnimationClip_getSpeed(lua_State* state)
  578. {
  579. // Get the number of parameters.
  580. int paramCount = lua_gettop(state);
  581. // Attempt to match the parameters to a valid binding.
  582. switch (paramCount)
  583. {
  584. case 1:
  585. {
  586. if ((lua_type(state, 1) == LUA_TUSERDATA))
  587. {
  588. AnimationClip* instance = getInstance(state);
  589. float result = instance->getSpeed();
  590. // Push the return value onto the stack.
  591. lua_pushnumber(state, result);
  592. return 1;
  593. }
  594. else
  595. {
  596. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  597. lua_error(state);
  598. }
  599. break;
  600. }
  601. default:
  602. {
  603. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  604. lua_error(state);
  605. break;
  606. }
  607. }
  608. return 0;
  609. }
  610. int lua_AnimationClip_getStartTime(lua_State* state)
  611. {
  612. // Get the number of parameters.
  613. int paramCount = lua_gettop(state);
  614. // Attempt to match the parameters to a valid binding.
  615. switch (paramCount)
  616. {
  617. case 1:
  618. {
  619. if ((lua_type(state, 1) == LUA_TUSERDATA))
  620. {
  621. AnimationClip* instance = getInstance(state);
  622. unsigned long result = instance->getStartTime();
  623. // Push the return value onto the stack.
  624. lua_pushunsigned(state, result);
  625. return 1;
  626. }
  627. else
  628. {
  629. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  630. lua_error(state);
  631. }
  632. break;
  633. }
  634. default:
  635. {
  636. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  637. lua_error(state);
  638. break;
  639. }
  640. }
  641. return 0;
  642. }
  643. int lua_AnimationClip_isPlaying(lua_State* state)
  644. {
  645. // Get the number of parameters.
  646. int paramCount = lua_gettop(state);
  647. // Attempt to match the parameters to a valid binding.
  648. switch (paramCount)
  649. {
  650. case 1:
  651. {
  652. if ((lua_type(state, 1) == LUA_TUSERDATA))
  653. {
  654. AnimationClip* instance = getInstance(state);
  655. bool result = instance->isPlaying();
  656. // Push the return value onto the stack.
  657. lua_pushboolean(state, result);
  658. return 1;
  659. }
  660. else
  661. {
  662. lua_pushstring(state, "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_AnimationClip_pause(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 1:
  684. {
  685. if ((lua_type(state, 1) == LUA_TUSERDATA))
  686. {
  687. AnimationClip* instance = getInstance(state);
  688. instance->pause();
  689. return 0;
  690. }
  691. else
  692. {
  693. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  694. lua_error(state);
  695. }
  696. break;
  697. }
  698. default:
  699. {
  700. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  701. lua_error(state);
  702. break;
  703. }
  704. }
  705. return 0;
  706. }
  707. int lua_AnimationClip_play(lua_State* state)
  708. {
  709. // Get the number of parameters.
  710. int paramCount = lua_gettop(state);
  711. // Attempt to match the parameters to a valid binding.
  712. switch (paramCount)
  713. {
  714. case 1:
  715. {
  716. if ((lua_type(state, 1) == LUA_TUSERDATA))
  717. {
  718. AnimationClip* instance = getInstance(state);
  719. instance->play();
  720. return 0;
  721. }
  722. else
  723. {
  724. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  725. lua_error(state);
  726. }
  727. break;
  728. }
  729. default:
  730. {
  731. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  732. lua_error(state);
  733. break;
  734. }
  735. }
  736. return 0;
  737. }
  738. int lua_AnimationClip_release(lua_State* state)
  739. {
  740. // Get the number of parameters.
  741. int paramCount = lua_gettop(state);
  742. // Attempt to match the parameters to a valid binding.
  743. switch (paramCount)
  744. {
  745. case 1:
  746. {
  747. if ((lua_type(state, 1) == LUA_TUSERDATA))
  748. {
  749. AnimationClip* instance = getInstance(state);
  750. instance->release();
  751. return 0;
  752. }
  753. else
  754. {
  755. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  756. lua_error(state);
  757. }
  758. break;
  759. }
  760. default:
  761. {
  762. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  763. lua_error(state);
  764. break;
  765. }
  766. }
  767. return 0;
  768. }
  769. int lua_AnimationClip_setActiveDuration(lua_State* state)
  770. {
  771. // Get the number of parameters.
  772. int paramCount = lua_gettop(state);
  773. // Attempt to match the parameters to a valid binding.
  774. switch (paramCount)
  775. {
  776. case 2:
  777. {
  778. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  779. lua_type(state, 2) == LUA_TNUMBER)
  780. {
  781. // Get parameter 1 off the stack.
  782. unsigned long param1 = (unsigned long)luaL_checkunsigned(state, 2);
  783. AnimationClip* instance = getInstance(state);
  784. instance->setActiveDuration(param1);
  785. return 0;
  786. }
  787. else
  788. {
  789. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  790. lua_error(state);
  791. }
  792. break;
  793. }
  794. default:
  795. {
  796. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  797. lua_error(state);
  798. break;
  799. }
  800. }
  801. return 0;
  802. }
  803. int lua_AnimationClip_setBlendWeight(lua_State* state)
  804. {
  805. // Get the number of parameters.
  806. int paramCount = lua_gettop(state);
  807. // Attempt to match the parameters to a valid binding.
  808. switch (paramCount)
  809. {
  810. case 2:
  811. {
  812. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  813. lua_type(state, 2) == LUA_TNUMBER)
  814. {
  815. // Get parameter 1 off the stack.
  816. float param1 = (float)luaL_checknumber(state, 2);
  817. AnimationClip* instance = getInstance(state);
  818. instance->setBlendWeight(param1);
  819. return 0;
  820. }
  821. else
  822. {
  823. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  824. lua_error(state);
  825. }
  826. break;
  827. }
  828. default:
  829. {
  830. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  831. lua_error(state);
  832. break;
  833. }
  834. }
  835. return 0;
  836. }
  837. int lua_AnimationClip_setRepeatCount(lua_State* state)
  838. {
  839. // Get the number of parameters.
  840. int paramCount = lua_gettop(state);
  841. // Attempt to match the parameters to a valid binding.
  842. switch (paramCount)
  843. {
  844. case 2:
  845. {
  846. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  847. lua_type(state, 2) == LUA_TNUMBER)
  848. {
  849. // Get parameter 1 off the stack.
  850. float param1 = (float)luaL_checknumber(state, 2);
  851. AnimationClip* instance = getInstance(state);
  852. instance->setRepeatCount(param1);
  853. return 0;
  854. }
  855. else
  856. {
  857. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  858. lua_error(state);
  859. }
  860. break;
  861. }
  862. default:
  863. {
  864. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  865. lua_error(state);
  866. break;
  867. }
  868. }
  869. return 0;
  870. }
  871. int lua_AnimationClip_setSpeed(lua_State* state)
  872. {
  873. // Get the number of parameters.
  874. int paramCount = lua_gettop(state);
  875. // Attempt to match the parameters to a valid binding.
  876. switch (paramCount)
  877. {
  878. case 2:
  879. {
  880. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  881. lua_type(state, 2) == LUA_TNUMBER)
  882. {
  883. // Get parameter 1 off the stack.
  884. float param1 = (float)luaL_checknumber(state, 2);
  885. AnimationClip* instance = getInstance(state);
  886. instance->setSpeed(param1);
  887. return 0;
  888. }
  889. else
  890. {
  891. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  892. lua_error(state);
  893. }
  894. break;
  895. }
  896. default:
  897. {
  898. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  899. lua_error(state);
  900. break;
  901. }
  902. }
  903. return 0;
  904. }
  905. int lua_AnimationClip_static_REPEAT_INDEFINITE(lua_State* state)
  906. {
  907. // Validate the number of parameters.
  908. if (lua_gettop(state) > 0)
  909. {
  910. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  911. lua_error(state);
  912. }
  913. unsigned int result = AnimationClip::REPEAT_INDEFINITE;
  914. // Push the return value onto the stack.
  915. lua_pushunsigned(state, result);
  916. return 1;
  917. }
  918. int lua_AnimationClip_stop(lua_State* state)
  919. {
  920. // Get the number of parameters.
  921. int paramCount = lua_gettop(state);
  922. // Attempt to match the parameters to a valid binding.
  923. switch (paramCount)
  924. {
  925. case 1:
  926. {
  927. if ((lua_type(state, 1) == LUA_TUSERDATA))
  928. {
  929. AnimationClip* instance = getInstance(state);
  930. instance->stop();
  931. return 0;
  932. }
  933. else
  934. {
  935. lua_pushstring(state, "Failed to match the given parameters to a valid function signature.");
  936. lua_error(state);
  937. }
  938. break;
  939. }
  940. default:
  941. {
  942. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  943. lua_error(state);
  944. break;
  945. }
  946. }
  947. return 0;
  948. }
  949. }