lua_PhysicsCharacter.cpp 37 KB

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