|
@@ -51,29 +51,56 @@ import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * <p>PhysicsRigidBody - Basic physics object</p>
|
|
|
|
|
|
+ * A collision object for a rigid body, based on Bullet's btRigidBody.
|
|
|
|
+ *
|
|
* @author normenhansen
|
|
* @author normenhansen
|
|
*/
|
|
*/
|
|
public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * motion state
|
|
|
|
+ */
|
|
protected RigidBodyMotionState motionState = new RigidBodyMotionState();
|
|
protected RigidBodyMotionState motionState = new RigidBodyMotionState();
|
|
|
|
+ /**
|
|
|
|
+ * copy of mass (>0) of a dynamic body, or 0 for a static body
|
|
|
|
+ * (default=1)
|
|
|
|
+ */
|
|
protected float mass = 1.0f;
|
|
protected float mass = 1.0f;
|
|
|
|
+ /**
|
|
|
|
+ * copy of kinematic flag: true→set kinematic mode (spatial controls
|
|
|
|
+ * body), false→dynamic/static mode (body controls spatial)
|
|
|
|
+ * (default=false)
|
|
|
|
+ */
|
|
protected boolean kinematic = false;
|
|
protected boolean kinematic = false;
|
|
|
|
+ /**
|
|
|
|
+ * joint list
|
|
|
|
+ */
|
|
protected ArrayList<PhysicsJoint> joints = new ArrayList<PhysicsJoint>();
|
|
protected ArrayList<PhysicsJoint> joints = new ArrayList<PhysicsJoint>();
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * No-argument constructor needed by SavableClassUtil. Do not invoke
|
|
|
|
+ * directly!
|
|
|
|
+ */
|
|
public PhysicsRigidBody() {
|
|
public PhysicsRigidBody() {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Creates a new PhysicsRigidBody with the supplied collision shape
|
|
|
|
- * @param child
|
|
|
|
- * @param shape
|
|
|
|
|
|
+ * Instantiate a dynamic body with mass=1 and the specified collision shape.
|
|
|
|
+ *
|
|
|
|
+ * @param shape the desired shape (not null, alias created)
|
|
*/
|
|
*/
|
|
public PhysicsRigidBody(CollisionShape shape) {
|
|
public PhysicsRigidBody(CollisionShape shape) {
|
|
collisionShape = shape;
|
|
collisionShape = shape;
|
|
rebuildRigidBody();
|
|
rebuildRigidBody();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Instantiate a body with the specified collision shape and mass.
|
|
|
|
+ *
|
|
|
|
+ * @param shape the desired shape (not null, alias created)
|
|
|
|
+ * @param mass if 0, a static body is created; otherwise a dynamic body is
|
|
|
|
+ * created (≥0)
|
|
|
|
+ */
|
|
public PhysicsRigidBody(CollisionShape shape, float mass) {
|
|
public PhysicsRigidBody(CollisionShape shape, float mass) {
|
|
collisionShape = shape;
|
|
collisionShape = shape;
|
|
this.mass = mass;
|
|
this.mass = mass;
|
|
@@ -81,7 +108,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Builds/rebuilds the phyiscs body when parameters have changed
|
|
|
|
|
|
+ * Build/rebuild this body after parameters have changed.
|
|
*/
|
|
*/
|
|
protected void rebuildRigidBody() {
|
|
protected void rebuildRigidBody() {
|
|
boolean removed = false;
|
|
boolean removed = false;
|
|
@@ -105,11 +132,17 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * For use by subclasses.
|
|
|
|
+ */
|
|
protected void preRebuild() {
|
|
protected void preRebuild() {
|
|
}
|
|
}
|
|
|
|
|
|
private native long createRigidBody(float mass, long motionStateId, long collisionShapeId);
|
|
private native long createRigidBody(float mass, long motionStateId, long collisionShapeId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * For use by subclasses.
|
|
|
|
+ */
|
|
protected void postRebuild() {
|
|
protected void postRebuild() {
|
|
if (mass == 0.0f) {
|
|
if (mass == 0.0f) {
|
|
setStatic(objectId, true);
|
|
setStatic(objectId, true);
|
|
@@ -120,12 +153,19 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the motionState
|
|
|
|
|
|
+ * Access this body's motion state.
|
|
|
|
+ *
|
|
|
|
+ * @return the pre-existing instance
|
|
*/
|
|
*/
|
|
public RigidBodyMotionState getMotionState() {
|
|
public RigidBodyMotionState getMotionState() {
|
|
return motionState;
|
|
return motionState;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test whether this body is in a physics space.
|
|
|
|
+ *
|
|
|
|
+ * @return true→in a space, false→not in a space
|
|
|
|
+ */
|
|
public boolean isInWorld() {
|
|
public boolean isInWorld() {
|
|
return isInWorld(objectId);
|
|
return isInWorld(objectId);
|
|
}
|
|
}
|
|
@@ -133,8 +173,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native boolean isInWorld(long objectId);
|
|
private native boolean isInWorld(long objectId);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the physics object location
|
|
|
|
- * @param location the location of the actual physics object
|
|
|
|
|
|
+ * Directly alter the location of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @param location the desired location (not null, unaffected)
|
|
*/
|
|
*/
|
|
public void setPhysicsLocation(Vector3f location) {
|
|
public void setPhysicsLocation(Vector3f location) {
|
|
setPhysicsLocation(objectId, location);
|
|
setPhysicsLocation(objectId, location);
|
|
@@ -143,8 +184,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setPhysicsLocation(long objectId, Vector3f location);
|
|
private native void setPhysicsLocation(long objectId, Vector3f location);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the physics object rotation
|
|
|
|
- * @param rotation the rotation of the actual physics object
|
|
|
|
|
|
+ * Directly alter this body's orientation.
|
|
|
|
+ *
|
|
|
|
+ * @param rotation the desired orientation (rotation matrix, not null,
|
|
|
|
+ * unaffected)
|
|
*/
|
|
*/
|
|
public void setPhysicsRotation(Matrix3f rotation) {
|
|
public void setPhysicsRotation(Matrix3f rotation) {
|
|
setPhysicsRotation(objectId, rotation);
|
|
setPhysicsRotation(objectId, rotation);
|
|
@@ -153,8 +196,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setPhysicsRotation(long objectId, Matrix3f rotation);
|
|
private native void setPhysicsRotation(long objectId, Matrix3f rotation);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the physics object rotation
|
|
|
|
- * @param rotation the rotation of the actual physics object
|
|
|
|
|
|
+ * Directly alter this body's orientation.
|
|
|
|
+ *
|
|
|
|
+ * @param rotation the desired orientation (quaternion, not null,
|
|
|
|
+ * unaffected)
|
|
*/
|
|
*/
|
|
public void setPhysicsRotation(Quaternion rotation) {
|
|
public void setPhysicsRotation(Quaternion rotation) {
|
|
setPhysicsRotation(objectId, rotation);
|
|
setPhysicsRotation(objectId, rotation);
|
|
@@ -163,7 +208,11 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setPhysicsRotation(long objectId, Quaternion rotation);
|
|
private native void setPhysicsRotation(long objectId, Quaternion rotation);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the physicsLocation
|
|
|
|
|
|
+ * Copy the location of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @param trans storage for the result (modified if not null)
|
|
|
|
+ * @return the location (either the provided storage or a new vector, not
|
|
|
|
+ * null)
|
|
*/
|
|
*/
|
|
public Vector3f getPhysicsLocation(Vector3f trans) {
|
|
public Vector3f getPhysicsLocation(Vector3f trans) {
|
|
if (trans == null) {
|
|
if (trans == null) {
|
|
@@ -176,7 +225,11 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getPhysicsLocation(long objectId, Vector3f vector);
|
|
private native void getPhysicsLocation(long objectId, Vector3f vector);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the physicsLocation
|
|
|
|
|
|
+ * Copy this body's orientation to a quaternion.
|
|
|
|
+ *
|
|
|
|
+ * @param rot storage for the result (modified if not null)
|
|
|
|
+ * @return the orientation (either the provided storage or a new quaternion,
|
|
|
|
+ * not null)
|
|
*/
|
|
*/
|
|
public Quaternion getPhysicsRotation(Quaternion rot) {
|
|
public Quaternion getPhysicsRotation(Quaternion rot) {
|
|
if (rot == null) {
|
|
if (rot == null) {
|
|
@@ -185,12 +238,23 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
getPhysicsRotation(objectId, rot);
|
|
getPhysicsRotation(objectId, rot);
|
|
return rot;
|
|
return rot;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Alter the principal components of the local inertia tensor.
|
|
|
|
+ *
|
|
|
|
+ * @param gravity (not null, unaffected)
|
|
|
|
+ */
|
|
public void setInverseInertiaLocal(Vector3f gravity) {
|
|
public void setInverseInertiaLocal(Vector3f gravity) {
|
|
setInverseInertiaLocal(objectId, gravity);
|
|
setInverseInertiaLocal(objectId, gravity);
|
|
}
|
|
}
|
|
private native void setInverseInertiaLocal(long objectId, Vector3f gravity);
|
|
private native void setInverseInertiaLocal(long objectId, Vector3f gravity);
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Read the principal components of the local inverse inertia tensor.
|
|
|
|
+ *
|
|
|
|
+ * @param trans storage for the result (modified if not null)
|
|
|
|
+ * @return a vector (either the provided storage or a new vector, not null)
|
|
|
|
+ */
|
|
public Vector3f getInverseInertiaLocal(Vector3f trans) {
|
|
public Vector3f getInverseInertiaLocal(Vector3f trans) {
|
|
if (trans == null) {
|
|
if (trans == null) {
|
|
trans = new Vector3f();
|
|
trans = new Vector3f();
|
|
@@ -204,7 +268,11 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getPhysicsRotation(long objectId, Quaternion rot);
|
|
private native void getPhysicsRotation(long objectId, Quaternion rot);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the physicsLocation
|
|
|
|
|
|
+ * Copy this body's orientation to a matrix.
|
|
|
|
+ *
|
|
|
|
+ * @param rot storage for the result (modified if not null)
|
|
|
|
+ * @return the orientation (either the provided storage or a new matrix, not
|
|
|
|
+ * null)
|
|
*/
|
|
*/
|
|
public Matrix3f getPhysicsRotationMatrix(Matrix3f rot) {
|
|
public Matrix3f getPhysicsRotationMatrix(Matrix3f rot) {
|
|
if (rot == null) {
|
|
if (rot == null) {
|
|
@@ -217,7 +285,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getPhysicsRotationMatrix(long objectId, Matrix3f rot);
|
|
private native void getPhysicsRotationMatrix(long objectId, Matrix3f rot);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the physicsLocation
|
|
|
|
|
|
+ * Copy the location of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @return a new location vector (not null)
|
|
*/
|
|
*/
|
|
public Vector3f getPhysicsLocation() {
|
|
public Vector3f getPhysicsLocation() {
|
|
Vector3f vec = new Vector3f();
|
|
Vector3f vec = new Vector3f();
|
|
@@ -226,7 +296,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @return the physicsLocation
|
|
|
|
|
|
+ * Copy this body's orientation to a quaternion.
|
|
|
|
+ *
|
|
|
|
+ * @return a new quaternion (not null)
|
|
*/
|
|
*/
|
|
public Quaternion getPhysicsRotation() {
|
|
public Quaternion getPhysicsRotation() {
|
|
Quaternion quat = new Quaternion();
|
|
Quaternion quat = new Quaternion();
|
|
@@ -234,6 +306,11 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
return quat;
|
|
return quat;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Copy this body's orientation to a matrix.
|
|
|
|
+ *
|
|
|
|
+ * @return a new matrix (not null)
|
|
|
|
+ */
|
|
public Matrix3f getPhysicsRotationMatrix() {
|
|
public Matrix3f getPhysicsRotationMatrix() {
|
|
Matrix3f mtx = new Matrix3f();
|
|
Matrix3f mtx = new Matrix3f();
|
|
getPhysicsRotationMatrix(objectId, mtx);
|
|
getPhysicsRotationMatrix(objectId, mtx);
|
|
@@ -264,10 +341,14 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
// return Converter.convert(tempTrans.basis, rotation);
|
|
// 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. Its kinetic force is calculated by the amount
|
|
|
|
- * of movement it is exposed to and its weight.
|
|
|
|
- * @param kinematic
|
|
|
|
|
|
+ * Put this body into kinematic mode or take it out of kinematic mode.
|
|
|
|
+ * <p>
|
|
|
|
+ * In kinematic mode, the body is not influenced by physics but can affect
|
|
|
|
+ * other physics objects. Its kinetic force is calculated based on its
|
|
|
|
+ * movement and weight.
|
|
|
|
+ *
|
|
|
|
+ * @param kinematic true→set kinematic mode, false→set
|
|
|
|
+ * dynamic/static mode (default=false)
|
|
*/
|
|
*/
|
|
public void setKinematic(boolean kinematic) {
|
|
public void setKinematic(boolean kinematic) {
|
|
this.kinematic = kinematic;
|
|
this.kinematic = kinematic;
|
|
@@ -276,10 +357,25 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void setKinematic(long objectId, boolean kinematic);
|
|
private native void setKinematic(long objectId, boolean kinematic);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test whether this body is in kinematic mode.
|
|
|
|
+ * <p>
|
|
|
|
+ * In kinematic mode, the body is not influenced by physics but can affect
|
|
|
|
+ * other physics objects. Its kinetic force is calculated based on its
|
|
|
|
+ * movement and weight.
|
|
|
|
+ *
|
|
|
|
+ * @return true if in kinematic mode, otherwise false (dynamic/static mode)
|
|
|
|
+ */
|
|
public boolean isKinematic() {
|
|
public boolean isKinematic() {
|
|
return kinematic;
|
|
return kinematic;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter the radius of the swept sphere used for continuous collision
|
|
|
|
+ * detection (CCD).
|
|
|
|
+ *
|
|
|
|
+ * @param radius the desired radius (≥0, default=0)
|
|
|
|
+ */
|
|
public void setCcdSweptSphereRadius(float radius) {
|
|
public void setCcdSweptSphereRadius(float radius) {
|
|
setCcdSweptSphereRadius(objectId, radius);
|
|
setCcdSweptSphereRadius(objectId, radius);
|
|
}
|
|
}
|
|
@@ -287,9 +383,14 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setCcdSweptSphereRadius(long objectId, float radius);
|
|
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)
|
|
|
|
- * @param threshold
|
|
|
|
|
|
+ * Alter the amount of motion required to activate continuous collision
|
|
|
|
+ * detection (CCD).
|
|
|
|
+ * <p>
|
|
|
|
+ * This addresses the issue of fast objects passing through other objects
|
|
|
|
+ * with no collision detected.
|
|
|
|
+ *
|
|
|
|
+ * @param threshold the desired threshold velocity (>0) or zero to
|
|
|
|
+ * disable CCD (default=0)
|
|
*/
|
|
*/
|
|
public void setCcdMotionThreshold(float threshold) {
|
|
public void setCcdMotionThreshold(float threshold) {
|
|
setCcdMotionThreshold(objectId, threshold);
|
|
setCcdMotionThreshold(objectId, threshold);
|
|
@@ -297,31 +398,56 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void setCcdMotionThreshold(long objectId, float threshold);
|
|
private native void setCcdMotionThreshold(long objectId, float threshold);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read the radius of the swept sphere used for continuous collision
|
|
|
|
+ * detection (CCD).
|
|
|
|
+ *
|
|
|
|
+ * @return radius (≥0)
|
|
|
|
+ */
|
|
public float getCcdSweptSphereRadius() {
|
|
public float getCcdSweptSphereRadius() {
|
|
return getCcdSweptSphereRadius(objectId);
|
|
return getCcdSweptSphereRadius(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getCcdSweptSphereRadius(long objectId);
|
|
private native float getCcdSweptSphereRadius(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Calculate this body's continuous collision detection (CCD) motion
|
|
|
|
+ * threshold.
|
|
|
|
+ *
|
|
|
|
+ * @return the threshold velocity (≥0)
|
|
|
|
+ */
|
|
public float getCcdMotionThreshold() {
|
|
public float getCcdMotionThreshold() {
|
|
return getCcdMotionThreshold(objectId);
|
|
return getCcdMotionThreshold(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getCcdMotionThreshold(long objectId);
|
|
private native float getCcdMotionThreshold(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Calculate the square of this body's continuous collision detection (CCD)
|
|
|
|
+ * motion threshold.
|
|
|
|
+ *
|
|
|
|
+ * @return the threshold velocity squared (≥0)
|
|
|
|
+ */
|
|
public float getCcdSquareMotionThreshold() {
|
|
public float getCcdSquareMotionThreshold() {
|
|
return getCcdSquareMotionThreshold(objectId);
|
|
return getCcdSquareMotionThreshold(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getCcdSquareMotionThreshold(long objectId);
|
|
private native float getCcdSquareMotionThreshold(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's mass.
|
|
|
|
+ *
|
|
|
|
+ * @return the mass (>0) or zero for a static body
|
|
|
|
+ */
|
|
public float getMass() {
|
|
public float getMass() {
|
|
return mass;
|
|
return mass;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the mass of this PhysicsRigidBody, objects with mass=0 are static.
|
|
|
|
- * @param mass
|
|
|
|
|
|
+ * Alter this body's mass. Bodies with mass=0 are static. For dynamic
|
|
|
|
+ * bodies, it is best to keep the mass around 1.
|
|
|
|
+ *
|
|
|
|
+ * @param mass the desired mass (>0) or 0 for a static body (default=1)
|
|
*/
|
|
*/
|
|
public void setMass(float mass) {
|
|
public void setMass(float mass) {
|
|
this.mass = mass;
|
|
this.mass = mass;
|
|
@@ -344,10 +470,22 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native long updateMassProps(long objectId, long collisionShapeId, float mass);
|
|
private native long updateMassProps(long objectId, long collisionShapeId, float mass);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Copy this body's gravitational acceleration.
|
|
|
|
+ *
|
|
|
|
+ * @return a new acceleration vector (not null)
|
|
|
|
+ */
|
|
public Vector3f getGravity() {
|
|
public Vector3f getGravity() {
|
|
return getGravity(null);
|
|
return getGravity(null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Copy this body's gravitational acceleration.
|
|
|
|
+ *
|
|
|
|
+ * @param gravity storage for the result (modified if not null)
|
|
|
|
+ * @return an acceleration vector (either the provided storage or a new
|
|
|
|
+ * vector, not null)
|
|
|
|
+ */
|
|
public Vector3f getGravity(Vector3f gravity) {
|
|
public Vector3f getGravity(Vector3f gravity) {
|
|
if (gravity == null) {
|
|
if (gravity == null) {
|
|
gravity = new Vector3f();
|
|
gravity = new Vector3f();
|
|
@@ -359,16 +497,23 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getGravity(long objectId, Vector3f gravity);
|
|
private native void getGravity(long objectId, Vector3f gravity);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 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.
|
|
|
|
- * @param gravity the gravity vector to set
|
|
|
|
|
|
+ * Alter this body's gravitational acceleration.
|
|
|
|
+ * <p>
|
|
|
|
+ * Invoke this after adding the body to a PhysicsSpace. Adding a body to a
|
|
|
|
+ * PhysicsSpace alters its gravity.
|
|
|
|
+ *
|
|
|
|
+ * @param gravity the desired acceleration vector (not null, unaffected)
|
|
*/
|
|
*/
|
|
public void setGravity(Vector3f gravity) {
|
|
public void setGravity(Vector3f gravity) {
|
|
setGravity(objectId, gravity);
|
|
setGravity(objectId, gravity);
|
|
}
|
|
}
|
|
private native void setGravity(long objectId, Vector3f gravity);
|
|
private native void setGravity(long objectId, Vector3f gravity);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's friction.
|
|
|
|
+ *
|
|
|
|
+ * @return friction value
|
|
|
|
+ */
|
|
public float getFriction() {
|
|
public float getFriction() {
|
|
return getFriction(objectId);
|
|
return getFriction(objectId);
|
|
}
|
|
}
|
|
@@ -376,8 +521,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native float getFriction(long objectId);
|
|
private native float getFriction(long objectId);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the friction of this physics object
|
|
|
|
- * @param friction the friction of this physics object
|
|
|
|
|
|
+ * Alter this body's friction.
|
|
|
|
+ *
|
|
|
|
+ * @param friction the desired friction value (default=0.5)
|
|
*/
|
|
*/
|
|
public void setFriction(float friction) {
|
|
public void setFriction(float friction) {
|
|
setFriction(objectId, friction);
|
|
setFriction(objectId, friction);
|
|
@@ -385,6 +531,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void setFriction(long objectId, float friction);
|
|
private native void setFriction(long objectId, float friction);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's damping.
|
|
|
|
+ *
|
|
|
|
+ * @param linearDamping the desired linear damping value (default=0)
|
|
|
|
+ * @param angularDamping the desired angular damping value (default=0)
|
|
|
|
+ */
|
|
public void setDamping(float linearDamping, float angularDamping) {
|
|
public void setDamping(float linearDamping, float angularDamping) {
|
|
setDamping(objectId, linearDamping, angularDamping);
|
|
setDamping(objectId, linearDamping, angularDamping);
|
|
}
|
|
}
|
|
@@ -400,27 +552,52 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
//
|
|
//
|
|
// private native void setRestitution(long objectId, float factor);
|
|
// private native void setRestitution(long objectId, float factor);
|
|
//
|
|
//
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's linear damping.
|
|
|
|
+ *
|
|
|
|
+ * @param linearDamping the desired linear damping value (default=0)
|
|
|
|
+ */
|
|
public void setLinearDamping(float linearDamping) {
|
|
public void setLinearDamping(float linearDamping) {
|
|
setDamping(objectId, linearDamping, getAngularDamping());
|
|
setDamping(objectId, linearDamping, getAngularDamping());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's angular damping.
|
|
|
|
+ *
|
|
|
|
+ * @param angularDamping the desired angular damping value (default=0)
|
|
|
|
+ */
|
|
public void setAngularDamping(float angularDamping) {
|
|
public void setAngularDamping(float angularDamping) {
|
|
setAngularDamping(objectId, angularDamping);
|
|
setAngularDamping(objectId, angularDamping);
|
|
}
|
|
}
|
|
private native void setAngularDamping(long objectId, float factor);
|
|
private native void setAngularDamping(long objectId, float factor);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's linear damping.
|
|
|
|
+ *
|
|
|
|
+ * @return damping value
|
|
|
|
+ */
|
|
public float getLinearDamping() {
|
|
public float getLinearDamping() {
|
|
return getLinearDamping(objectId);
|
|
return getLinearDamping(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getLinearDamping(long objectId);
|
|
private native float getLinearDamping(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's angular damping.
|
|
|
|
+ *
|
|
|
|
+ * @return damping value
|
|
|
|
+ */
|
|
public float getAngularDamping() {
|
|
public float getAngularDamping() {
|
|
return getAngularDamping(objectId);
|
|
return getAngularDamping(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getAngularDamping(long objectId);
|
|
private native float getAngularDamping(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's restitution (bounciness).
|
|
|
|
+ *
|
|
|
|
+ * @return restitution value
|
|
|
|
+ */
|
|
public float getRestitution() {
|
|
public float getRestitution() {
|
|
return getRestitution(objectId);
|
|
return getRestitution(objectId);
|
|
}
|
|
}
|
|
@@ -428,8 +605,10 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native float getRestitution(long objectId);
|
|
private native float getRestitution(long objectId);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The "bouncyness" of the PhysicsRigidBody, best performance if restitution=0
|
|
|
|
- * @param restitution
|
|
|
|
|
|
+ * Alter this body's restitution (bounciness). For best performance, set
|
|
|
|
+ * restitution=0.
|
|
|
|
+ *
|
|
|
|
+ * @param restitution the desired value (default=0)
|
|
*/
|
|
*/
|
|
public void setRestitution(float restitution) {
|
|
public void setRestitution(float restitution) {
|
|
setRestitution(objectId, restitution);
|
|
setRestitution(objectId, restitution);
|
|
@@ -438,8 +617,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setRestitution(long objectId, float factor);
|
|
private native void setRestitution(long objectId, float factor);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the current angular velocity of this PhysicsRigidBody
|
|
|
|
- * @return the current linear velocity
|
|
|
|
|
|
+ * Copy this body's angular velocity.
|
|
|
|
+ *
|
|
|
|
+ * @return a new velocity vector (not null)
|
|
*/
|
|
*/
|
|
public Vector3f getAngularVelocity() {
|
|
public Vector3f getAngularVelocity() {
|
|
Vector3f vec = new Vector3f();
|
|
Vector3f vec = new Vector3f();
|
|
@@ -450,16 +630,18 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getAngularVelocity(long objectId, Vector3f vec);
|
|
private native void getAngularVelocity(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the current angular velocity of this PhysicsRigidBody
|
|
|
|
- * @param vec the vector to store the velocity in
|
|
|
|
|
|
+ * Copy this body's angular velocity.
|
|
|
|
+ *
|
|
|
|
+ * @param vec storage for the result (not null, modified)
|
|
*/
|
|
*/
|
|
public void getAngularVelocity(Vector3f vec) {
|
|
public void getAngularVelocity(Vector3f vec) {
|
|
getAngularVelocity(objectId, vec);
|
|
getAngularVelocity(objectId, vec);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the angular velocity of this PhysicsRigidBody
|
|
|
|
- * @param vec the angular velocity of this PhysicsRigidBody
|
|
|
|
|
|
+ * Alter this body's angular velocity.
|
|
|
|
+ *
|
|
|
|
+ * @param vec the desired angular velocity vector (not null, unaffected)
|
|
*/
|
|
*/
|
|
public void setAngularVelocity(Vector3f vec) {
|
|
public void setAngularVelocity(Vector3f vec) {
|
|
setAngularVelocity(objectId, vec);
|
|
setAngularVelocity(objectId, vec);
|
|
@@ -469,8 +651,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setAngularVelocity(long objectId, Vector3f vec);
|
|
private native void setAngularVelocity(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the current linear velocity of this PhysicsRigidBody
|
|
|
|
- * @return the current linear velocity
|
|
|
|
|
|
+ * Copy the linear velocity of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @return a new velocity vector (not null)
|
|
*/
|
|
*/
|
|
public Vector3f getLinearVelocity() {
|
|
public Vector3f getLinearVelocity() {
|
|
Vector3f vec = new Vector3f();
|
|
Vector3f vec = new Vector3f();
|
|
@@ -481,16 +664,18 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void getLinearVelocity(long objectId, Vector3f vec);
|
|
private native void getLinearVelocity(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the current linear velocity of this PhysicsRigidBody
|
|
|
|
- * @param vec the vector to store the velocity in
|
|
|
|
|
|
+ * Copy the linear velocity of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @param vec storage for the result (not null, modified)
|
|
*/
|
|
*/
|
|
public void getLinearVelocity(Vector3f vec) {
|
|
public void getLinearVelocity(Vector3f vec) {
|
|
getLinearVelocity(objectId, vec);
|
|
getLinearVelocity(objectId, vec);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the linear velocity of this PhysicsRigidBody
|
|
|
|
- * @param vec the linear velocity of this PhysicsRigidBody
|
|
|
|
|
|
+ * Alter the linear velocity of this body's center of mass.
|
|
|
|
+ *
|
|
|
|
+ * @param vec the desired velocity vector (not null)
|
|
*/
|
|
*/
|
|
public void setLinearVelocity(Vector3f vec) {
|
|
public void setLinearVelocity(Vector3f vec) {
|
|
setLinearVelocity(objectId, vec);
|
|
setLinearVelocity(objectId, vec);
|
|
@@ -500,9 +685,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setLinearVelocity(long objectId, Vector3f vec);
|
|
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. Effective only if the next physics
|
|
|
|
+ * update steps the physics space.
|
|
|
|
+ * <p>
|
|
|
|
+ * To apply an impulse, use applyImpulse, use applyContinuousForce to apply
|
|
|
|
+ * continuous force.
|
|
|
|
+ *
|
|
* @param force the force
|
|
* @param force the force
|
|
* @param location the location of the force
|
|
* @param location the location of the force
|
|
*/
|
|
*/
|
|
@@ -514,10 +702,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void applyForce(long objectId, Vector3f force, Vector3f location);
|
|
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>
|
|
|
|
- * To apply an impulse, use applyImpulse.
|
|
|
|
- *
|
|
|
|
|
|
+ * Apply a force to the PhysicsRigidBody. Effective only if the next physics
|
|
|
|
+ * update steps the physics space.
|
|
|
|
+ * <p>
|
|
|
|
+ * To apply an impulse, use
|
|
|
|
+ * {@link #applyImpulse(com.jme3.math.Vector3f, com.jme3.math.Vector3f)}.
|
|
|
|
+ *
|
|
* @param force the force
|
|
* @param force the force
|
|
*/
|
|
*/
|
|
public void applyCentralForce(Vector3f force) {
|
|
public void applyCentralForce(Vector3f force) {
|
|
@@ -528,10 +718,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void applyCentralForce(long objectId, Vector3f force);
|
|
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>
|
|
|
|
- * To apply an impulse, use applyImpulse.
|
|
|
|
- *
|
|
|
|
|
|
+ * Apply a force to the PhysicsRigidBody. Effective only if the next physics
|
|
|
|
+ * update steps the physics space.
|
|
|
|
+ * <p>
|
|
|
|
+ * To apply an impulse, use
|
|
|
|
+ * {@link #applyImpulse(com.jme3.math.Vector3f, com.jme3.math.Vector3f)}.
|
|
|
|
+ *
|
|
* @param torque the torque
|
|
* @param torque the torque
|
|
*/
|
|
*/
|
|
public void applyTorque(Vector3f torque) {
|
|
public void applyTorque(Vector3f torque) {
|
|
@@ -542,7 +734,8 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void applyTorque(long objectId, Vector3f vec);
|
|
private native void applyTorque(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Apply an impulse to the PhysicsRigidBody in the next physics update.
|
|
|
|
|
|
+ * Apply an impulse to the body the next physics update.
|
|
|
|
+ *
|
|
* @param impulse applied impulse
|
|
* @param impulse applied impulse
|
|
* @param rel_pos location relative to object
|
|
* @param rel_pos location relative to object
|
|
*/
|
|
*/
|
|
@@ -554,8 +747,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void applyImpulse(long objectId, Vector3f impulse, Vector3f rel_pos);
|
|
private native void applyImpulse(long objectId, Vector3f impulse, Vector3f rel_pos);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Apply a torque impulse to the PhysicsRigidBody in the next physics update.
|
|
|
|
- * @param vec
|
|
|
|
|
|
+ * Apply a torque impulse to the body in the next physics update.
|
|
|
|
+ *
|
|
|
|
+ * @param vec the torque to apply
|
|
*/
|
|
*/
|
|
public void applyTorqueImpulse(Vector3f vec) {
|
|
public void applyTorqueImpulse(Vector3f vec) {
|
|
applyTorqueImpulse(objectId, vec);
|
|
applyTorqueImpulse(objectId, vec);
|
|
@@ -565,8 +759,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void applyTorqueImpulse(long objectId, Vector3f vec);
|
|
private native void applyTorqueImpulse(long objectId, Vector3f vec);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Clear all forces from the PhysicsRigidBody
|
|
|
|
- *
|
|
|
|
|
|
+ * Clear all forces acting on this body.
|
|
*/
|
|
*/
|
|
public void clearForces() {
|
|
public void clearForces() {
|
|
clearForces(objectId);
|
|
clearForces(objectId);
|
|
@@ -574,6 +767,14 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void clearForces(long objectId);
|
|
private native void clearForces(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Apply the specified CollisionShape to this body.
|
|
|
|
+ * <p>
|
|
|
|
+ * Note that the body should not be in any physics space while changing
|
|
|
|
+ * shape; the body gets rebuilt on the physics side.
|
|
|
|
+ *
|
|
|
|
+ * @param collisionShape the shape to apply (not null, alias created)
|
|
|
|
+ */
|
|
public void setCollisionShape(CollisionShape collisionShape) {
|
|
public void setCollisionShape(CollisionShape collisionShape) {
|
|
super.setCollisionShape(collisionShape);
|
|
super.setCollisionShape(collisionShape);
|
|
if (collisionShape instanceof MeshCollisionShape && mass != 0) {
|
|
if (collisionShape instanceof MeshCollisionShape && mass != 0) {
|
|
@@ -590,7 +791,7 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native void setCollisionShape(long objectId, long collisionShapeId);
|
|
private native void setCollisionShape(long objectId, long collisionShapeId);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * reactivates this PhysicsRigidBody when it has been deactivated because it was not moving
|
|
|
|
|
|
+ * Reactivates this body if it has been deactivated due to lack of motion.
|
|
*/
|
|
*/
|
|
public void activate() {
|
|
public void activate() {
|
|
activate(objectId);
|
|
activate(objectId);
|
|
@@ -598,6 +799,11 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void activate(long objectId);
|
|
private native void activate(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test whether this body has been deactivated due to lack of motion.
|
|
|
|
+ *
|
|
|
|
+ * @return true if still active, false if deactivated
|
|
|
|
+ */
|
|
public boolean isActive() {
|
|
public boolean isActive() {
|
|
return isActive(objectId);
|
|
return isActive(objectId);
|
|
}
|
|
}
|
|
@@ -605,10 +811,13 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
private native boolean isActive(long objectId);
|
|
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
|
|
|
|
- * @param linear the linear sleeping threshold
|
|
|
|
- * @param angular the angular sleeping threshold
|
|
|
|
|
|
+ * Alter this body's sleeping thresholds.
|
|
|
|
+ * <p>
|
|
|
|
+ * These thresholds determine when the body can be deactivated to save
|
|
|
|
+ * resources. Low values keep the body active when it barely moves.
|
|
|
|
+ *
|
|
|
|
+ * @param linear the desired linear sleeping threshold (≥0, default=0.8)
|
|
|
|
+ * @param angular the desired angular sleeping threshold (≥0, default=1)
|
|
*/
|
|
*/
|
|
public void setSleepingThresholds(float linear, float angular) {
|
|
public void setSleepingThresholds(float linear, float angular) {
|
|
setSleepingThresholds(objectId, linear, angular);
|
|
setSleepingThresholds(objectId, linear, angular);
|
|
@@ -616,36 +825,67 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void setSleepingThresholds(long objectId, float linear, float angular);
|
|
private native void setSleepingThresholds(long objectId, float linear, float angular);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's linear sleeping threshold.
|
|
|
|
+ *
|
|
|
|
+ * @param linearSleepingThreshold the desired threshold (≥0, default=0.8)
|
|
|
|
+ */
|
|
public void setLinearSleepingThreshold(float linearSleepingThreshold) {
|
|
public void setLinearSleepingThreshold(float linearSleepingThreshold) {
|
|
setLinearSleepingThreshold(objectId, linearSleepingThreshold);
|
|
setLinearSleepingThreshold(objectId, linearSleepingThreshold);
|
|
}
|
|
}
|
|
|
|
|
|
private native void setLinearSleepingThreshold(long objectId, float linearSleepingThreshold);
|
|
private native void setLinearSleepingThreshold(long objectId, float linearSleepingThreshold);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's angular sleeping threshold.
|
|
|
|
+ *
|
|
|
|
+ * @param angularSleepingThreshold the desired threshold (≥0, default=1)
|
|
|
|
+ */
|
|
public void setAngularSleepingThreshold(float angularSleepingThreshold) {
|
|
public void setAngularSleepingThreshold(float angularSleepingThreshold) {
|
|
setAngularSleepingThreshold(objectId, angularSleepingThreshold);
|
|
setAngularSleepingThreshold(objectId, angularSleepingThreshold);
|
|
}
|
|
}
|
|
|
|
|
|
private native void setAngularSleepingThreshold(long objectId, float angularSleepingThreshold);
|
|
private native void setAngularSleepingThreshold(long objectId, float angularSleepingThreshold);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's linear sleeping threshold.
|
|
|
|
+ *
|
|
|
|
+ * @return the linear sleeping threshold (≥0)
|
|
|
|
+ */
|
|
public float getLinearSleepingThreshold() {
|
|
public float getLinearSleepingThreshold() {
|
|
return getLinearSleepingThreshold(objectId);
|
|
return getLinearSleepingThreshold(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getLinearSleepingThreshold(long objectId);
|
|
private native float getLinearSleepingThreshold(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read this body's angular sleeping threshold.
|
|
|
|
+ *
|
|
|
|
+ * @return the angular sleeping threshold (≥0)
|
|
|
|
+ */
|
|
public float getAngularSleepingThreshold() {
|
|
public float getAngularSleepingThreshold() {
|
|
return getAngularSleepingThreshold(objectId);
|
|
return getAngularSleepingThreshold(objectId);
|
|
}
|
|
}
|
|
|
|
|
|
private native float getAngularSleepingThreshold(long objectId);
|
|
private native float getAngularSleepingThreshold(long objectId);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Read the X-component of this body's angular factor.
|
|
|
|
+ *
|
|
|
|
+ * @return the X-component of the angular factor
|
|
|
|
+ */
|
|
public float getAngularFactor() {
|
|
public float getAngularFactor() {
|
|
return getAngularFactor(null).getX();
|
|
return getAngularFactor(null).getX();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Copy this body's angular factors.
|
|
|
|
+ *
|
|
|
|
+ * @param store storage for the result (modified if not null)
|
|
|
|
+ * @return a vector (either the provided storage or a new vector, not null)
|
|
|
|
+ */
|
|
public Vector3f getAngularFactor(Vector3f store) {
|
|
public Vector3f getAngularFactor(Vector3f store) {
|
|
- // doing like this prevent from breaking the API
|
|
|
|
|
|
+ // Done this way to prevent breaking the API.
|
|
if (store == null) {
|
|
if (store == null) {
|
|
store = new Vector3f();
|
|
store = new Vector3f();
|
|
}
|
|
}
|
|
@@ -655,16 +895,33 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void getAngularFactor(long objectId, Vector3f vec);
|
|
private native void getAngularFactor(long objectId, Vector3f vec);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's angular factor.
|
|
|
|
+ *
|
|
|
|
+ * @param factor the desired angular factor for all axes (not null,
|
|
|
|
+ * unaffected, default=1)
|
|
|
|
+ */
|
|
public void setAngularFactor(float factor) {
|
|
public void setAngularFactor(float factor) {
|
|
setAngularFactor(objectId, new Vector3f(factor, factor, factor));
|
|
setAngularFactor(objectId, new Vector3f(factor, factor, factor));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's angular factors.
|
|
|
|
+ *
|
|
|
|
+ * @param factor the desired angular factor for each axis (not null,
|
|
|
|
+ * unaffected, default=(1,1,1))
|
|
|
|
+ */
|
|
public void setAngularFactor(Vector3f factor) {
|
|
public void setAngularFactor(Vector3f factor) {
|
|
setAngularFactor(objectId, factor);
|
|
setAngularFactor(objectId, factor);
|
|
}
|
|
}
|
|
|
|
|
|
private native void setAngularFactor(long objectId, Vector3f factor);
|
|
private native void setAngularFactor(long objectId, Vector3f factor);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Copy this body's linear factors.
|
|
|
|
+ *
|
|
|
|
+ * @return a new vector (not null)
|
|
|
|
+ */
|
|
public Vector3f getLinearFactor() {
|
|
public Vector3f getLinearFactor() {
|
|
Vector3f vec = new Vector3f();
|
|
Vector3f vec = new Vector3f();
|
|
getLinearFactor(objectId, vec);
|
|
getLinearFactor(objectId, vec);
|
|
@@ -673,6 +930,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
private native void getLinearFactor(long objectId, Vector3f vec);
|
|
private native void getLinearFactor(long objectId, Vector3f vec);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Alter this body's linear factors.
|
|
|
|
+ *
|
|
|
|
+ * @param factor the desired linear factor for each axis (not null,
|
|
|
|
+ * unaffected, default=(1,1,1))
|
|
|
|
+ */
|
|
public void setLinearFactor(Vector3f factor) {
|
|
public void setLinearFactor(Vector3f factor) {
|
|
setLinearFactor(objectId, factor);
|
|
setLinearFactor(objectId, factor);
|
|
}
|
|
}
|
|
@@ -681,7 +944,9 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * do not use manually, joints are added automatically
|
|
|
|
|
|
+ * Do not invoke directly! Joints are added automatically when created.
|
|
|
|
+ *
|
|
|
|
+ * @param joint the joint to add (not null)
|
|
*/
|
|
*/
|
|
public void addJoint(PhysicsJoint joint) {
|
|
public void addJoint(PhysicsJoint joint) {
|
|
if (!joints.contains(joint)) {
|
|
if (!joints.contains(joint)) {
|
|
@@ -690,21 +955,32 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
|
|
+ * Do not invoke directly! Joints are removed automatically when destroyed.
|
|
|
|
+ *
|
|
|
|
+ * @param joint the joint to remove (not null)
|
|
*/
|
|
*/
|
|
public void removeJoint(PhysicsJoint joint) {
|
|
public void removeJoint(PhysicsJoint joint) {
|
|
joints.remove(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.
|
|
|
|
- * @return list of active joints connected to this PhysicsRigidBody
|
|
|
|
|
|
+ * Access the list of joints connected with this body.
|
|
|
|
+ * <p>
|
|
|
|
+ * This list is only filled when the PhysicsRigidBody is added to a physics
|
|
|
|
+ * space.
|
|
|
|
+ *
|
|
|
|
+ * @return the pre-existing list (not null)
|
|
*/
|
|
*/
|
|
public List<PhysicsJoint> getJoints() {
|
|
public List<PhysicsJoint> getJoints() {
|
|
return joints;
|
|
return joints;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Serialize this body, for example when saving to a J3O file.
|
|
|
|
+ *
|
|
|
|
+ * @param e exporter (not null)
|
|
|
|
+ * @throws IOException from exporter
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public void write(JmeExporter e) throws IOException {
|
|
public void write(JmeExporter e) throws IOException {
|
|
super.write(e);
|
|
super.write(e);
|
|
@@ -738,6 +1014,12 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
|
|
capsule.writeSavableArrayList(joints, "joints", null);
|
|
capsule.writeSavableArrayList(joints, "joints", null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * De-serialize this body, for example when loading from a J3O file.
|
|
|
|
+ *
|
|
|
|
+ * @param e importer (not null)
|
|
|
|
+ * @throws IOException from importer
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public void read(JmeImporter e) throws IOException {
|
|
public void read(JmeImporter e) throws IOException {
|
|
super.read(e);
|
|
super.read(e);
|