/android/LGame-Android-0.2.9/src/com/badlogic/gdx/physics/box2d/joints/PrismaticJoint.java

http://loon-simple.googlecode.com/ · Java · 146 lines · 60 code · 30 blank · 56 comment · 0 complexity · 1e8ec7fe441dfca2fa182410608800e0 MD5 · raw file

  1. /*******************************************************************************
  2. * Copyright 2010 Mario Zechner (contact@badlogicgames.com)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
  5. * License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
  10. * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
  11. * governing permissions and limitations under the License.
  12. ******************************************************************************/
  13. package com.badlogic.gdx.physics.box2d.joints;
  14. import com.badlogic.gdx.physics.box2d.Joint;
  15. import com.badlogic.gdx.physics.box2d.World;
  16. /**
  17. * A prismatic joint. This joint provides one degree of freedom: translation along an axis fixed in body1. Relative rotation is
  18. * prevented. You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint
  19. * friction.
  20. */
  21. public class PrismaticJoint extends Joint {
  22. public PrismaticJoint (World world, long addr) {
  23. super(world, addr);
  24. }
  25. /**
  26. * Get the current joint translation, usually in meters.
  27. */
  28. public float getJointTranslation () {
  29. return jniGetJointTranslation(addr);
  30. }
  31. private native float jniGetJointTranslation (long addr);
  32. /**
  33. * Get the current joint translation speed, usually in meters per second.
  34. */
  35. public float getJointSpeed () {
  36. return jniGetJointSpeed(addr);
  37. }
  38. private native float jniGetJointSpeed (long addr);
  39. /**
  40. * Is the joint limit enabled?
  41. */
  42. public boolean isLimitEnabled () {
  43. return jniIsLimitEnabled(addr);
  44. }
  45. private native boolean jniIsLimitEnabled (long addr);
  46. /**
  47. * Enable/disable the joint limit.
  48. */
  49. public void enableLimit (boolean flag) {
  50. jniEnableLimit(addr, flag);
  51. }
  52. private native void jniEnableLimit (long addr, boolean flag);
  53. /**
  54. * Get the lower joint limit, usually in meters.
  55. */
  56. public float getLowerLimit () {
  57. return jniGetLowerLimit(addr);
  58. }
  59. private native float jniGetLowerLimit (long addr);
  60. /**
  61. * Get the upper joint limit, usually in meters.
  62. */
  63. public float getUpperLimit () {
  64. return jniGetUpperLimit(addr);
  65. }
  66. private native float jniGetUpperLimit (long addr);
  67. /**
  68. * Set the joint limits, usually in meters.
  69. */
  70. public void setLimits (float lower, float upper) {
  71. jniSetLimits(addr, lower, upper);
  72. }
  73. private native void jniSetLimits (long addr, float lower, float upper);
  74. /**
  75. * Is the joint motor enabled?
  76. */
  77. public boolean isMotorEnabled () {
  78. return jniIsMotorEnabled(addr);
  79. }
  80. private native boolean jniIsMotorEnabled (long addr);
  81. /**
  82. * Enable/disable the joint motor.
  83. */
  84. public void enableMotor (boolean flag) {
  85. jniEnableMotor(addr, flag);
  86. }
  87. private native void jniEnableMotor (long addr, boolean flag);
  88. /**
  89. * Set the motor speed, usually in meters per second.
  90. */
  91. public void setMotorSpeed (float speed) {
  92. jniSetMotorSpeed(addr, speed);
  93. }
  94. private native void jniSetMotorSpeed (long addr, float speed);
  95. /**
  96. * Get the motor speed, usually in meters per second.
  97. */
  98. public float getMotorSpeed () {
  99. return jniGetMotorSpeed(addr);
  100. }
  101. private native float jniGetMotorSpeed (long addr);
  102. /**
  103. * Set the maximum motor force, usually in N.
  104. */
  105. public void setMaxMotorForce (float force) {
  106. jniSetMaxMotorForce(addr, force);
  107. }
  108. private native void jniSetMaxMotorForce (long addr, float force);
  109. /**
  110. * Get the current motor force, usually in N.
  111. */
  112. public float getMotorForce () {
  113. return jniGetMotorForce(addr);
  114. }
  115. private native float jniGetMotorForce (long addr);
  116. }