|
@@ -51,9 +51,7 @@ import java.util.logging.Level;
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
/**
|
|
|
- * <p>
|
|
|
- * PhysicsRigidBody - Basic physics object</p>
|
|
|
- *
|
|
|
+ * <p>PhysicsRigidBody - Basic physics object</p>
|
|
|
* @author normenhansen
|
|
|
*/
|
|
|
public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
@@ -68,7 +66,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Creates a new PhysicsRigidBody with the supplied collision shape
|
|
|
- *
|
|
|
* @param child
|
|
|
* @param shape
|
|
|
*/
|
|
@@ -137,7 +134,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the physics object location
|
|
|
- *
|
|
|
* @param location the location of the actual physics object
|
|
|
*/
|
|
|
public void setPhysicsLocation(Vector3f location) {
|
|
@@ -148,7 +144,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the physics object rotation
|
|
|
- *
|
|
|
* @param rotation the rotation of the actual physics object
|
|
|
*/
|
|
|
public void setPhysicsRotation(Matrix3f rotation) {
|
|
@@ -159,7 +154,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the physics object rotation
|
|
|
- *
|
|
|
* @param rotation the rotation of the actual physics object
|
|
|
*/
|
|
|
public void setPhysicsRotation(Quaternion rotation) {
|
|
@@ -255,10 +249,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
// return Converter.convert(tempTrans.basis, rotation);
|
|
|
// }
|
|
|
/**
|
|
|
- * Sets the node to kinematic mode. in this mode the node is not affected by
|
|
|
- * physics but affects other physics objects. Iits kinetic force is
|
|
|
- * calculated by the amount of movement it is exposed to and its weight.
|
|
|
- *
|
|
|
+ * Sets the node to kinematic mode. in this mode the node is not affected by physics
|
|
|
+ * but affects other physics objects. Iits kinetic force is calculated by the amount
|
|
|
+ * of movement it is exposed to and its weight.
|
|
|
* @param kinematic
|
|
|
*/
|
|
|
public void setKinematic(boolean kinematic) {
|
|
@@ -279,11 +272,8 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void setCcdSweptSphereRadius(long objectId, float radius);
|
|
|
|
|
|
/**
|
|
|
- * Sets the amount of motion that has to happen in one physics tick to
|
|
|
- * trigger the continuous motion detection<br/>
|
|
|
- * This avoids the problem of fast objects moving through other objects, set
|
|
|
- * to zero to disable (default)
|
|
|
- *
|
|
|
+ * Sets the amount of motion that has to happen in one physics tick to trigger the continuous motion detection<br/>
|
|
|
+ * This avoids the problem of fast objects moving through other objects, set to zero to disable (default)
|
|
|
* @param threshold
|
|
|
*/
|
|
|
public void setCcdMotionThreshold(float threshold) {
|
|
@@ -316,7 +306,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the mass of this PhysicsRigidBody, objects with mass=0 are static.
|
|
|
- *
|
|
|
* @param mass
|
|
|
*/
|
|
|
public void setMass(float mass) {
|
|
@@ -356,9 +345,8 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Set the local gravity of this PhysicsRigidBody<br/>
|
|
|
- * Set this after adding the node to the PhysicsSpace, the PhysicsSpace
|
|
|
- * assigns its current gravity to the physics node when its added.
|
|
|
- *
|
|
|
+ * Set this after adding the node to the PhysicsSpace,
|
|
|
+ * the PhysicsSpace assigns its current gravity to the physics node when its added.
|
|
|
* @param gravity the gravity vector to set
|
|
|
*/
|
|
|
public void setGravity(Vector3f gravity) {
|
|
@@ -375,7 +363,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the friction of this physics object
|
|
|
- *
|
|
|
* @param friction the friction of this physics object
|
|
|
*/
|
|
|
public void setFriction(float friction) {
|
|
@@ -402,11 +389,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
public void setLinearDamping(float linearDamping) {
|
|
|
setDamping(objectId, linearDamping, getAngularDamping());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void setAngularDamping(float angularDamping) {
|
|
|
setAngularDamping(objectId, angularDamping);
|
|
|
}
|
|
|
-
|
|
|
private native void setAngularDamping(long objectId, float factor);
|
|
|
|
|
|
public float getLinearDamping() {
|
|
@@ -428,9 +414,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native float getRestitution(long objectId);
|
|
|
|
|
|
/**
|
|
|
- * The "bouncyness" of the PhysicsRigidBody, best performance if
|
|
|
- * restitution=0
|
|
|
- *
|
|
|
+ * The "bouncyness" of the PhysicsRigidBody, best performance if restitution=0
|
|
|
* @param restitution
|
|
|
*/
|
|
|
public void setRestitution(float restitution) {
|
|
@@ -441,7 +425,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Get the current angular velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @return the current linear velocity
|
|
|
*/
|
|
|
public Vector3f getAngularVelocity() {
|
|
@@ -454,7 +437,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Get the current angular velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @param vec the vector to store the velocity in
|
|
|
*/
|
|
|
public void getAngularVelocity(Vector3f vec) {
|
|
@@ -463,7 +445,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the angular velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @param vec the angular velocity of this PhysicsRigidBody
|
|
|
*/
|
|
|
public void setAngularVelocity(Vector3f vec) {
|
|
@@ -475,7 +456,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Get the current linear velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @return the current linear velocity
|
|
|
*/
|
|
|
public Vector3f getLinearVelocity() {
|
|
@@ -488,7 +468,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Get the current linear velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @param vec the vector to store the velocity in
|
|
|
*/
|
|
|
public void getLinearVelocity(Vector3f vec) {
|
|
@@ -497,7 +476,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Sets the linear velocity of this PhysicsRigidBody
|
|
|
- *
|
|
|
* @param vec the linear velocity of this PhysicsRigidBody
|
|
|
*/
|
|
|
public void setLinearVelocity(Vector3f vec) {
|
|
@@ -508,11 +486,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void setLinearVelocity(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
|
- * Apply a force to the PhysicsRigidBody, only applies force if the next
|
|
|
- * physics update call updates the physics space.<br>
|
|
|
- * To apply an impulse, use applyImpulse, use applyContinuousForce to apply
|
|
|
- * continuous force.
|
|
|
- *
|
|
|
+ * Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
|
|
|
+ * updates the physics space.<br>
|
|
|
+ * To apply an impulse, use applyImpulse, use applyContinuousForce to apply continuous force.
|
|
|
* @param force the force
|
|
|
* @param location the location of the force
|
|
|
*/
|
|
@@ -524,10 +500,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void applyForce(long objectId, Vector3f force, Vector3f location);
|
|
|
|
|
|
/**
|
|
|
- * Apply a force to the PhysicsRigidBody, only applies force if the next
|
|
|
- * physics update call updates the physics space.<br>
|
|
|
+ * Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
|
|
|
+ * updates the physics space.<br>
|
|
|
* To apply an impulse, use applyImpulse.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param force the force
|
|
|
*/
|
|
|
public void applyCentralForce(Vector3f force) {
|
|
@@ -538,10 +514,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void applyCentralForce(long objectId, Vector3f force);
|
|
|
|
|
|
/**
|
|
|
- * Apply a force to the PhysicsRigidBody, only applies force if the next
|
|
|
- * physics update call updates the physics space.<br>
|
|
|
+ * Apply a force to the PhysicsRigidBody, only applies force if the next physics update call
|
|
|
+ * updates the physics space.<br>
|
|
|
* To apply an impulse, use applyImpulse.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param torque the torque
|
|
|
*/
|
|
|
public void applyTorque(Vector3f torque) {
|
|
@@ -553,7 +529,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Apply an impulse to the PhysicsRigidBody in the next physics update.
|
|
|
- *
|
|
|
* @param impulse applied impulse
|
|
|
* @param rel_pos location relative to object
|
|
|
*/
|
|
@@ -565,9 +540,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void applyImpulse(long objectId, Vector3f impulse, Vector3f rel_pos);
|
|
|
|
|
|
/**
|
|
|
- * Apply a torque impulse to the PhysicsRigidBody in the next physics
|
|
|
- * update.
|
|
|
- *
|
|
|
+ * Apply a torque impulse to the PhysicsRigidBody in the next physics update.
|
|
|
* @param vec
|
|
|
*/
|
|
|
public void applyTorqueImpulse(Vector3f vec) {
|
|
@@ -579,7 +552,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
/**
|
|
|
* Clear all forces from the PhysicsRigidBody
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
public void clearForces() {
|
|
|
clearForces(objectId);
|
|
@@ -603,8 +576,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native void setCollisionShape(long objectId, long collisionShapeId);
|
|
|
|
|
|
/**
|
|
|
- * reactivates this PhysicsRigidBody when it has been deactivated because it
|
|
|
- * was not moving
|
|
|
+ * reactivates this PhysicsRigidBody when it has been deactivated because it was not moving
|
|
|
*/
|
|
|
public void activate() {
|
|
|
activate(objectId);
|
|
@@ -619,10 +591,8 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
private native boolean isActive(long objectId);
|
|
|
|
|
|
/**
|
|
|
- * sets the sleeping thresholds, these define when the object gets
|
|
|
- * deactivated to save ressources. Low values keep the object active when it
|
|
|
- * barely moves
|
|
|
- *
|
|
|
+ * sets the sleeping thresholds, these define when the object gets deactivated
|
|
|
+ * to save ressources. Low values keep the object active when it barely moves
|
|
|
* @param linear the linear sleeping threshold
|
|
|
* @param angular the angular sleeping threshold
|
|
|
*/
|
|
@@ -676,25 +646,26 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
}
|
|
|
|
|
|
public void setAngularFactor(Vector3f factor) {
|
|
|
- setAngularFactor(objectId, factor);
|
|
|
+ setAngularFactor(objectId, factor);
|
|
|
}
|
|
|
|
|
|
private native void setAngularFactor(long objectId, Vector3f factor);
|
|
|
|
|
|
public Vector3f getLinearFactor() {
|
|
|
Vector3f vec = new Vector3f();
|
|
|
- getLinearFactor(objectId, vec);
|
|
|
+ getLinearFactor(objectId, vec);
|
|
|
return vec;
|
|
|
}
|
|
|
|
|
|
private native void getLinearFactor(long objectId, Vector3f vec);
|
|
|
|
|
|
public void setLinearFactor(Vector3f factor) {
|
|
|
- setLinearFactor(objectId, factor);
|
|
|
+ setLinearFactor(objectId, factor);
|
|
|
}
|
|
|
|
|
|
private native void setLinearFactor(long objectId, Vector3f factor);
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* do not use manually, joints are added automatically
|
|
|
*/
|
|
@@ -705,17 +676,15 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
public void removeJoint(PhysicsJoint joint) {
|
|
|
joints.remove(joint);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns a list of connected joints. This list is only filled when the
|
|
|
- * PhysicsRigidBody is actually added to the physics space or loaded from
|
|
|
- * disk.
|
|
|
- *
|
|
|
+ * Returns a list of connected joints. This list is only filled when
|
|
|
+ * the PhysicsRigidBody is actually added to the physics space or loaded from disk.
|
|
|
* @return list of active joints connected to this PhysicsRigidBody
|
|
|
*/
|
|
|
public List<PhysicsJoint> getJoints() {
|