lua_PhysicsVehicle.cpp 35 KB

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