lua_PhysicsRigidBodyParameters.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_PhysicsRigidBodyParameters.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 "PhysicsCharacter.h"
  12. #include "PhysicsCollisionObject.h"
  13. #include "PhysicsController.h"
  14. #include "PhysicsGhostObject.h"
  15. #include "PhysicsRigidBody.h"
  16. #include "PhysicsVehicle.h"
  17. #include "PhysicsVehicleWheel.h"
  18. #include "ScriptController.h"
  19. #include "ScriptTarget.h"
  20. #include "Terrain.h"
  21. #include "Transform.h"
  22. #include "lua_CurveInterpolationType.h"
  23. #include "lua_PhysicsCollisionObjectCollisionListenerEventType.h"
  24. #include "lua_PhysicsCollisionObjectType.h"
  25. #include "lua_PhysicsCollisionShapeType.h"
  26. namespace gameplay
  27. {
  28. void luaRegister_PhysicsRigidBodyParameters()
  29. {
  30. const luaL_Reg lua_members[] =
  31. {
  32. {"angularDamping", lua_PhysicsRigidBodyParameters_angularDamping},
  33. {"angularFactor", lua_PhysicsRigidBodyParameters_angularFactor},
  34. {"anisotropicFriction", lua_PhysicsRigidBodyParameters_anisotropicFriction},
  35. {"friction", lua_PhysicsRigidBodyParameters_friction},
  36. {"kinematic", lua_PhysicsRigidBodyParameters_kinematic},
  37. {"linearDamping", lua_PhysicsRigidBodyParameters_linearDamping},
  38. {"linearFactor", lua_PhysicsRigidBodyParameters_linearFactor},
  39. {"mass", lua_PhysicsRigidBodyParameters_mass},
  40. {"restitution", lua_PhysicsRigidBodyParameters_restitution},
  41. {NULL, NULL}
  42. };
  43. const luaL_Reg* lua_statics = NULL;
  44. std::vector<std::string> scopePath;
  45. scopePath.push_back("PhysicsRigidBody");
  46. gameplay::ScriptUtil::registerClass("PhysicsRigidBodyParameters", lua_members, lua_PhysicsRigidBodyParameters__init, lua_PhysicsRigidBodyParameters__gc, lua_statics, scopePath);
  47. }
  48. static PhysicsRigidBody::Parameters* getInstance(lua_State* state)
  49. {
  50. void* userdata = luaL_checkudata(state, 1, "PhysicsRigidBodyParameters");
  51. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsRigidBodyParameters' expected.");
  52. return (PhysicsRigidBody::Parameters*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  53. }
  54. int lua_PhysicsRigidBodyParameters__gc(lua_State* state)
  55. {
  56. // Get the number of parameters.
  57. int paramCount = lua_gettop(state);
  58. // Attempt to match the parameters to a valid binding.
  59. switch (paramCount)
  60. {
  61. case 1:
  62. {
  63. if ((lua_type(state, 1) == LUA_TUSERDATA))
  64. {
  65. void* userdata = luaL_checkudata(state, 1, "PhysicsRigidBodyParameters");
  66. luaL_argcheck(state, userdata != NULL, 1, "'PhysicsRigidBodyParameters' expected.");
  67. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  68. if (object->owns)
  69. {
  70. PhysicsRigidBody::Parameters* instance = (PhysicsRigidBody::Parameters*)object->instance;
  71. SAFE_DELETE(instance);
  72. }
  73. return 0;
  74. }
  75. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__gc - Failed to match the given parameters to a valid function signature.");
  76. lua_error(state);
  77. break;
  78. }
  79. default:
  80. {
  81. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  82. lua_error(state);
  83. break;
  84. }
  85. }
  86. return 0;
  87. }
  88. int lua_PhysicsRigidBodyParameters__init(lua_State* state)
  89. {
  90. // Get the number of parameters.
  91. int paramCount = lua_gettop(state);
  92. // Attempt to match the parameters to a valid binding.
  93. switch (paramCount)
  94. {
  95. case 0:
  96. {
  97. void* returnPtr = (void*)new PhysicsRigidBody::Parameters();
  98. if (returnPtr)
  99. {
  100. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  101. object->instance = returnPtr;
  102. object->owns = true;
  103. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  104. lua_setmetatable(state, -2);
  105. }
  106. else
  107. {
  108. lua_pushnil(state);
  109. }
  110. return 1;
  111. break;
  112. }
  113. case 1:
  114. {
  115. do
  116. {
  117. if (lua_type(state, 1) == LUA_TNUMBER)
  118. {
  119. // Get parameter 1 off the stack.
  120. float param1 = (float)luaL_checknumber(state, 1);
  121. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1);
  122. if (returnPtr)
  123. {
  124. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  125. object->instance = returnPtr;
  126. object->owns = true;
  127. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  128. lua_setmetatable(state, -2);
  129. }
  130. else
  131. {
  132. lua_pushnil(state);
  133. }
  134. return 1;
  135. }
  136. } while (0);
  137. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  138. lua_error(state);
  139. break;
  140. }
  141. case 2:
  142. {
  143. do
  144. {
  145. if (lua_type(state, 1) == LUA_TNUMBER &&
  146. lua_type(state, 2) == LUA_TNUMBER)
  147. {
  148. // Get parameter 1 off the stack.
  149. float param1 = (float)luaL_checknumber(state, 1);
  150. // Get parameter 2 off the stack.
  151. float param2 = (float)luaL_checknumber(state, 2);
  152. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2);
  153. if (returnPtr)
  154. {
  155. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  156. object->instance = returnPtr;
  157. object->owns = true;
  158. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  159. lua_setmetatable(state, -2);
  160. }
  161. else
  162. {
  163. lua_pushnil(state);
  164. }
  165. return 1;
  166. }
  167. } while (0);
  168. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  169. lua_error(state);
  170. break;
  171. }
  172. case 3:
  173. {
  174. do
  175. {
  176. if (lua_type(state, 1) == LUA_TNUMBER &&
  177. lua_type(state, 2) == LUA_TNUMBER &&
  178. lua_type(state, 3) == LUA_TNUMBER)
  179. {
  180. // Get parameter 1 off the stack.
  181. float param1 = (float)luaL_checknumber(state, 1);
  182. // Get parameter 2 off the stack.
  183. float param2 = (float)luaL_checknumber(state, 2);
  184. // Get parameter 3 off the stack.
  185. float param3 = (float)luaL_checknumber(state, 3);
  186. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3);
  187. if (returnPtr)
  188. {
  189. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  190. object->instance = returnPtr;
  191. object->owns = true;
  192. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  193. lua_setmetatable(state, -2);
  194. }
  195. else
  196. {
  197. lua_pushnil(state);
  198. }
  199. return 1;
  200. }
  201. } while (0);
  202. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  203. lua_error(state);
  204. break;
  205. }
  206. case 4:
  207. {
  208. do
  209. {
  210. if (lua_type(state, 1) == LUA_TNUMBER &&
  211. lua_type(state, 2) == LUA_TNUMBER &&
  212. lua_type(state, 3) == LUA_TNUMBER &&
  213. lua_type(state, 4) == LUA_TNUMBER)
  214. {
  215. // Get parameter 1 off the stack.
  216. float param1 = (float)luaL_checknumber(state, 1);
  217. // Get parameter 2 off the stack.
  218. float param2 = (float)luaL_checknumber(state, 2);
  219. // Get parameter 3 off the stack.
  220. float param3 = (float)luaL_checknumber(state, 3);
  221. // Get parameter 4 off the stack.
  222. float param4 = (float)luaL_checknumber(state, 4);
  223. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4);
  224. if (returnPtr)
  225. {
  226. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  227. object->instance = returnPtr;
  228. object->owns = true;
  229. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  230. lua_setmetatable(state, -2);
  231. }
  232. else
  233. {
  234. lua_pushnil(state);
  235. }
  236. return 1;
  237. }
  238. } while (0);
  239. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  240. lua_error(state);
  241. break;
  242. }
  243. case 5:
  244. {
  245. do
  246. {
  247. if (lua_type(state, 1) == LUA_TNUMBER &&
  248. lua_type(state, 2) == LUA_TNUMBER &&
  249. lua_type(state, 3) == LUA_TNUMBER &&
  250. lua_type(state, 4) == LUA_TNUMBER &&
  251. lua_type(state, 5) == LUA_TNUMBER)
  252. {
  253. // Get parameter 1 off the stack.
  254. float param1 = (float)luaL_checknumber(state, 1);
  255. // Get parameter 2 off the stack.
  256. float param2 = (float)luaL_checknumber(state, 2);
  257. // Get parameter 3 off the stack.
  258. float param3 = (float)luaL_checknumber(state, 3);
  259. // Get parameter 4 off the stack.
  260. float param4 = (float)luaL_checknumber(state, 4);
  261. // Get parameter 5 off the stack.
  262. float param5 = (float)luaL_checknumber(state, 5);
  263. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5);
  264. if (returnPtr)
  265. {
  266. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  267. object->instance = returnPtr;
  268. object->owns = true;
  269. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  270. lua_setmetatable(state, -2);
  271. }
  272. else
  273. {
  274. lua_pushnil(state);
  275. }
  276. return 1;
  277. }
  278. } while (0);
  279. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  280. lua_error(state);
  281. break;
  282. }
  283. case 6:
  284. {
  285. do
  286. {
  287. if (lua_type(state, 1) == LUA_TNUMBER &&
  288. lua_type(state, 2) == LUA_TNUMBER &&
  289. lua_type(state, 3) == LUA_TNUMBER &&
  290. lua_type(state, 4) == LUA_TNUMBER &&
  291. lua_type(state, 5) == LUA_TNUMBER &&
  292. lua_type(state, 6) == LUA_TBOOLEAN)
  293. {
  294. // Get parameter 1 off the stack.
  295. float param1 = (float)luaL_checknumber(state, 1);
  296. // Get parameter 2 off the stack.
  297. float param2 = (float)luaL_checknumber(state, 2);
  298. // Get parameter 3 off the stack.
  299. float param3 = (float)luaL_checknumber(state, 3);
  300. // Get parameter 4 off the stack.
  301. float param4 = (float)luaL_checknumber(state, 4);
  302. // Get parameter 5 off the stack.
  303. float param5 = (float)luaL_checknumber(state, 5);
  304. // Get parameter 6 off the stack.
  305. bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 6);
  306. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6);
  307. if (returnPtr)
  308. {
  309. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  310. object->instance = returnPtr;
  311. object->owns = true;
  312. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  313. lua_setmetatable(state, -2);
  314. }
  315. else
  316. {
  317. lua_pushnil(state);
  318. }
  319. return 1;
  320. }
  321. } while (0);
  322. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  323. lua_error(state);
  324. break;
  325. }
  326. case 7:
  327. {
  328. do
  329. {
  330. if (lua_type(state, 1) == LUA_TNUMBER &&
  331. lua_type(state, 2) == LUA_TNUMBER &&
  332. lua_type(state, 3) == LUA_TNUMBER &&
  333. lua_type(state, 4) == LUA_TNUMBER &&
  334. lua_type(state, 5) == LUA_TNUMBER &&
  335. lua_type(state, 6) == LUA_TBOOLEAN &&
  336. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL))
  337. {
  338. // Get parameter 1 off the stack.
  339. float param1 = (float)luaL_checknumber(state, 1);
  340. // Get parameter 2 off the stack.
  341. float param2 = (float)luaL_checknumber(state, 2);
  342. // Get parameter 3 off the stack.
  343. float param3 = (float)luaL_checknumber(state, 3);
  344. // Get parameter 4 off the stack.
  345. float param4 = (float)luaL_checknumber(state, 4);
  346. // Get parameter 5 off the stack.
  347. float param5 = (float)luaL_checknumber(state, 5);
  348. // Get parameter 6 off the stack.
  349. bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 6);
  350. // Get parameter 7 off the stack.
  351. bool param7Valid;
  352. gameplay::ScriptUtil::LuaArray<Vector3> param7 = gameplay::ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true, &param7Valid);
  353. if (!param7Valid)
  354. break;
  355. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6, *param7);
  356. if (returnPtr)
  357. {
  358. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  359. object->instance = returnPtr;
  360. object->owns = true;
  361. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  362. lua_setmetatable(state, -2);
  363. }
  364. else
  365. {
  366. lua_pushnil(state);
  367. }
  368. return 1;
  369. }
  370. } while (0);
  371. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  372. lua_error(state);
  373. break;
  374. }
  375. case 8:
  376. {
  377. do
  378. {
  379. if (lua_type(state, 1) == LUA_TNUMBER &&
  380. lua_type(state, 2) == LUA_TNUMBER &&
  381. lua_type(state, 3) == LUA_TNUMBER &&
  382. lua_type(state, 4) == LUA_TNUMBER &&
  383. lua_type(state, 5) == LUA_TNUMBER &&
  384. lua_type(state, 6) == LUA_TBOOLEAN &&
  385. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL) &&
  386. (lua_type(state, 8) == LUA_TUSERDATA || lua_type(state, 8) == LUA_TNIL))
  387. {
  388. // Get parameter 1 off the stack.
  389. float param1 = (float)luaL_checknumber(state, 1);
  390. // Get parameter 2 off the stack.
  391. float param2 = (float)luaL_checknumber(state, 2);
  392. // Get parameter 3 off the stack.
  393. float param3 = (float)luaL_checknumber(state, 3);
  394. // Get parameter 4 off the stack.
  395. float param4 = (float)luaL_checknumber(state, 4);
  396. // Get parameter 5 off the stack.
  397. float param5 = (float)luaL_checknumber(state, 5);
  398. // Get parameter 6 off the stack.
  399. bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 6);
  400. // Get parameter 7 off the stack.
  401. bool param7Valid;
  402. gameplay::ScriptUtil::LuaArray<Vector3> param7 = gameplay::ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true, &param7Valid);
  403. if (!param7Valid)
  404. break;
  405. // Get parameter 8 off the stack.
  406. bool param8Valid;
  407. gameplay::ScriptUtil::LuaArray<Vector3> param8 = gameplay::ScriptUtil::getObjectPointer<Vector3>(8, "Vector3", true, &param8Valid);
  408. if (!param8Valid)
  409. break;
  410. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6, *param7, *param8);
  411. if (returnPtr)
  412. {
  413. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  414. object->instance = returnPtr;
  415. object->owns = true;
  416. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  417. lua_setmetatable(state, -2);
  418. }
  419. else
  420. {
  421. lua_pushnil(state);
  422. }
  423. return 1;
  424. }
  425. } while (0);
  426. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  427. lua_error(state);
  428. break;
  429. }
  430. case 9:
  431. {
  432. do
  433. {
  434. if (lua_type(state, 1) == LUA_TNUMBER &&
  435. lua_type(state, 2) == LUA_TNUMBER &&
  436. lua_type(state, 3) == LUA_TNUMBER &&
  437. lua_type(state, 4) == LUA_TNUMBER &&
  438. lua_type(state, 5) == LUA_TNUMBER &&
  439. lua_type(state, 6) == LUA_TBOOLEAN &&
  440. (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL) &&
  441. (lua_type(state, 8) == LUA_TUSERDATA || lua_type(state, 8) == LUA_TNIL) &&
  442. (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL))
  443. {
  444. // Get parameter 1 off the stack.
  445. float param1 = (float)luaL_checknumber(state, 1);
  446. // Get parameter 2 off the stack.
  447. float param2 = (float)luaL_checknumber(state, 2);
  448. // Get parameter 3 off the stack.
  449. float param3 = (float)luaL_checknumber(state, 3);
  450. // Get parameter 4 off the stack.
  451. float param4 = (float)luaL_checknumber(state, 4);
  452. // Get parameter 5 off the stack.
  453. float param5 = (float)luaL_checknumber(state, 5);
  454. // Get parameter 6 off the stack.
  455. bool param6 = gameplay::ScriptUtil::luaCheckBool(state, 6);
  456. // Get parameter 7 off the stack.
  457. bool param7Valid;
  458. gameplay::ScriptUtil::LuaArray<Vector3> param7 = gameplay::ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true, &param7Valid);
  459. if (!param7Valid)
  460. break;
  461. // Get parameter 8 off the stack.
  462. bool param8Valid;
  463. gameplay::ScriptUtil::LuaArray<Vector3> param8 = gameplay::ScriptUtil::getObjectPointer<Vector3>(8, "Vector3", true, &param8Valid);
  464. if (!param8Valid)
  465. break;
  466. // Get parameter 9 off the stack.
  467. bool param9Valid;
  468. gameplay::ScriptUtil::LuaArray<Vector3> param9 = gameplay::ScriptUtil::getObjectPointer<Vector3>(9, "Vector3", true, &param9Valid);
  469. if (!param9Valid)
  470. break;
  471. void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6, *param7, *param8, *param9);
  472. if (returnPtr)
  473. {
  474. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  475. object->instance = returnPtr;
  476. object->owns = true;
  477. luaL_getmetatable(state, "PhysicsRigidBodyParameters");
  478. lua_setmetatable(state, -2);
  479. }
  480. else
  481. {
  482. lua_pushnil(state);
  483. }
  484. return 1;
  485. }
  486. } while (0);
  487. lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
  488. lua_error(state);
  489. break;
  490. }
  491. default:
  492. {
  493. lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9).");
  494. lua_error(state);
  495. break;
  496. }
  497. }
  498. return 0;
  499. }
  500. int lua_PhysicsRigidBodyParameters_angularDamping(lua_State* state)
  501. {
  502. // Validate the number of parameters.
  503. if (lua_gettop(state) > 2)
  504. {
  505. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  506. lua_error(state);
  507. }
  508. PhysicsRigidBody::Parameters* instance = getInstance(state);
  509. if (lua_gettop(state) == 2)
  510. {
  511. // Get parameter 2 off the stack.
  512. float param2 = (float)luaL_checknumber(state, 2);
  513. instance->angularDamping = param2;
  514. return 0;
  515. }
  516. else
  517. {
  518. float result = instance->angularDamping;
  519. // Push the return value onto the stack.
  520. lua_pushnumber(state, result);
  521. return 1;
  522. }
  523. }
  524. int lua_PhysicsRigidBodyParameters_angularFactor(lua_State* state)
  525. {
  526. // Validate the number of parameters.
  527. if (lua_gettop(state) > 2)
  528. {
  529. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  530. lua_error(state);
  531. }
  532. PhysicsRigidBody::Parameters* instance = getInstance(state);
  533. if (lua_gettop(state) == 2)
  534. {
  535. // Get parameter 2 off the stack.
  536. bool param2Valid;
  537. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  538. if (!param2Valid)
  539. {
  540. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector3'.");
  541. lua_error(state);
  542. }
  543. instance->angularFactor = *param2;
  544. return 0;
  545. }
  546. else
  547. {
  548. void* returnPtr = (void*)new Vector3(instance->angularFactor);
  549. if (returnPtr)
  550. {
  551. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  552. object->instance = returnPtr;
  553. object->owns = true;
  554. luaL_getmetatable(state, "Vector3");
  555. lua_setmetatable(state, -2);
  556. }
  557. else
  558. {
  559. lua_pushnil(state);
  560. }
  561. return 1;
  562. }
  563. }
  564. int lua_PhysicsRigidBodyParameters_anisotropicFriction(lua_State* state)
  565. {
  566. // Validate the number of parameters.
  567. if (lua_gettop(state) > 2)
  568. {
  569. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  570. lua_error(state);
  571. }
  572. PhysicsRigidBody::Parameters* instance = getInstance(state);
  573. if (lua_gettop(state) == 2)
  574. {
  575. // Get parameter 2 off the stack.
  576. bool param2Valid;
  577. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  578. if (!param2Valid)
  579. {
  580. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector3'.");
  581. lua_error(state);
  582. }
  583. instance->anisotropicFriction = *param2;
  584. return 0;
  585. }
  586. else
  587. {
  588. void* returnPtr = (void*)new Vector3(instance->anisotropicFriction);
  589. if (returnPtr)
  590. {
  591. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  592. object->instance = returnPtr;
  593. object->owns = true;
  594. luaL_getmetatable(state, "Vector3");
  595. lua_setmetatable(state, -2);
  596. }
  597. else
  598. {
  599. lua_pushnil(state);
  600. }
  601. return 1;
  602. }
  603. }
  604. int lua_PhysicsRigidBodyParameters_friction(lua_State* state)
  605. {
  606. // Validate the number of parameters.
  607. if (lua_gettop(state) > 2)
  608. {
  609. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  610. lua_error(state);
  611. }
  612. PhysicsRigidBody::Parameters* instance = getInstance(state);
  613. if (lua_gettop(state) == 2)
  614. {
  615. // Get parameter 2 off the stack.
  616. float param2 = (float)luaL_checknumber(state, 2);
  617. instance->friction = param2;
  618. return 0;
  619. }
  620. else
  621. {
  622. float result = instance->friction;
  623. // Push the return value onto the stack.
  624. lua_pushnumber(state, result);
  625. return 1;
  626. }
  627. }
  628. int lua_PhysicsRigidBodyParameters_kinematic(lua_State* state)
  629. {
  630. // Validate the number of parameters.
  631. if (lua_gettop(state) > 2)
  632. {
  633. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  634. lua_error(state);
  635. }
  636. PhysicsRigidBody::Parameters* instance = getInstance(state);
  637. if (lua_gettop(state) == 2)
  638. {
  639. // Get parameter 2 off the stack.
  640. bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  641. instance->kinematic = param2;
  642. return 0;
  643. }
  644. else
  645. {
  646. bool result = instance->kinematic;
  647. // Push the return value onto the stack.
  648. lua_pushboolean(state, result);
  649. return 1;
  650. }
  651. }
  652. int lua_PhysicsRigidBodyParameters_linearDamping(lua_State* state)
  653. {
  654. // Validate the number of parameters.
  655. if (lua_gettop(state) > 2)
  656. {
  657. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  658. lua_error(state);
  659. }
  660. PhysicsRigidBody::Parameters* instance = getInstance(state);
  661. if (lua_gettop(state) == 2)
  662. {
  663. // Get parameter 2 off the stack.
  664. float param2 = (float)luaL_checknumber(state, 2);
  665. instance->linearDamping = param2;
  666. return 0;
  667. }
  668. else
  669. {
  670. float result = instance->linearDamping;
  671. // Push the return value onto the stack.
  672. lua_pushnumber(state, result);
  673. return 1;
  674. }
  675. }
  676. int lua_PhysicsRigidBodyParameters_linearFactor(lua_State* state)
  677. {
  678. // Validate the number of parameters.
  679. if (lua_gettop(state) > 2)
  680. {
  681. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  682. lua_error(state);
  683. }
  684. PhysicsRigidBody::Parameters* instance = getInstance(state);
  685. if (lua_gettop(state) == 2)
  686. {
  687. // Get parameter 2 off the stack.
  688. bool param2Valid;
  689. gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
  690. if (!param2Valid)
  691. {
  692. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector3'.");
  693. lua_error(state);
  694. }
  695. instance->linearFactor = *param2;
  696. return 0;
  697. }
  698. else
  699. {
  700. void* returnPtr = (void*)new Vector3(instance->linearFactor);
  701. if (returnPtr)
  702. {
  703. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  704. object->instance = returnPtr;
  705. object->owns = true;
  706. luaL_getmetatable(state, "Vector3");
  707. lua_setmetatable(state, -2);
  708. }
  709. else
  710. {
  711. lua_pushnil(state);
  712. }
  713. return 1;
  714. }
  715. }
  716. int lua_PhysicsRigidBodyParameters_mass(lua_State* state)
  717. {
  718. // Validate the number of parameters.
  719. if (lua_gettop(state) > 2)
  720. {
  721. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  722. lua_error(state);
  723. }
  724. PhysicsRigidBody::Parameters* instance = getInstance(state);
  725. if (lua_gettop(state) == 2)
  726. {
  727. // Get parameter 2 off the stack.
  728. float param2 = (float)luaL_checknumber(state, 2);
  729. instance->mass = param2;
  730. return 0;
  731. }
  732. else
  733. {
  734. float result = instance->mass;
  735. // Push the return value onto the stack.
  736. lua_pushnumber(state, result);
  737. return 1;
  738. }
  739. }
  740. int lua_PhysicsRigidBodyParameters_restitution(lua_State* state)
  741. {
  742. // Validate the number of parameters.
  743. if (lua_gettop(state) > 2)
  744. {
  745. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  746. lua_error(state);
  747. }
  748. PhysicsRigidBody::Parameters* instance = getInstance(state);
  749. if (lua_gettop(state) == 2)
  750. {
  751. // Get parameter 2 off the stack.
  752. float param2 = (float)luaL_checknumber(state, 2);
  753. instance->restitution = param2;
  754. return 0;
  755. }
  756. else
  757. {
  758. float result = instance->restitution;
  759. // Push the return value onto the stack.
  760. lua_pushnumber(state, result);
  761. return 1;
  762. }
  763. }
  764. }