Package com.jme3.bullet.objects.infos
Class RigidBodyMotionState
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.objects.infos.RigidBodyMotionState
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
public class RigidBodyMotionState
extends NativePhysicsObject
implements com.jme3.util.clone.JmeCloneable, com.jme3.export.Savable
The motion state (transform) of a rigid body, with thread-safe access.
-
Field Summary
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
applyTransform
(com.jme3.scene.Spatial spatial) If the motion state has been updated, apply the new transform to the specified Spatial.void
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned state into a deep-cloned one, using the specified Cloner and original to resolve copied fields.com.jme3.math.Vector3f
getLocation
(com.jme3.math.Vector3f storeResult) Copy the location to a Vector3f.com.simsilica.mathd.Vec3d
getLocationDp
(com.simsilica.mathd.Vec3d storeResult) Copy the location to a Vector3d.com.jme3.math.Matrix3f
getOrientation
(com.jme3.math.Matrix3f storeResult) Copy the orientation to a Matrix3f.com.jme3.math.Quaternion
getOrientation
(com.jme3.math.Quaternion storeResult) Copy the orientation to a Quaternion.com.simsilica.mathd.Matrix3d
getOrientationMatrixDp
(com.simsilica.mathd.Matrix3d storeResult) Copy the orientation to a Matrix3d.com.simsilica.mathd.Quatd
getOrientationQuaternionDp
(com.simsilica.mathd.Quatd storeResult) Copy the orientation to a Quatd.boolean
Test whether physics-space coordinates should match the spatial's local coordinates.jmeClone()
Create a shallow clone for the JME cloner.com.jme3.math.Transform
physicsTransform
(com.jme3.math.Transform storeResult) Calculate the body's physics transform.void
read
(com.jme3.export.JmeImporter importer) De-serialize this state from the specified importer, for example when loading from a J3O file.void
setApplyPhysicsLocal
(boolean applyPhysicsLocal) Alter whether physics-space coordinates should match the spatial's local coordinates.void
setVehicle
(PhysicsVehicle vehicle) Alter which vehicle uses this motion state.void
write
(com.jme3.export.JmeExporter exporter) Serialize this object to the specified exporter, for example when saving to a J3O file.Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObject
-
Field Details
-
logger
message logger for this class
-
-
Constructor Details
-
RigidBodyMotionState
public RigidBodyMotionState()Instantiate a motion state.
-
-
Method Details
-
applyTransform
public boolean applyTransform(com.jme3.scene.Spatial spatial) If the motion state has been updated, apply the new transform to the specified Spatial.- Parameters:
spatial
- where to apply the physics transform (not null, modified)- Returns:
- true if changed
-
getLocation
public com.jme3.math.Vector3f getLocation(com.jme3.math.Vector3f storeResult) Copy the location to a Vector3f.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the location vector (in physics-space coordinates, either storeResult or a new vector, not null)
-
getLocationDp
public com.simsilica.mathd.Vec3d getLocationDp(com.simsilica.mathd.Vec3d storeResult) Copy the location to a Vector3d.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the location vector (in physics-space coordinates, either storeResult or a new vector, not null, finite)
-
getOrientation
public com.jme3.math.Matrix3f getOrientation(com.jme3.math.Matrix3f storeResult) Copy the orientation to a Matrix3f.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (in physics-space coordinates, either storeResult or a new matrix, not null)
-
getOrientation
public com.jme3.math.Quaternion getOrientation(com.jme3.math.Quaternion storeResult) Copy the orientation to a Quaternion.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (in physics-space coordinates, either storeResult or a new instance, not null)
-
getOrientationMatrixDp
public com.simsilica.mathd.Matrix3d getOrientationMatrixDp(com.simsilica.mathd.Matrix3d storeResult) Copy the orientation to a Matrix3d.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (in physics-space coordinates, either storeResult or a new matrix, not null)
-
getOrientationQuaternionDp
public com.simsilica.mathd.Quatd getOrientationQuaternionDp(com.simsilica.mathd.Quatd storeResult) Copy the orientation to a Quatd.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the orientation (in physics-space coordinates, either storeResult or a new instance, not null)
-
isApplyPhysicsLocal
public boolean isApplyPhysicsLocal()Test whether physics-space coordinates should match the spatial's local coordinates.- Returns:
- true if matching local coordinates, false if matching world coordinates
-
physicsTransform
public com.jme3.math.Transform physicsTransform(com.jme3.math.Transform storeResult) Calculate the body's physics transform.- Parameters:
storeResult
- storage for the result (modified if not null)- Returns:
- the body's transform in physics-space coordinates (either storeResult or a new instance, not null)
-
setApplyPhysicsLocal
public void setApplyPhysicsLocal(boolean applyPhysicsLocal) Alter whether physics-space coordinates should match the spatial's local coordinates.- Parameters:
applyPhysicsLocal
- true→match local coordinates, false→match world coordinates (default=false)
-
setVehicle
Alter which vehicle uses this motion state.- Parameters:
vehicle
- the desired vehicle, or null for none (alias created)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned state into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Parameters:
cloner
- the Cloner that's cloning this state (not null)original
- the instance from which this state was shallow-cloned
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfacecom.jme3.util.clone.JmeCloneable
- Returns:
- a new instance
-
read
De-serialize this state from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Parameters:
importer
- (not null)- Throws:
IOException
- from the importer
-
write
Serialize this object to the specified exporter, for example when saving to a J3O file.- Specified by:
write
in interfacecom.jme3.export.Savable
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-