lua_PhysicsRigidBody.cpp 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsRigidBody.h"
  4. #include "Animation.h"
  5. #include "AnimationTarget.h"
  6. #include "Base.h"
  7. #include "Game.h"
  8. #include "Image.h"
  9. #include "MeshPart.h"
  10. #include "Node.h"
  11. #include "PhysicsCollisionObject.h"
  12. #include "PhysicsController.h"
  13. #include "PhysicsRigidBody.h"
  14. #include "ScriptController.h"
  15. #include "ScriptTarget.h"
  16. #include "Transform.h"
  17. #include "lua_CurveInterpolationType.h"
  18. #include "lua_PhysicsCollisionObjectCollisionListenerEventType.h"
  19. #include "lua_PhysicsCollisionObjectType.h"
  20. #include "lua_PhysicsCollisionShapeType.h"
  21. namespace gameplay
  22. {
  23. void luaRegister_PhysicsRigidBody()
  24. {
  25. const luaL_Reg lua_members[] =
  26. {
  27. {"addCollisionListener", lua_PhysicsRigidBody_addCollisionListener},
  28. {"applyForce", lua_PhysicsRigidBody_applyForce},
  29. {"applyImpulse", lua_PhysicsRigidBody_applyImpulse},
  30. {"applyTorque", lua_PhysicsRigidBody_applyTorque},
  31. {"applyTorqueImpulse", lua_PhysicsRigidBody_applyTorqueImpulse},
  32. {"collidesWith", lua_PhysicsRigidBody_collidesWith},
  33. {"getAngularDamping", lua_PhysicsRigidBody_getAngularDamping},
  34. {"getAngularVelocity", lua_PhysicsRigidBody_getAngularVelocity},
  35. {"getAnisotropicFriction", lua_PhysicsRigidBody_getAnisotropicFriction},
  36. {"getCollisionShape", lua_PhysicsRigidBody_getCollisionShape},
  37. {"getFriction", lua_PhysicsRigidBody_getFriction},
  38. {"getGravity", lua_PhysicsRigidBody_getGravity},
  39. {"getHeight", lua_PhysicsRigidBody_getHeight},
  40. {"getLinearDamping", lua_PhysicsRigidBody_getLinearDamping},
  41. {"getLinearVelocity", lua_PhysicsRigidBody_getLinearVelocity},
  42. {"getMass", lua_PhysicsRigidBody_getMass},
  43. {"getNode", lua_PhysicsRigidBody_getNode},
  44. {"getRestitution", lua_PhysicsRigidBody_getRestitution},
  45. {"getShapeType", lua_PhysicsRigidBody_getShapeType},
  46. {"getType", lua_PhysicsRigidBody_getType},
  47. {"isDynamic", lua_PhysicsRigidBody_isDynamic},
  48. {"isEnabled", lua_PhysicsRigidBody_isEnabled},
  49. {"isKinematic", lua_PhysicsRigidBody_isKinematic},
  50. {"isStatic", lua_PhysicsRigidBody_isStatic},
  51. {"removeCollisionListener", lua_PhysicsRigidBody_removeCollisionListener},
  52. {"setAngularVelocity", lua_PhysicsRigidBody_setAngularVelocity},
  53. {"setAnisotropicFriction", lua_PhysicsRigidBody_setAnisotropicFriction},
  54. {"setDamping", lua_PhysicsRigidBody_setDamping},
  55. {"setEnabled", lua_PhysicsRigidBody_setEnabled},
  56. {"setFriction", lua_PhysicsRigidBody_setFriction},
  57. {"setGravity", lua_PhysicsRigidBody_setGravity},
  58. {"setKinematic", lua_PhysicsRigidBody_setKinematic},
  59. {"setLinearVelocity", lua_PhysicsRigidBody_setLinearVelocity},
  60. {"setRestitution", lua_PhysicsRigidBody_setRestitution},
  61. {NULL, NULL}
  62. };
  63. const luaL_Reg* lua_statics = NULL;
  64. std::vector<std::string> scopePath;
  65. ScriptUtil::registerClass("PhysicsRigidBody", lua_members, NULL, NULL, lua_statics, scopePath);
  66. }
  67. static PhysicsRigidBody* getInstance(lua_State* state)
  68. {
  69. void* userdata = luaL_checkudata(state, 1, "PhysicsRigidBody");
  70. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsRigidBody' expected.");
  71. return (PhysicsRigidBody*)((ScriptUtil::LuaObject*)userdata)->instance;
  72. }
  73. int lua_PhysicsRigidBody_addCollisionListener(lua_State* state)
  74. {
  75. // Get the number of parameters.
  76. int paramCount = lua_gettop(state);
  77. // Attempt to match the parameters to a valid binding.
  78. switch (paramCount)
  79. {
  80. case 2:
  81. {
  82. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  83. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  84. {
  85. // Get parameter 1 off the stack.
  86. PhysicsCollisionObject::CollisionListener* param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject::CollisionListener>(2, "PhysicsCollisionObjectCollisionListener", false);
  87. PhysicsRigidBody* instance = getInstance(state);
  88. instance->addCollisionListener(param1);
  89. return 0;
  90. }
  91. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  92. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  93. {
  94. // Get parameter 1 off the stack.
  95. const char* param1 = ScriptUtil::getString(2, false);
  96. PhysicsRigidBody* instance = getInstance(state);
  97. instance->addCollisionListener(param1);
  98. return 0;
  99. }
  100. else
  101. {
  102. lua_pushstring(state, "lua_PhysicsRigidBody_addCollisionListener - Failed to match the given parameters to a valid function signature.");
  103. lua_error(state);
  104. }
  105. break;
  106. }
  107. case 3:
  108. {
  109. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  110. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  111. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  112. {
  113. // Get parameter 1 off the stack.
  114. PhysicsCollisionObject::CollisionListener* param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject::CollisionListener>(2, "PhysicsCollisionObjectCollisionListener", false);
  115. // Get parameter 2 off the stack.
  116. PhysicsCollisionObject* param2 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(3, "PhysicsCollisionObject", false);
  117. PhysicsRigidBody* instance = getInstance(state);
  118. instance->addCollisionListener(param1, param2);
  119. return 0;
  120. }
  121. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  122. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  123. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  124. {
  125. // Get parameter 1 off the stack.
  126. const char* param1 = ScriptUtil::getString(2, false);
  127. // Get parameter 2 off the stack.
  128. PhysicsCollisionObject* param2 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(3, "PhysicsCollisionObject", false);
  129. PhysicsRigidBody* instance = getInstance(state);
  130. instance->addCollisionListener(param1, param2);
  131. return 0;
  132. }
  133. else
  134. {
  135. lua_pushstring(state, "lua_PhysicsRigidBody_addCollisionListener - Failed to match the given parameters to a valid function signature.");
  136. lua_error(state);
  137. }
  138. break;
  139. }
  140. default:
  141. {
  142. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  143. lua_error(state);
  144. break;
  145. }
  146. }
  147. return 0;
  148. }
  149. int lua_PhysicsRigidBody_applyForce(lua_State* state)
  150. {
  151. // Get the number of parameters.
  152. int paramCount = lua_gettop(state);
  153. // Attempt to match the parameters to a valid binding.
  154. switch (paramCount)
  155. {
  156. case 2:
  157. {
  158. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  159. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  160. {
  161. // Get parameter 1 off the stack.
  162. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  163. PhysicsRigidBody* instance = getInstance(state);
  164. instance->applyForce(*param1);
  165. return 0;
  166. }
  167. else
  168. {
  169. lua_pushstring(state, "lua_PhysicsRigidBody_applyForce - Failed to match the given parameters to a valid function signature.");
  170. lua_error(state);
  171. }
  172. break;
  173. }
  174. case 3:
  175. {
  176. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  177. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  178. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  179. {
  180. // Get parameter 1 off the stack.
  181. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  182. // Get parameter 2 off the stack.
  183. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", false);
  184. PhysicsRigidBody* instance = getInstance(state);
  185. instance->applyForce(*param1, param2);
  186. return 0;
  187. }
  188. else
  189. {
  190. lua_pushstring(state, "lua_PhysicsRigidBody_applyForce - Failed to match the given parameters to a valid function signature.");
  191. lua_error(state);
  192. }
  193. break;
  194. }
  195. default:
  196. {
  197. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  198. lua_error(state);
  199. break;
  200. }
  201. }
  202. return 0;
  203. }
  204. int lua_PhysicsRigidBody_applyImpulse(lua_State* state)
  205. {
  206. // Get the number of parameters.
  207. int paramCount = lua_gettop(state);
  208. // Attempt to match the parameters to a valid binding.
  209. switch (paramCount)
  210. {
  211. case 2:
  212. {
  213. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  214. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  215. {
  216. // Get parameter 1 off the stack.
  217. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  218. PhysicsRigidBody* instance = getInstance(state);
  219. instance->applyImpulse(*param1);
  220. return 0;
  221. }
  222. else
  223. {
  224. lua_pushstring(state, "lua_PhysicsRigidBody_applyImpulse - Failed to match the given parameters to a valid function signature.");
  225. lua_error(state);
  226. }
  227. break;
  228. }
  229. case 3:
  230. {
  231. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  232. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  233. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  234. {
  235. // Get parameter 1 off the stack.
  236. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  237. // Get parameter 2 off the stack.
  238. Vector3* param2 = ScriptUtil::getObjectPointer<Vector3>(3, "Vector3", false);
  239. PhysicsRigidBody* instance = getInstance(state);
  240. instance->applyImpulse(*param1, param2);
  241. return 0;
  242. }
  243. else
  244. {
  245. lua_pushstring(state, "lua_PhysicsRigidBody_applyImpulse - Failed to match the given parameters to a valid function signature.");
  246. lua_error(state);
  247. }
  248. break;
  249. }
  250. default:
  251. {
  252. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  253. lua_error(state);
  254. break;
  255. }
  256. }
  257. return 0;
  258. }
  259. int lua_PhysicsRigidBody_applyTorque(lua_State* state)
  260. {
  261. // Get the number of parameters.
  262. int paramCount = lua_gettop(state);
  263. // Attempt to match the parameters to a valid binding.
  264. switch (paramCount)
  265. {
  266. case 2:
  267. {
  268. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  269. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  270. {
  271. // Get parameter 1 off the stack.
  272. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  273. PhysicsRigidBody* instance = getInstance(state);
  274. instance->applyTorque(*param1);
  275. return 0;
  276. }
  277. else
  278. {
  279. lua_pushstring(state, "lua_PhysicsRigidBody_applyTorque - 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 2).");
  287. lua_error(state);
  288. break;
  289. }
  290. }
  291. return 0;
  292. }
  293. int lua_PhysicsRigidBody_applyTorqueImpulse(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 2:
  301. {
  302. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  303. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  304. {
  305. // Get parameter 1 off the stack.
  306. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  307. PhysicsRigidBody* instance = getInstance(state);
  308. instance->applyTorqueImpulse(*param1);
  309. return 0;
  310. }
  311. else
  312. {
  313. lua_pushstring(state, "lua_PhysicsRigidBody_applyTorqueImpulse - Failed to match the given parameters to a valid function signature.");
  314. lua_error(state);
  315. }
  316. break;
  317. }
  318. default:
  319. {
  320. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  321. lua_error(state);
  322. break;
  323. }
  324. }
  325. return 0;
  326. }
  327. int lua_PhysicsRigidBody_collidesWith(lua_State* state)
  328. {
  329. // Get the number of parameters.
  330. int paramCount = lua_gettop(state);
  331. // Attempt to match the parameters to a valid binding.
  332. switch (paramCount)
  333. {
  334. case 2:
  335. {
  336. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  337. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  338. {
  339. // Get parameter 1 off the stack.
  340. PhysicsCollisionObject* param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(2, "PhysicsCollisionObject", false);
  341. PhysicsRigidBody* instance = getInstance(state);
  342. bool result = instance->collidesWith(param1);
  343. // Push the return value onto the stack.
  344. lua_pushboolean(state, result);
  345. return 1;
  346. }
  347. else
  348. {
  349. lua_pushstring(state, "lua_PhysicsRigidBody_collidesWith - Failed to match the given parameters to a valid function signature.");
  350. lua_error(state);
  351. }
  352. break;
  353. }
  354. default:
  355. {
  356. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  357. lua_error(state);
  358. break;
  359. }
  360. }
  361. return 0;
  362. }
  363. int lua_PhysicsRigidBody_getAngularDamping(lua_State* state)
  364. {
  365. // Get the number of parameters.
  366. int paramCount = lua_gettop(state);
  367. // Attempt to match the parameters to a valid binding.
  368. switch (paramCount)
  369. {
  370. case 1:
  371. {
  372. if ((lua_type(state, 1) == LUA_TUSERDATA))
  373. {
  374. PhysicsRigidBody* instance = getInstance(state);
  375. float result = instance->getAngularDamping();
  376. // Push the return value onto the stack.
  377. lua_pushnumber(state, result);
  378. return 1;
  379. }
  380. else
  381. {
  382. lua_pushstring(state, "lua_PhysicsRigidBody_getAngularDamping - Failed to match the given parameters to a valid function signature.");
  383. lua_error(state);
  384. }
  385. break;
  386. }
  387. default:
  388. {
  389. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  390. lua_error(state);
  391. break;
  392. }
  393. }
  394. return 0;
  395. }
  396. int lua_PhysicsRigidBody_getAngularVelocity(lua_State* state)
  397. {
  398. // Get the number of parameters.
  399. int paramCount = lua_gettop(state);
  400. // Attempt to match the parameters to a valid binding.
  401. switch (paramCount)
  402. {
  403. case 1:
  404. {
  405. if ((lua_type(state, 1) == LUA_TUSERDATA))
  406. {
  407. PhysicsRigidBody* instance = getInstance(state);
  408. void* returnPtr = (void*)new Vector3(instance->getAngularVelocity());
  409. if (returnPtr)
  410. {
  411. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  412. object->instance = returnPtr;
  413. object->owns = true;
  414. luaL_getmetatable(state, "Vector3");
  415. lua_setmetatable(state, -2);
  416. }
  417. else
  418. {
  419. lua_pushnil(state);
  420. }
  421. return 1;
  422. }
  423. else
  424. {
  425. lua_pushstring(state, "lua_PhysicsRigidBody_getAngularVelocity - Failed to match the given parameters to a valid function signature.");
  426. lua_error(state);
  427. }
  428. break;
  429. }
  430. default:
  431. {
  432. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  433. lua_error(state);
  434. break;
  435. }
  436. }
  437. return 0;
  438. }
  439. int lua_PhysicsRigidBody_getAnisotropicFriction(lua_State* state)
  440. {
  441. // Get the number of parameters.
  442. int paramCount = lua_gettop(state);
  443. // Attempt to match the parameters to a valid binding.
  444. switch (paramCount)
  445. {
  446. case 1:
  447. {
  448. if ((lua_type(state, 1) == LUA_TUSERDATA))
  449. {
  450. PhysicsRigidBody* instance = getInstance(state);
  451. void* returnPtr = (void*)new Vector3(instance->getAnisotropicFriction());
  452. if (returnPtr)
  453. {
  454. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  455. object->instance = returnPtr;
  456. object->owns = true;
  457. luaL_getmetatable(state, "Vector3");
  458. lua_setmetatable(state, -2);
  459. }
  460. else
  461. {
  462. lua_pushnil(state);
  463. }
  464. return 1;
  465. }
  466. else
  467. {
  468. lua_pushstring(state, "lua_PhysicsRigidBody_getAnisotropicFriction - Failed to match the given parameters to a valid function signature.");
  469. lua_error(state);
  470. }
  471. break;
  472. }
  473. default:
  474. {
  475. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  476. lua_error(state);
  477. break;
  478. }
  479. }
  480. return 0;
  481. }
  482. int lua_PhysicsRigidBody_getCollisionShape(lua_State* state)
  483. {
  484. // Get the number of parameters.
  485. int paramCount = lua_gettop(state);
  486. // Attempt to match the parameters to a valid binding.
  487. switch (paramCount)
  488. {
  489. case 1:
  490. {
  491. if ((lua_type(state, 1) == LUA_TUSERDATA))
  492. {
  493. PhysicsRigidBody* instance = getInstance(state);
  494. void* returnPtr = (void*)instance->getCollisionShape();
  495. if (returnPtr)
  496. {
  497. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  498. object->instance = returnPtr;
  499. object->owns = false;
  500. luaL_getmetatable(state, "PhysicsCollisionShape");
  501. lua_setmetatable(state, -2);
  502. }
  503. else
  504. {
  505. lua_pushnil(state);
  506. }
  507. return 1;
  508. }
  509. else
  510. {
  511. lua_pushstring(state, "lua_PhysicsRigidBody_getCollisionShape - Failed to match the given parameters to a valid function signature.");
  512. lua_error(state);
  513. }
  514. break;
  515. }
  516. default:
  517. {
  518. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  519. lua_error(state);
  520. break;
  521. }
  522. }
  523. return 0;
  524. }
  525. int lua_PhysicsRigidBody_getFriction(lua_State* state)
  526. {
  527. // Get the number of parameters.
  528. int paramCount = lua_gettop(state);
  529. // Attempt to match the parameters to a valid binding.
  530. switch (paramCount)
  531. {
  532. case 1:
  533. {
  534. if ((lua_type(state, 1) == LUA_TUSERDATA))
  535. {
  536. PhysicsRigidBody* instance = getInstance(state);
  537. float result = instance->getFriction();
  538. // Push the return value onto the stack.
  539. lua_pushnumber(state, result);
  540. return 1;
  541. }
  542. else
  543. {
  544. lua_pushstring(state, "lua_PhysicsRigidBody_getFriction - Failed to match the given parameters to a valid function signature.");
  545. lua_error(state);
  546. }
  547. break;
  548. }
  549. default:
  550. {
  551. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  552. lua_error(state);
  553. break;
  554. }
  555. }
  556. return 0;
  557. }
  558. int lua_PhysicsRigidBody_getGravity(lua_State* state)
  559. {
  560. // Get the number of parameters.
  561. int paramCount = lua_gettop(state);
  562. // Attempt to match the parameters to a valid binding.
  563. switch (paramCount)
  564. {
  565. case 1:
  566. {
  567. if ((lua_type(state, 1) == LUA_TUSERDATA))
  568. {
  569. PhysicsRigidBody* instance = getInstance(state);
  570. void* returnPtr = (void*)new Vector3(instance->getGravity());
  571. if (returnPtr)
  572. {
  573. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  574. object->instance = returnPtr;
  575. object->owns = true;
  576. luaL_getmetatable(state, "Vector3");
  577. lua_setmetatable(state, -2);
  578. }
  579. else
  580. {
  581. lua_pushnil(state);
  582. }
  583. return 1;
  584. }
  585. else
  586. {
  587. lua_pushstring(state, "lua_PhysicsRigidBody_getGravity - Failed to match the given parameters to a valid function signature.");
  588. lua_error(state);
  589. }
  590. break;
  591. }
  592. default:
  593. {
  594. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  595. lua_error(state);
  596. break;
  597. }
  598. }
  599. return 0;
  600. }
  601. int lua_PhysicsRigidBody_getHeight(lua_State* state)
  602. {
  603. // Get the number of parameters.
  604. int paramCount = lua_gettop(state);
  605. // Attempt to match the parameters to a valid binding.
  606. switch (paramCount)
  607. {
  608. case 3:
  609. {
  610. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  611. lua_type(state, 2) == LUA_TNUMBER &&
  612. lua_type(state, 3) == LUA_TNUMBER)
  613. {
  614. // Get parameter 1 off the stack.
  615. float param1 = (float)luaL_checknumber(state, 2);
  616. // Get parameter 2 off the stack.
  617. float param2 = (float)luaL_checknumber(state, 3);
  618. PhysicsRigidBody* instance = getInstance(state);
  619. float result = instance->getHeight(param1, param2);
  620. // Push the return value onto the stack.
  621. lua_pushnumber(state, result);
  622. return 1;
  623. }
  624. else
  625. {
  626. lua_pushstring(state, "lua_PhysicsRigidBody_getHeight - Failed to match the given parameters to a valid function signature.");
  627. lua_error(state);
  628. }
  629. break;
  630. }
  631. case 4:
  632. {
  633. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  634. lua_type(state, 2) == LUA_TNUMBER &&
  635. lua_type(state, 3) == LUA_TNUMBER &&
  636. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL))
  637. {
  638. // Get parameter 1 off the stack.
  639. float param1 = (float)luaL_checknumber(state, 2);
  640. // Get parameter 2 off the stack.
  641. float param2 = (float)luaL_checknumber(state, 3);
  642. // Get parameter 3 off the stack.
  643. Vector3* param3 = ScriptUtil::getObjectPointer<Vector3>(4, "Vector3", false);
  644. PhysicsRigidBody* instance = getInstance(state);
  645. float result = instance->getHeight(param1, param2, param3);
  646. // Push the return value onto the stack.
  647. lua_pushnumber(state, result);
  648. return 1;
  649. }
  650. else
  651. {
  652. lua_pushstring(state, "lua_PhysicsRigidBody_getHeight - Failed to match the given parameters to a valid function signature.");
  653. lua_error(state);
  654. }
  655. break;
  656. }
  657. default:
  658. {
  659. lua_pushstring(state, "Invalid number of parameters (expected 3 or 4).");
  660. lua_error(state);
  661. break;
  662. }
  663. }
  664. return 0;
  665. }
  666. int lua_PhysicsRigidBody_getLinearDamping(lua_State* state)
  667. {
  668. // Get the number of parameters.
  669. int paramCount = lua_gettop(state);
  670. // Attempt to match the parameters to a valid binding.
  671. switch (paramCount)
  672. {
  673. case 1:
  674. {
  675. if ((lua_type(state, 1) == LUA_TUSERDATA))
  676. {
  677. PhysicsRigidBody* instance = getInstance(state);
  678. float result = instance->getLinearDamping();
  679. // Push the return value onto the stack.
  680. lua_pushnumber(state, result);
  681. return 1;
  682. }
  683. else
  684. {
  685. lua_pushstring(state, "lua_PhysicsRigidBody_getLinearDamping - Failed to match the given parameters to a valid function signature.");
  686. lua_error(state);
  687. }
  688. break;
  689. }
  690. default:
  691. {
  692. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  693. lua_error(state);
  694. break;
  695. }
  696. }
  697. return 0;
  698. }
  699. int lua_PhysicsRigidBody_getLinearVelocity(lua_State* state)
  700. {
  701. // Get the number of parameters.
  702. int paramCount = lua_gettop(state);
  703. // Attempt to match the parameters to a valid binding.
  704. switch (paramCount)
  705. {
  706. case 1:
  707. {
  708. if ((lua_type(state, 1) == LUA_TUSERDATA))
  709. {
  710. PhysicsRigidBody* instance = getInstance(state);
  711. void* returnPtr = (void*)new Vector3(instance->getLinearVelocity());
  712. if (returnPtr)
  713. {
  714. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  715. object->instance = returnPtr;
  716. object->owns = true;
  717. luaL_getmetatable(state, "Vector3");
  718. lua_setmetatable(state, -2);
  719. }
  720. else
  721. {
  722. lua_pushnil(state);
  723. }
  724. return 1;
  725. }
  726. else
  727. {
  728. lua_pushstring(state, "lua_PhysicsRigidBody_getLinearVelocity - Failed to match the given parameters to a valid function signature.");
  729. lua_error(state);
  730. }
  731. break;
  732. }
  733. default:
  734. {
  735. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  736. lua_error(state);
  737. break;
  738. }
  739. }
  740. return 0;
  741. }
  742. int lua_PhysicsRigidBody_getMass(lua_State* state)
  743. {
  744. // Get the number of parameters.
  745. int paramCount = lua_gettop(state);
  746. // Attempt to match the parameters to a valid binding.
  747. switch (paramCount)
  748. {
  749. case 1:
  750. {
  751. if ((lua_type(state, 1) == LUA_TUSERDATA))
  752. {
  753. PhysicsRigidBody* instance = getInstance(state);
  754. float result = instance->getMass();
  755. // Push the return value onto the stack.
  756. lua_pushnumber(state, result);
  757. return 1;
  758. }
  759. else
  760. {
  761. lua_pushstring(state, "lua_PhysicsRigidBody_getMass - Failed to match the given parameters to a valid function signature.");
  762. lua_error(state);
  763. }
  764. break;
  765. }
  766. default:
  767. {
  768. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  769. lua_error(state);
  770. break;
  771. }
  772. }
  773. return 0;
  774. }
  775. int lua_PhysicsRigidBody_getNode(lua_State* state)
  776. {
  777. // Get the number of parameters.
  778. int paramCount = lua_gettop(state);
  779. // Attempt to match the parameters to a valid binding.
  780. switch (paramCount)
  781. {
  782. case 1:
  783. {
  784. if ((lua_type(state, 1) == LUA_TUSERDATA))
  785. {
  786. PhysicsRigidBody* instance = getInstance(state);
  787. void* returnPtr = (void*)instance->getNode();
  788. if (returnPtr)
  789. {
  790. ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
  791. object->instance = returnPtr;
  792. object->owns = false;
  793. luaL_getmetatable(state, "Node");
  794. lua_setmetatable(state, -2);
  795. }
  796. else
  797. {
  798. lua_pushnil(state);
  799. }
  800. return 1;
  801. }
  802. else
  803. {
  804. lua_pushstring(state, "lua_PhysicsRigidBody_getNode - Failed to match the given parameters to a valid function signature.");
  805. lua_error(state);
  806. }
  807. break;
  808. }
  809. default:
  810. {
  811. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  812. lua_error(state);
  813. break;
  814. }
  815. }
  816. return 0;
  817. }
  818. int lua_PhysicsRigidBody_getRestitution(lua_State* state)
  819. {
  820. // Get the number of parameters.
  821. int paramCount = lua_gettop(state);
  822. // Attempt to match the parameters to a valid binding.
  823. switch (paramCount)
  824. {
  825. case 1:
  826. {
  827. if ((lua_type(state, 1) == LUA_TUSERDATA))
  828. {
  829. PhysicsRigidBody* instance = getInstance(state);
  830. float result = instance->getRestitution();
  831. // Push the return value onto the stack.
  832. lua_pushnumber(state, result);
  833. return 1;
  834. }
  835. else
  836. {
  837. lua_pushstring(state, "lua_PhysicsRigidBody_getRestitution - 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 1).");
  845. lua_error(state);
  846. break;
  847. }
  848. }
  849. return 0;
  850. }
  851. int lua_PhysicsRigidBody_getShapeType(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 1:
  859. {
  860. if ((lua_type(state, 1) == LUA_TUSERDATA))
  861. {
  862. PhysicsRigidBody* instance = getInstance(state);
  863. PhysicsCollisionShape::Type result = instance->getShapeType();
  864. // Push the return value onto the stack.
  865. lua_pushstring(state, lua_stringFromEnum_PhysicsCollisionShapeType(result));
  866. return 1;
  867. }
  868. else
  869. {
  870. lua_pushstring(state, "lua_PhysicsRigidBody_getShapeType - Failed to match the given parameters to a valid function signature.");
  871. lua_error(state);
  872. }
  873. break;
  874. }
  875. default:
  876. {
  877. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  878. lua_error(state);
  879. break;
  880. }
  881. }
  882. return 0;
  883. }
  884. int lua_PhysicsRigidBody_getType(lua_State* state)
  885. {
  886. // Get the number of parameters.
  887. int paramCount = lua_gettop(state);
  888. // Attempt to match the parameters to a valid binding.
  889. switch (paramCount)
  890. {
  891. case 1:
  892. {
  893. if ((lua_type(state, 1) == LUA_TUSERDATA))
  894. {
  895. PhysicsRigidBody* instance = getInstance(state);
  896. PhysicsCollisionObject::Type result = instance->getType();
  897. // Push the return value onto the stack.
  898. lua_pushstring(state, lua_stringFromEnum_PhysicsCollisionObjectType(result));
  899. return 1;
  900. }
  901. else
  902. {
  903. lua_pushstring(state, "lua_PhysicsRigidBody_getType - Failed to match the given parameters to a valid function signature.");
  904. lua_error(state);
  905. }
  906. break;
  907. }
  908. default:
  909. {
  910. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  911. lua_error(state);
  912. break;
  913. }
  914. }
  915. return 0;
  916. }
  917. int lua_PhysicsRigidBody_isDynamic(lua_State* state)
  918. {
  919. // Get the number of parameters.
  920. int paramCount = lua_gettop(state);
  921. // Attempt to match the parameters to a valid binding.
  922. switch (paramCount)
  923. {
  924. case 1:
  925. {
  926. if ((lua_type(state, 1) == LUA_TUSERDATA))
  927. {
  928. PhysicsRigidBody* instance = getInstance(state);
  929. bool result = instance->isDynamic();
  930. // Push the return value onto the stack.
  931. lua_pushboolean(state, result);
  932. return 1;
  933. }
  934. else
  935. {
  936. lua_pushstring(state, "lua_PhysicsRigidBody_isDynamic - Failed to match the given parameters to a valid function signature.");
  937. lua_error(state);
  938. }
  939. break;
  940. }
  941. default:
  942. {
  943. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  944. lua_error(state);
  945. break;
  946. }
  947. }
  948. return 0;
  949. }
  950. int lua_PhysicsRigidBody_isEnabled(lua_State* state)
  951. {
  952. // Get the number of parameters.
  953. int paramCount = lua_gettop(state);
  954. // Attempt to match the parameters to a valid binding.
  955. switch (paramCount)
  956. {
  957. case 1:
  958. {
  959. if ((lua_type(state, 1) == LUA_TUSERDATA))
  960. {
  961. PhysicsRigidBody* instance = getInstance(state);
  962. bool result = instance->isEnabled();
  963. // Push the return value onto the stack.
  964. lua_pushboolean(state, result);
  965. return 1;
  966. }
  967. else
  968. {
  969. lua_pushstring(state, "lua_PhysicsRigidBody_isEnabled - Failed to match the given parameters to a valid function signature.");
  970. lua_error(state);
  971. }
  972. break;
  973. }
  974. default:
  975. {
  976. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  977. lua_error(state);
  978. break;
  979. }
  980. }
  981. return 0;
  982. }
  983. int lua_PhysicsRigidBody_isKinematic(lua_State* state)
  984. {
  985. // Get the number of parameters.
  986. int paramCount = lua_gettop(state);
  987. // Attempt to match the parameters to a valid binding.
  988. switch (paramCount)
  989. {
  990. case 1:
  991. {
  992. if ((lua_type(state, 1) == LUA_TUSERDATA))
  993. {
  994. PhysicsRigidBody* instance = getInstance(state);
  995. bool result = instance->isKinematic();
  996. // Push the return value onto the stack.
  997. lua_pushboolean(state, result);
  998. return 1;
  999. }
  1000. else
  1001. {
  1002. lua_pushstring(state, "lua_PhysicsRigidBody_isKinematic - Failed to match the given parameters to a valid function signature.");
  1003. lua_error(state);
  1004. }
  1005. break;
  1006. }
  1007. default:
  1008. {
  1009. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1010. lua_error(state);
  1011. break;
  1012. }
  1013. }
  1014. return 0;
  1015. }
  1016. int lua_PhysicsRigidBody_isStatic(lua_State* state)
  1017. {
  1018. // Get the number of parameters.
  1019. int paramCount = lua_gettop(state);
  1020. // Attempt to match the parameters to a valid binding.
  1021. switch (paramCount)
  1022. {
  1023. case 1:
  1024. {
  1025. if ((lua_type(state, 1) == LUA_TUSERDATA))
  1026. {
  1027. PhysicsRigidBody* instance = getInstance(state);
  1028. bool result = instance->isStatic();
  1029. // Push the return value onto the stack.
  1030. lua_pushboolean(state, result);
  1031. return 1;
  1032. }
  1033. else
  1034. {
  1035. lua_pushstring(state, "lua_PhysicsRigidBody_isStatic - Failed to match the given parameters to a valid function signature.");
  1036. lua_error(state);
  1037. }
  1038. break;
  1039. }
  1040. default:
  1041. {
  1042. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  1043. lua_error(state);
  1044. break;
  1045. }
  1046. }
  1047. return 0;
  1048. }
  1049. int lua_PhysicsRigidBody_removeCollisionListener(lua_State* state)
  1050. {
  1051. // Get the number of parameters.
  1052. int paramCount = lua_gettop(state);
  1053. // Attempt to match the parameters to a valid binding.
  1054. switch (paramCount)
  1055. {
  1056. case 2:
  1057. {
  1058. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1059. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  1060. {
  1061. // Get parameter 1 off the stack.
  1062. PhysicsCollisionObject::CollisionListener* param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject::CollisionListener>(2, "PhysicsCollisionObjectCollisionListener", false);
  1063. PhysicsRigidBody* instance = getInstance(state);
  1064. instance->removeCollisionListener(param1);
  1065. return 0;
  1066. }
  1067. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1068. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
  1069. {
  1070. // Get parameter 1 off the stack.
  1071. const char* param1 = ScriptUtil::getString(2, false);
  1072. PhysicsRigidBody* instance = getInstance(state);
  1073. instance->removeCollisionListener(param1);
  1074. return 0;
  1075. }
  1076. else
  1077. {
  1078. lua_pushstring(state, "lua_PhysicsRigidBody_removeCollisionListener - Failed to match the given parameters to a valid function signature.");
  1079. lua_error(state);
  1080. }
  1081. break;
  1082. }
  1083. case 3:
  1084. {
  1085. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1086. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
  1087. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  1088. {
  1089. // Get parameter 1 off the stack.
  1090. PhysicsCollisionObject::CollisionListener* param1 = ScriptUtil::getObjectPointer<PhysicsCollisionObject::CollisionListener>(2, "PhysicsCollisionObjectCollisionListener", false);
  1091. // Get parameter 2 off the stack.
  1092. PhysicsCollisionObject* param2 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(3, "PhysicsCollisionObject", false);
  1093. PhysicsRigidBody* instance = getInstance(state);
  1094. instance->removeCollisionListener(param1, param2);
  1095. return 0;
  1096. }
  1097. else if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1098. (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
  1099. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  1100. {
  1101. // Get parameter 1 off the stack.
  1102. const char* param1 = ScriptUtil::getString(2, false);
  1103. // Get parameter 2 off the stack.
  1104. PhysicsCollisionObject* param2 = ScriptUtil::getObjectPointer<PhysicsCollisionObject>(3, "PhysicsCollisionObject", false);
  1105. PhysicsRigidBody* instance = getInstance(state);
  1106. instance->removeCollisionListener(param1, param2);
  1107. return 0;
  1108. }
  1109. else
  1110. {
  1111. lua_pushstring(state, "lua_PhysicsRigidBody_removeCollisionListener - Failed to match the given parameters to a valid function signature.");
  1112. lua_error(state);
  1113. }
  1114. break;
  1115. }
  1116. default:
  1117. {
  1118. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  1119. lua_error(state);
  1120. break;
  1121. }
  1122. }
  1123. return 0;
  1124. }
  1125. int lua_PhysicsRigidBody_setAngularVelocity(lua_State* state)
  1126. {
  1127. // Get the number of parameters.
  1128. int paramCount = lua_gettop(state);
  1129. // Attempt to match the parameters to a valid binding.
  1130. switch (paramCount)
  1131. {
  1132. case 2:
  1133. {
  1134. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1135. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1136. {
  1137. // Get parameter 1 off the stack.
  1138. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1139. PhysicsRigidBody* instance = getInstance(state);
  1140. instance->setAngularVelocity(*param1);
  1141. return 0;
  1142. }
  1143. else
  1144. {
  1145. lua_pushstring(state, "lua_PhysicsRigidBody_setAngularVelocity - Failed to match the given parameters to a valid function signature.");
  1146. lua_error(state);
  1147. }
  1148. break;
  1149. }
  1150. default:
  1151. {
  1152. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1153. lua_error(state);
  1154. break;
  1155. }
  1156. }
  1157. return 0;
  1158. }
  1159. int lua_PhysicsRigidBody_setAnisotropicFriction(lua_State* state)
  1160. {
  1161. // Get the number of parameters.
  1162. int paramCount = lua_gettop(state);
  1163. // Attempt to match the parameters to a valid binding.
  1164. switch (paramCount)
  1165. {
  1166. case 2:
  1167. {
  1168. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1169. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1170. {
  1171. // Get parameter 1 off the stack.
  1172. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1173. PhysicsRigidBody* instance = getInstance(state);
  1174. instance->setAnisotropicFriction(*param1);
  1175. return 0;
  1176. }
  1177. else
  1178. {
  1179. lua_pushstring(state, "lua_PhysicsRigidBody_setAnisotropicFriction - Failed to match the given parameters to a valid function signature.");
  1180. lua_error(state);
  1181. }
  1182. break;
  1183. }
  1184. default:
  1185. {
  1186. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1187. lua_error(state);
  1188. break;
  1189. }
  1190. }
  1191. return 0;
  1192. }
  1193. int lua_PhysicsRigidBody_setDamping(lua_State* state)
  1194. {
  1195. // Get the number of parameters.
  1196. int paramCount = lua_gettop(state);
  1197. // Attempt to match the parameters to a valid binding.
  1198. switch (paramCount)
  1199. {
  1200. case 3:
  1201. {
  1202. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1203. lua_type(state, 2) == LUA_TNUMBER &&
  1204. lua_type(state, 3) == LUA_TNUMBER)
  1205. {
  1206. // Get parameter 1 off the stack.
  1207. float param1 = (float)luaL_checknumber(state, 2);
  1208. // Get parameter 2 off the stack.
  1209. float param2 = (float)luaL_checknumber(state, 3);
  1210. PhysicsRigidBody* instance = getInstance(state);
  1211. instance->setDamping(param1, param2);
  1212. return 0;
  1213. }
  1214. else
  1215. {
  1216. lua_pushstring(state, "lua_PhysicsRigidBody_setDamping - Failed to match the given parameters to a valid function signature.");
  1217. lua_error(state);
  1218. }
  1219. break;
  1220. }
  1221. default:
  1222. {
  1223. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1224. lua_error(state);
  1225. break;
  1226. }
  1227. }
  1228. return 0;
  1229. }
  1230. int lua_PhysicsRigidBody_setEnabled(lua_State* state)
  1231. {
  1232. // Get the number of parameters.
  1233. int paramCount = lua_gettop(state);
  1234. // Attempt to match the parameters to a valid binding.
  1235. switch (paramCount)
  1236. {
  1237. case 2:
  1238. {
  1239. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1240. lua_type(state, 2) == LUA_TBOOLEAN)
  1241. {
  1242. // Get parameter 1 off the stack.
  1243. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1244. PhysicsRigidBody* instance = getInstance(state);
  1245. instance->setEnabled(param1);
  1246. return 0;
  1247. }
  1248. else
  1249. {
  1250. lua_pushstring(state, "lua_PhysicsRigidBody_setEnabled - Failed to match the given parameters to a valid function signature.");
  1251. lua_error(state);
  1252. }
  1253. break;
  1254. }
  1255. default:
  1256. {
  1257. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1258. lua_error(state);
  1259. break;
  1260. }
  1261. }
  1262. return 0;
  1263. }
  1264. int lua_PhysicsRigidBody_setFriction(lua_State* state)
  1265. {
  1266. // Get the number of parameters.
  1267. int paramCount = lua_gettop(state);
  1268. // Attempt to match the parameters to a valid binding.
  1269. switch (paramCount)
  1270. {
  1271. case 2:
  1272. {
  1273. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1274. lua_type(state, 2) == LUA_TNUMBER)
  1275. {
  1276. // Get parameter 1 off the stack.
  1277. float param1 = (float)luaL_checknumber(state, 2);
  1278. PhysicsRigidBody* instance = getInstance(state);
  1279. instance->setFriction(param1);
  1280. return 0;
  1281. }
  1282. else
  1283. {
  1284. lua_pushstring(state, "lua_PhysicsRigidBody_setFriction - Failed to match the given parameters to a valid function signature.");
  1285. lua_error(state);
  1286. }
  1287. break;
  1288. }
  1289. default:
  1290. {
  1291. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1292. lua_error(state);
  1293. break;
  1294. }
  1295. }
  1296. return 0;
  1297. }
  1298. int lua_PhysicsRigidBody_setGravity(lua_State* state)
  1299. {
  1300. // Get the number of parameters.
  1301. int paramCount = lua_gettop(state);
  1302. // Attempt to match the parameters to a valid binding.
  1303. switch (paramCount)
  1304. {
  1305. case 2:
  1306. {
  1307. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1308. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1309. {
  1310. // Get parameter 1 off the stack.
  1311. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1312. PhysicsRigidBody* instance = getInstance(state);
  1313. instance->setGravity(*param1);
  1314. return 0;
  1315. }
  1316. else
  1317. {
  1318. lua_pushstring(state, "lua_PhysicsRigidBody_setGravity - Failed to match the given parameters to a valid function signature.");
  1319. lua_error(state);
  1320. }
  1321. break;
  1322. }
  1323. default:
  1324. {
  1325. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1326. lua_error(state);
  1327. break;
  1328. }
  1329. }
  1330. return 0;
  1331. }
  1332. int lua_PhysicsRigidBody_setKinematic(lua_State* state)
  1333. {
  1334. // Get the number of parameters.
  1335. int paramCount = lua_gettop(state);
  1336. // Attempt to match the parameters to a valid binding.
  1337. switch (paramCount)
  1338. {
  1339. case 2:
  1340. {
  1341. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1342. lua_type(state, 2) == LUA_TBOOLEAN)
  1343. {
  1344. // Get parameter 1 off the stack.
  1345. bool param1 = ScriptUtil::luaCheckBool(state, 2);
  1346. PhysicsRigidBody* instance = getInstance(state);
  1347. instance->setKinematic(param1);
  1348. return 0;
  1349. }
  1350. else
  1351. {
  1352. lua_pushstring(state, "lua_PhysicsRigidBody_setKinematic - Failed to match the given parameters to a valid function signature.");
  1353. lua_error(state);
  1354. }
  1355. break;
  1356. }
  1357. default:
  1358. {
  1359. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1360. lua_error(state);
  1361. break;
  1362. }
  1363. }
  1364. return 0;
  1365. }
  1366. int lua_PhysicsRigidBody_setLinearVelocity(lua_State* state)
  1367. {
  1368. // Get the number of parameters.
  1369. int paramCount = lua_gettop(state);
  1370. // Attempt to match the parameters to a valid binding.
  1371. switch (paramCount)
  1372. {
  1373. case 2:
  1374. {
  1375. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1376. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1377. {
  1378. // Get parameter 1 off the stack.
  1379. Vector3* param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
  1380. PhysicsRigidBody* instance = getInstance(state);
  1381. instance->setLinearVelocity(*param1);
  1382. return 0;
  1383. }
  1384. else
  1385. {
  1386. lua_pushstring(state, "lua_PhysicsRigidBody_setLinearVelocity - Failed to match the given parameters to a valid function signature.");
  1387. lua_error(state);
  1388. }
  1389. break;
  1390. }
  1391. default:
  1392. {
  1393. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1394. lua_error(state);
  1395. break;
  1396. }
  1397. }
  1398. return 0;
  1399. }
  1400. int lua_PhysicsRigidBody_setRestitution(lua_State* state)
  1401. {
  1402. // Get the number of parameters.
  1403. int paramCount = lua_gettop(state);
  1404. // Attempt to match the parameters to a valid binding.
  1405. switch (paramCount)
  1406. {
  1407. case 2:
  1408. {
  1409. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1410. lua_type(state, 2) == LUA_TNUMBER)
  1411. {
  1412. // Get parameter 1 off the stack.
  1413. float param1 = (float)luaL_checknumber(state, 2);
  1414. PhysicsRigidBody* instance = getInstance(state);
  1415. instance->setRestitution(param1);
  1416. return 0;
  1417. }
  1418. else
  1419. {
  1420. lua_pushstring(state, "lua_PhysicsRigidBody_setRestitution - Failed to match the given parameters to a valid function signature.");
  1421. lua_error(state);
  1422. }
  1423. break;
  1424. }
  1425. default:
  1426. {
  1427. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1428. lua_error(state);
  1429. break;
  1430. }
  1431. }
  1432. return 0;
  1433. }
  1434. }