public class PhysicsSpace
extends java.lang.Object
PhysicsSpace - The central jbullet-jme physics space
Modifier and Type | Class and Description |
---|---|
static class |
PhysicsSpace.BroadphaseType
interface with Broadphase types
|
Modifier and Type | Field and Description |
---|---|
static int |
AXIS_X
index of the X axis
|
static int |
AXIS_Y
index of the Y axis
|
static int |
AXIS_Z
index of the Z axis
|
Constructor and Description |
---|
PhysicsSpace() |
PhysicsSpace(PhysicsSpace.BroadphaseType broadphaseType) |
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax) |
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Object obj)
adds an object to the physics space
|
void |
addAll(Spatial spatial)
adds all physics controls and joints in the given spatial node to the physics space
(e.g.
|
void |
addCollisionGroupListener(PhysicsCollisionGroupListener listener,
int collisionGroup)
Adds a listener for a specific collision group, such a listener can disable collisions when they happen.
There can be only one listener per collision group. |
void |
addCollisionListener(PhysicsCollisionListener listener)
Adds a CollisionListener that will be informed about collision events
|
void |
addCollisionObject(PhysicsCollisionObject obj) |
void |
addTickListener(PhysicsTickListener listener)
Adds the specified listener to the physics tick listeners.
|
void |
applyGravity()
applies gravity value to all objects
|
void |
clearForces()
clears forces of all objects
|
void |
create()
Has to be called from the (designated) physics thread
|
void |
destroy()
destroys the current PhysicsSpace so that a new one can be created
|
void |
distributeEvents() |
<V> java.util.concurrent.Future<V> |
enqueue(java.util.concurrent.Callable<V> callable)
calls the callable on the next physics tick (ensuring e.g.
|
static <V> java.util.concurrent.Future<V> |
enqueueOnThisThread(java.util.concurrent.Callable<V> callable) |
float |
getAccuracy()
get the current accuracy of the physics computation
|
PhysicsSpace.BroadphaseType |
getBroadphaseType() |
java.util.Collection<PhysicsCharacter> |
getCharacterList() |
com.bulletphysics.dynamics.DynamicsWorld |
getDynamicsWorld()
used internally
|
java.util.Collection<PhysicsGhostObject> |
getGhostObjectList() |
Vector3f |
getGravity(Vector3f gravity)
Gets the gravity of the PhysicsSpace
|
java.util.Collection<PhysicsJoint> |
getJointList() |
static PhysicsSpace |
getPhysicsSpace()
Get the current PhysicsSpace running on this thread
For parallel physics, this can also be called from the OpenGL thread to receive the PhysicsSpace |
java.util.Collection<PhysicsRigidBody> |
getRigidBodyList() |
int |
getSolverNumIterations() |
java.util.Collection<PhysicsVehicle> |
getVehicleList() |
Vector3f |
getWorldMax() |
Vector3f |
getWorldMin() |
java.util.List<PhysicsRayTestResult> |
rayTest(Vector3f from,
Vector3f to)
Performs a ray collision test and returns the results as a list of PhysicsRayTestResults
|
java.util.List<PhysicsRayTestResult> |
rayTest(Vector3f from,
Vector3f to,
java.util.List<PhysicsRayTestResult> results)
Performs a ray collision test and returns the results as a list of PhysicsRayTestResults
|
void |
remove(java.lang.Object obj)
removes an object from the physics space
|
void |
removeAll(Spatial spatial)
Removes all physics controls and joints in the given spatial from the physics space
(e.g.
|
void |
removeCollisionGroupListener(int collisionGroup) |
void |
removeCollisionListener(PhysicsCollisionListener listener)
Removes a CollisionListener from the list
|
void |
removeCollisionObject(PhysicsCollisionObject obj) |
void |
removeTickListener(PhysicsTickListener listener) |
void |
setAccuracy(float accuracy)
sets the accuracy of the physics computation, default=1/60s
|
void |
setBroadphaseType(PhysicsSpace.BroadphaseType broadphaseType) |
void |
setGravity(Vector3f gravity)
Sets the gravity of the PhysicsSpace, set before adding physics objects!
|
static void |
setLocalThreadPhysicsSpace(PhysicsSpace space)
Used internally
|
void |
setMaxSubSteps(int steps)
Sets the maximum amount of extra steps that will be used to step the physics
when the fps is below the physics fps.
|
void |
setSolverNumIterations(int numIterations)
Set the number of iterations used by the contact solver.
|
void |
setWorldMax(Vector3f worldMax)
only applies for AXIS_SWEEP broadphase
|
void |
setWorldMin(Vector3f worldMin)
only applies for AXIS_SWEEP broadphase
|
java.util.List<PhysicsSweepTestResult> |
sweepTest(CollisionShape shape,
Transform start,
Transform end)
Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults
You have to use different Transforms for start and end (at least distance greater than 0.4f). |
java.util.List<PhysicsSweepTestResult> |
sweepTest(CollisionShape shape,
Transform start,
Transform end,
java.util.List<PhysicsSweepTestResult> results)
Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults
You have to use different Transforms for start and end (at least distance greater than 0.4f). |
void |
update(float time)
updates the physics space
|
void |
update(float time,
int maxSteps)
updates the physics space, uses maxSteps
|
public static final int AXIS_X
public static final int AXIS_Y
public static final int AXIS_Z
public PhysicsSpace()
public PhysicsSpace(PhysicsSpace.BroadphaseType broadphaseType)
public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType)
public static PhysicsSpace getPhysicsSpace()
public static void setLocalThreadPhysicsSpace(PhysicsSpace space)
space
- public void create()
public void update(float time)
time
- the current time valuepublic void update(float time, int maxSteps)
time
- the current time valuemaxSteps
- public void distributeEvents()
public static <V> java.util.concurrent.Future<V> enqueueOnThisThread(java.util.concurrent.Callable<V> callable)
public <V> java.util.concurrent.Future<V> enqueue(java.util.concurrent.Callable<V> callable)
V
- callable
- public void add(java.lang.Object obj)
obj
- the PhysicsControl or Spatial with PhysicsControl to addpublic void addCollisionObject(PhysicsCollisionObject obj)
public void remove(java.lang.Object obj)
obj
- the PhysicsControl or Spatial with PhysicsControl to removepublic void removeCollisionObject(PhysicsCollisionObject obj)
public void addAll(Spatial spatial)
spatial
- the rootnode containing the physics objectspublic void removeAll(Spatial spatial)
spatial
- the rootnode containing the physics objectspublic java.util.Collection<PhysicsRigidBody> getRigidBodyList()
public java.util.Collection<PhysicsGhostObject> getGhostObjectList()
public java.util.Collection<PhysicsCharacter> getCharacterList()
public java.util.Collection<PhysicsJoint> getJointList()
public java.util.Collection<PhysicsVehicle> getVehicleList()
public void setGravity(Vector3f gravity)
gravity
- public Vector3f getGravity(Vector3f gravity)
gravity
- public void applyGravity()
public void clearForces()
public void addTickListener(PhysicsTickListener listener)
listener
- public void removeTickListener(PhysicsTickListener listener)
public void addCollisionListener(PhysicsCollisionListener listener)
listener
- the CollisionListener to addpublic void removeCollisionListener(PhysicsCollisionListener listener)
listener
- the CollisionListener to removepublic void addCollisionGroupListener(PhysicsCollisionGroupListener listener, int collisionGroup)
listener
- collisionGroup
- public void removeCollisionGroupListener(int collisionGroup)
public java.util.List<PhysicsRayTestResult> rayTest(Vector3f from, Vector3f to)
public java.util.List<PhysicsRayTestResult> rayTest(Vector3f from, Vector3f to, java.util.List<PhysicsRayTestResult> results)
public java.util.List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end)
public java.util.List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, java.util.List<PhysicsSweepTestResult> results)
public void destroy()
public com.bulletphysics.dynamics.DynamicsWorld getDynamicsWorld()
public PhysicsSpace.BroadphaseType getBroadphaseType()
public void setBroadphaseType(PhysicsSpace.BroadphaseType broadphaseType)
public void setMaxSubSteps(int steps)
steps
- The maximum number of extra steps, default is 4.public float getAccuracy()
public void setAccuracy(float accuracy)
accuracy
- public Vector3f getWorldMin()
public void setWorldMin(Vector3f worldMin)
worldMin
- public Vector3f getWorldMax()
public void setWorldMax(Vector3f worldMax)
worldMax
- public void setSolverNumIterations(int numIterations)
numIterations
- The number of iterations used by the contact and constraint solver.public int getSolverNumIterations()