Package com.jme3.bullet.objects
Class PhysicsGhostObject
java.lang.Object
com.jme3.bullet.NativePhysicsObject
com.jme3.bullet.collision.PhysicsCollisionObject
com.jme3.bullet.objects.PhysicsGhostObject
- All Implemented Interfaces:
com.jme3.export.Savable
,com.jme3.util.clone.JmeCloneable
,Cloneable
,Comparable<NativePhysicsObject>
- Direct Known Subclasses:
GhostControl
A collision object for intangibles, based on Bullet's
btPairCachingGhostObject
. This is useful for creating a character
controller, collision sensors/triggers, explosions etc.
Overlap detection skips the narrow-phase collision-detection algorithm and
relies entirely on the broad-phase algorithm, which is AABB plus a margin of
about 0.06 world units. Precise collision detection is still available via
PhysicsSpace.addCollisionListener()
.
From Bullet manual:
btGhostObject is a special btCollisionObject, useful for fast localized
collision queries.
-
Field Summary
Fields inherited from class com.jme3.bullet.collision.PhysicsCollisionObject
COLLISION_GROUP_01, COLLISION_GROUP_02, COLLISION_GROUP_03, COLLISION_GROUP_04, COLLISION_GROUP_05, COLLISION_GROUP_06, COLLISION_GROUP_07, COLLISION_GROUP_08, COLLISION_GROUP_09, COLLISION_GROUP_10, COLLISION_GROUP_11, COLLISION_GROUP_12, COLLISION_GROUP_13, COLLISION_GROUP_14, COLLISION_GROUP_15, COLLISION_GROUP_16, COLLISION_GROUP_NONE, logger
Fields inherited from class com.jme3.bullet.NativePhysicsObject
loggerN
-
Constructor Summary
ModifierConstructorDescriptionprotected
No-argument constructor needed by SavableClassUtil.PhysicsGhostObject
(CollisionShape shape) Instantiate a ghost object with the specified CollisionShape. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(com.jme3.util.clone.Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.getOverlapping
(int index) Access an overlapping collision object by its position in the list.int
Count how many collision objects this object overlaps.Update and access a list of overlapping objects.void
read
(com.jme3.export.JmeImporter importer) De-serialize this object from the specified importer, for example when loading from a J3O file.void
setCollisionShape
(CollisionShape collisionShape) Apply the specified CollisionShape to this object.void
setPhysicsLocation
(com.jme3.math.Vector3f location) Directly alter the location of the ghost's center.void
setPhysicsLocationDp
(com.simsilica.mathd.Vec3d location) Directly alter the location of the ghost's center.void
setPhysicsRotation
(com.jme3.math.Matrix3f orientation) Directly alter the ghost's orientation.void
setPhysicsRotation
(com.jme3.math.Quaternion orientation) Directly alter the ghost's orientation.void
setPhysicsRotationDp
(com.simsilica.mathd.Matrix3d orientation) Directly alter the ghost's orientation.void
setPhysicsRotationDp
(com.simsilica.mathd.Quatd orientation) Directly alter the ghost's orientation.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.collision.PhysicsCollisionObject
activate, addCollideWithGroup, addToIgnoreList, attachCollisionShape, boundingBox, clearIgnoreList, cloneIgnoreList, collisionFlags, copyPcoProperties, countIgnored, debugMeshInitListener, debugMeshNormals, debugMeshResolution, debugNumSides, finalizeNative, findInstance, getActivationState, getAnisotropicFriction, getApplicationData, getCcdMotionThreshold, getCcdSquareMotionThreshold, getCcdSweptSphereRadius, getCollideWithGroups, getCollisionGroup, getCollisionShape, getCollisionSpace, getContactDamping, getContactProcessingThreshold, getContactStiffness, getDeactivationTime, getDebugMaterial, getFriction, getInternalType, getPhysicsLocation, getPhysicsLocation, getPhysicsLocationDp, getPhysicsRotation, getPhysicsRotationDp, getPhysicsRotationMatrix, getPhysicsRotationMatrixDp, getRestitution, getRollingFriction, getScale, getSpinningFriction, getTransform, getUserObject, hasAnisotropicFriction, ignores, initUserPointer, isActive, isContactResponse, isInWorld, isStatic, jmeClone, listIgnoredPcos, proxyGroup, proxyMask, readPcoProperties, removeCollideWithGroup, removeFromIgnoreList, setActivationState, setAnisotropicFriction, setApplicationData, setCcdMotionThreshold, setCcdSweptSphereRadius, setCollideWithGroups, setCollisionFlags, setCollisionGroup, setContactDamping, setContactProcessingThreshold, setContactStiffness, setDeactivationTime, setDebugMaterial, setDebugMeshInitListener, setDebugMeshNormals, setDebugMeshResolution, setDebugNumSides, setFriction, setIgnoreList, setLocationAndBasis, setRestitution, setRollingFriction, setSpinningFriction, setUserIndex, setUserIndex2, setUserIndex3, setUserObject, spaceId, toString, userIndex, userIndex2, userIndex3
Methods inherited from class com.jme3.bullet.NativePhysicsObject
compareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, unassignNativeObject
-
Field Details
-
logger2
message logger for this class
-
-
Constructor Details
-
PhysicsGhostObject
protected PhysicsGhostObject()No-argument constructor needed by SavableClassUtil. -
PhysicsGhostObject
Instantiate a ghost object with the specified CollisionShape. The new object is not added to any CollisionSpace.- Parameters:
shape
- the desired shape (not null, alias created)
-
-
Method Details
-
getOverlapping
Access an overlapping collision object by its position in the list. Important:getOverlappingObjects()
must be invoked first!- Parameters:
index
- which list position (≥0, <count)- Returns:
- the pre-existing object
-
getOverlappingCount
public int getOverlappingCount()Count how many collision objects this object overlaps.- Returns:
- the count (≥0)
-
getOverlappingObjects
Update and access a list of overlapping objects.- Returns:
- an internal list which may get reused (not null)
-
setPhysicsLocation
public void setPhysicsLocation(com.jme3.math.Vector3f location) Directly alter the location of the ghost's center.- Parameters:
location
- the desired location (in physics-space coordinates, not null, finite, unaffected)
-
setPhysicsLocationDp
public void setPhysicsLocationDp(com.simsilica.mathd.Vec3d location) Directly alter the location of the ghost's center.- Parameters:
location
- the desired location (in physics-space coordinates, not null, unaffected)
-
setPhysicsRotation
public void setPhysicsRotation(com.jme3.math.Matrix3f orientation) Directly alter the ghost's orientation.- Parameters:
orientation
- the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
-
setPhysicsRotation
public void setPhysicsRotation(com.jme3.math.Quaternion orientation) Directly alter the ghost's orientation.- Parameters:
orientation
- the desired orientation (a rotation quaternion in physics-space coordinates, not null, not zero, unaffected)
-
setPhysicsRotationDp
public void setPhysicsRotationDp(com.simsilica.mathd.Matrix3d orientation) Directly alter the ghost's orientation.- Parameters:
orientation
- the desired orientation (a rotation matrix in physics-space coordinates, not null, unaffected)
-
setPhysicsRotationDp
public void setPhysicsRotationDp(com.simsilica.mathd.Quatd orientation) Directly alter the ghost's orientation.- Parameters:
orientation
- the desired orientation (a rotation quaternion in physics-space coordinates, not null, unaffected)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned object into a deep-cloned one, using the specified Cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfacecom.jme3.util.clone.JmeCloneable
- Overrides:
cloneFields
in classPhysicsCollisionObject
- Parameters:
cloner
- the Cloner that's cloning this object (not null)original
- the instance from which this object was shallow-cloned (not null, unaffected)
-
setCollisionShape
Apply the specified CollisionShape to this object. Note that the object should not be in any CollisionSpace while changing shape; the object gets rebuilt on the physics side.- Overrides:
setCollisionShape
in classPhysicsCollisionObject
- Parameters:
collisionShape
- the shape to apply (not null, alias created)
-
read
De-serialize this object from the specified importer, for example when loading from a J3O file.- Specified by:
read
in interfacecom.jme3.export.Savable
- Overrides:
read
in classPhysicsCollisionObject
- 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
- Overrides:
write
in classPhysicsCollisionObject
- Parameters:
exporter
- (not null)- Throws:
IOException
- from the exporter
-