wrap_PrismaticJoint.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * Copyright (c) 2006-2011 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #include "wrap_PrismaticJoint.h"
  21. namespace love
  22. {
  23. namespace physics
  24. {
  25. namespace box2d
  26. {
  27. PrismaticJoint * luax_checkprismaticjoint(lua_State * L, int idx)
  28. {
  29. return luax_checktype<PrismaticJoint>(L, idx, "PrismaticJoint", PHYSICS_PRISMATIC_JOINT_T);
  30. }
  31. int w_PrismaticJoint_getJointTranslation(lua_State * L)
  32. {
  33. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  34. lua_pushnumber(L, t->getJointTranslation());
  35. return 1;
  36. }
  37. int w_PrismaticJoint_getJointSpeed(lua_State * L)
  38. {
  39. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  40. lua_pushnumber(L, t->getJointSpeed());
  41. return 1;
  42. }
  43. int w_PrismaticJoint_enableMotor(lua_State * L)
  44. {
  45. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  46. bool arg1 = luax_toboolean(L, 2);
  47. t->enableMotor(arg1);
  48. return 0;
  49. }
  50. int w_PrismaticJoint_isMotorEnabled(lua_State * L)
  51. {
  52. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  53. luax_pushboolean(L, t->isMotorEnabled());
  54. return 1;
  55. }
  56. int w_PrismaticJoint_setMaxMotorForce(lua_State * L)
  57. {
  58. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  59. float arg1 = (float)luaL_checknumber(L, 2);
  60. t->setMaxMotorForce(arg1);
  61. return 0;
  62. }
  63. int w_PrismaticJoint_setMotorSpeed(lua_State * L)
  64. {
  65. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  66. float arg1 = (float)luaL_checknumber(L, 2);
  67. t->setMotorSpeed(arg1);
  68. return 0;
  69. }
  70. int w_PrismaticJoint_getMotorSpeed(lua_State * L)
  71. {
  72. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  73. lua_pushnumber(L, t->getMotorSpeed());
  74. return 1;
  75. }
  76. int w_PrismaticJoint_getMotorForce(lua_State * L)
  77. {
  78. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  79. float inv_dt = (float)luaL_checknumber(L, 2);
  80. lua_pushnumber(L, t->getMotorForce(inv_dt));
  81. return 1;
  82. }
  83. int w_PrismaticJoint_getMaxMotorForce(lua_State * L)
  84. {
  85. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  86. lua_pushnumber(L, t->getMaxMotorForce());
  87. return 1;
  88. }
  89. int w_PrismaticJoint_enableLimit(lua_State * L)
  90. {
  91. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  92. bool arg1 = luax_toboolean(L, 2);
  93. t->enableLimit(arg1);
  94. return 0;
  95. }
  96. int w_PrismaticJoint_isLimitEnabled(lua_State * L)
  97. {
  98. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  99. luax_pushboolean(L, t->isLimitEnabled());
  100. return 1;
  101. }
  102. int w_PrismaticJoint_setUpperLimit(lua_State * L)
  103. {
  104. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  105. float arg1 = (float)luaL_checknumber(L, 2);
  106. t->setUpperLimit(arg1);
  107. return 0;
  108. }
  109. int w_PrismaticJoint_setLowerLimit(lua_State * L)
  110. {
  111. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  112. float arg1 = (float)luaL_checknumber(L, 2);
  113. t->setLowerLimit(arg1);
  114. return 0;
  115. }
  116. int w_PrismaticJoint_setLimits(lua_State * L)
  117. {
  118. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  119. float arg1 = (float)luaL_checknumber(L, 2);
  120. float arg2 = (float)luaL_checknumber(L, 3);
  121. t->setLimits(arg1, arg2);
  122. return 0;
  123. }
  124. int w_PrismaticJoint_getLowerLimit(lua_State * L)
  125. {
  126. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  127. lua_pushnumber(L, t->getLowerLimit());
  128. return 1;
  129. }
  130. int w_PrismaticJoint_getUpperLimit(lua_State * L)
  131. {
  132. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  133. lua_pushnumber(L, t->getUpperLimit());
  134. return 1;
  135. }
  136. int w_PrismaticJoint_getLimits(lua_State * L)
  137. {
  138. PrismaticJoint * t = luax_checkprismaticjoint(L, 1);
  139. lua_remove(L, 1);
  140. return t->getLimits(L);
  141. }
  142. static const luaL_Reg functions[] = {
  143. { "getJointTranslation", w_PrismaticJoint_getJointTranslation },
  144. { "getJointSpeed", w_PrismaticJoint_getJointSpeed },
  145. { "enableMotor", w_PrismaticJoint_enableMotor },
  146. { "isMotorEnabled", w_PrismaticJoint_isMotorEnabled },
  147. { "setMaxMotorForce", w_PrismaticJoint_setMaxMotorForce },
  148. { "setMotorSpeed", w_PrismaticJoint_setMotorSpeed },
  149. { "getMotorSpeed", w_PrismaticJoint_getMotorSpeed },
  150. { "getMotorForce", w_PrismaticJoint_getMotorForce },
  151. { "getMaxMotorForce", w_PrismaticJoint_getMaxMotorForce },
  152. { "enableLimit", w_PrismaticJoint_enableLimit },
  153. { "isLimitEnabled", w_PrismaticJoint_isLimitEnabled },
  154. { "setUpperLimit", w_PrismaticJoint_setUpperLimit },
  155. { "setLowerLimit", w_PrismaticJoint_setLowerLimit },
  156. { "setLimits", w_PrismaticJoint_setLimits },
  157. { "getLowerLimit", w_PrismaticJoint_getLowerLimit },
  158. { "getUpperLimit", w_PrismaticJoint_getUpperLimit },
  159. { "getLimits", w_PrismaticJoint_getLimits },
  160. // From Joint.
  161. { "getType", w_Joint_getType },
  162. { "getAnchors", w_Joint_getAnchors },
  163. { "getReactionForce", w_Joint_getReactionForce },
  164. { "getReactionTorque", w_Joint_getReactionTorque },
  165. { "getCollideConnected", w_Joint_getCollideConnected },
  166. { "destroy", w_Joint_destroy },
  167. { 0, 0 }
  168. };
  169. int luaopen_prismaticjoint(lua_State * L)
  170. {
  171. return luax_register_type(L, "PrismaticJoint", functions);
  172. }
  173. } // box2d
  174. } // physics
  175. } // love