Package com.github.stephengold.joltjni
Class BodyCreationSettings
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.BodyCreationSettings
- All Implemented Interfaces:
ConstBodyCreationSettings
,ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
Part
Settings used to create a rigid body.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate default settings.BodyCreationSettings
(ConstShape shape, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape.BodyCreationSettings
(ConstShapeSettings shapeSettings, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape settings.BodyCreationSettings
(ShapeRef shapeRef, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape reference. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test whether a static body can be converted to kinematic or dynamic.int
Return the body's degrees of freedom.boolean
Test whether the created body will be allowed to fall asleep.float
Return the angular damping constant.Copy the (initial) angular velocity.boolean
Test whether the gyroscopic force will be applied.Access the collision group to which the body will belong.boolean
Test whether extra effort should be made to remove ghost contacts.float
Return the friction ratio.float
Return the gravity factor.boolean
Test whether the body will be a sensor.float
Return the linear damping constant.Copy the (initial) linear velocity.Calculate the mass and inertia.Access the mass-properties override.float
Return the maximum angular speed.float
Return the maximum linear speed.Return the motion quality.Return the motion type.int
Return the index of the object layer.Return how the mass-properties override will be used.Copy the (initial) location.float
Return the restitution ratio.Copy the (initial) orientation of the body's axes.getShape()
Acquire read-only access to theShape
.boolean
Test whether the body's mass properties will be calculated.setAllowDynamicOrKinematic
(boolean setting) Alter whether a static body can be converted to kinematic or dynamic.setAllowedDofs
(int bitmask) Alter the body's degrees of freedom.setAllowSleeping
(boolean allow) Alter whether the created body will be allowed to fall asleep.setAngularDamping
(float damping) Alter the angular damping constant.setAngularVelocity
(Vec3Arg omega) Alter the (initial) angular velocity.setApplyGyroscopicForce
(boolean setting) Alter whether gyroscopic force will be applied.Alter the collision group to which the body will belong.setEnhancedInternalEdgeRemoval
(boolean enhance) Alter whether extra effort should be made to remove ghost contacts.setFriction
(float friction) Alter the friction ratio.setGravityFactor
(float factor) Alter the gravity multiplier.setIsSensor
(boolean setting) Alter whether the body will be a sensor.setLinearDamping
(float damping) Alter the linear damping constant.setLinearVelocity
(Vec3Arg velocity) Alter the (initial) linear velocity.setMassPropertiesOverride
(MassProperties properties) Alter the mass-properties override.setMaxAngularVelocity
(float maxSpeed) Alter the maximum angular speed.setMaxLinearVelocity
(float maxSpeed) Alter the maximum linear speed.setMotionQuality
(EMotionQuality motionQuality) Alter the motion quality.setMotionType
(EMotionType motionType) Alter the motion type.setObjectLayer
(int objLayer) Alter the object layer.Alter how the mass-properties override will be used.setPosition
(double xx, double yy, double zz) Alter the (initial) location of the body's origin (which might not coincide with its center of mass).setPosition
(RVec3Arg location) Alter the (initial) location of the body's origin (which might not coincide with its center of mass).setRestitution
(float restitution) Alter the restitution ratio for collisions.setRotation
(QuatArg quat) Alter the (initial) orientation of the body's axes.setShape
(ConstShape shape) Replace the shape.setShapeSettings
(ConstShapeSettings shapeSettings) Replace the shape settings.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
BodyCreationSettings
public BodyCreationSettings()Instantiate default settings. -
BodyCreationSettings
public BodyCreationSettings(ConstShape shape, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape.- Parameters:
shape
- the desired shape (not null)loc
- the desired location (not null, unaffected)orient
- the desired orientation (not null, unaffected)motionType
- the desired motion type (not null)objLayer
- the ID of the desired object layer (≥0)
-
BodyCreationSettings
public BodyCreationSettings(ShapeRef shapeRef, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape reference.- Parameters:
shapeRef
- a reference to the desired shape (not null)loc
- the desired location (not null, unaffected)orient
- the desired orientation (not null, unaffected)motionType
- the desired motion type (not null)objLayer
- the ID of the desired object layer
-
BodyCreationSettings
public BodyCreationSettings(ConstShapeSettings shapeSettings, RVec3Arg loc, QuatArg orient, EMotionType motionType, int objLayer) Instantiate settings for the specified shape settings.- Parameters:
shapeSettings
- the desired shape settings (not null)loc
- the desired location (not null, unaffected)orient
- the desired orientation (not null, unaffected)motionType
- the desired motion type (not null)objLayer
- the ID of the desired object layer
-
-
Method Details
-
setAllowDynamicOrKinematic
Alter whether a static body can be converted to kinematic or dynamic. (native attribute: mAllowDynamicOrKinematic)- Parameters:
setting
-true
to allow orfalse
to inhibit (default=false)- Returns:
- the modified settings, for chaining
-
setAllowedDofs
Alter the body's degrees of freedom. (native attribute: mAllowedDOFs)- Parameters:
bitmask
- the desired bitmask (seeEAllowedDofs
for semantics)- Returns:
- the modified settings, for chaining
-
setAllowSleeping
Alter whether the created body will be allowed to fall asleep. (native attribute: mAllowSleeping)- Parameters:
allow
-true
to allow,false
to inhibit (default=true)- Returns:
- the modified settings, for chaining
-
setAngularDamping
Alter the angular damping constant. (native attribute: mAngularDamping)- Parameters:
damping
- the desired value (in units of per second, ≥0, ≤1, default=0.05)- Returns:
- the modified settings, for chaining
-
setAngularVelocity
Alter the (initial) angular velocity. (native attribute: mAngularVelocity)- Parameters:
omega
- the desired angular velocity (radians per second in system coordinates, not null, unaffected, default=(0,0,0))- Returns:
- the modified settings, for chaining
-
setApplyGyroscopicForce
Alter whether gyroscopic force will be applied. (native attribute: mApplyGyroscopicForce)- Parameters:
setting
-true
to enable the force, orfalse
to disable it- Returns:
- the modified settings, for chaining
-
setCollisionGroup
Alter the collision group to which the body will belong. (native attribute: mCollisionGroup)- Parameters:
group
- the desired group (not null, unaffected)- Returns:
- the modified settings, for chaining
-
setEnhancedInternalEdgeRemoval
Alter whether extra effort should be made to remove ghost contacts.- Parameters:
enhance
-true
for extra effort,false
for ordinary effort (default=false)- Returns:
- the modified settings, for chaining
-
setFriction
Alter the friction ratio. (native attribute: mFriction)- Parameters:
friction
- the desired ratio (typically ≥0 and ≤1, default=0.2)- Returns:
- the modified settings, for chaining
-
setGravityFactor
Alter the gravity multiplier. (native attribute: mGravityFactor)- Parameters:
factor
- the desired multiplier (default=1)- Returns:
- the modified settings, for chaining
-
setIsSensor
Alter whether the body will be a sensor. (native attribute: mIsSensor)- Parameters:
setting
-true
for a sensor, otherwisefalse
(default=false)- Returns:
- the modified settings, for chaining
-
setLinearDamping
Alter the linear damping constant. (native attribute: mLinearDamping)- Parameters:
damping
- the desired value (in units of per second, ≥0, ≤1, default=0.05)- Returns:
- the modified settings, for chaining
-
setLinearVelocity
Alter the (initial) linear velocity. (native attribute: mLinearVelocity)- Parameters:
velocity
- the desired velocity (in system coordinates, not null, unaffected, default=(0,0,0))- Returns:
- the modified settings, for chaining
-
setMassPropertiesOverride
Alter the mass-properties override. (native attribute: mMassPropertiesOverride)- Parameters:
properties
- the desired properties (not null, unaffected)- Returns:
- the modified settings, for chaining
-
setMaxAngularVelocity
Alter the maximum angular speed. (native attribute: mMaxAngularVelocity)- Parameters:
maxSpeed
- the desired maximum speed (in radians per second, ≥0, default=15*pi)- Returns:
- the modified settings, for chaining
-
setMaxLinearVelocity
Alter the maximum linear speed. (native attribute: mMaxLinearVelocity)- Parameters:
maxSpeed
- the desired maximum speed (in meters per second, ≥0, default=500)- Returns:
- the modified settings, for chaining
-
setMotionQuality
Alter the motion quality. (native attribute: mMotionQuality)- Parameters:
motionQuality
- the desired quality (not null, default=Discrete)- Returns:
- the modified settings, for chaining
-
setMotionType
Alter the motion type. (native attribute: mMotionType)- Parameters:
motionType
- the desired type (not null, default=Dynamic)- Returns:
- the modified settings, for chaining
-
setObjectLayer
Alter the object layer. (native attribute: mObjectLayer)- Parameters:
objLayer
- the index of the desired object layer (≥0, <numObjectLayers, <65536, default=0)- Returns:
- the modified settings, for chaining
-
setOverrideMassProperties
Alter how the mass-properties override will be used. (native attribute: mOverrideMassProperties)- Parameters:
setting
- an enum value (not null, default=CalculateMassAndInertia)- Returns:
- the modified settings, for chaining
-
setPosition
Alter the (initial) location of the body's origin (which might not coincide with its center of mass). (native attribute: mPosition)- Parameters:
xx
- the desired X coordinate (in system coordinates, default=0)yy
- the desired Y coordinate (in system coordinates, default=0)zz
- the desired Z coordinate (in system coordinates, default=0)- Returns:
- the modified settings, for chaining
-
setPosition
Alter the (initial) location of the body's origin (which might not coincide with its center of mass). (native attribute: mPosition)- Parameters:
location
- the desired location (in system coordinates, not null, unaffected, default=(0,0,0))- Returns:
- the modified settings, for chaining
-
setRestitution
Alter the restitution ratio for collisions. (native attribute: mRestitution)- Parameters:
restitution
- the desired ratio (typically ≥0 and ≤1, default=0)- Returns:
- the modified settings, for chaining
-
setRotation
Alter the (initial) orientation of the body's axes. (native attribute: mRotation)- Parameters:
quat
- the desired rotation (relative to the system axes, not null, normalized, unaffected, default=(0,0,0,1))- Returns:
- the modified settings, for chaining
-
setShape
Replace the shape.- Parameters:
shape
- the desired shape (not null, unaffected)- Returns:
- the modified settings, for chaining
-
setShapeSettings
Replace the shape settings.- Parameters:
shapeSettings
- the desired shape settings (not null)- Returns:
- the modified settings, for chaining
-
getAllowDynamicOrKinematic
public boolean getAllowDynamicOrKinematic()Test whether a static body can be converted to kinematic or dynamic. The settings are unaffected. (native attribute: mAllowDynamicOrKinematic)- Specified by:
getAllowDynamicOrKinematic
in interfaceConstBodyCreationSettings
- Returns:
true
if convertible, otherwisefalse
-
getAllowedDofs
public int getAllowedDofs()Return the body's degrees of freedom. The settings are unaffected. (native attribute: mAllowedDOFs)- Specified by:
getAllowedDofs
in interfaceConstBodyCreationSettings
- Returns:
- a bitmask (see
EAllowedDofs
for semantics)
-
getAllowSleeping
public boolean getAllowSleeping()Test whether the created body will be allowed to fall asleep. The settings are unaffected. (native attribute: mAllowSleeping)- Specified by:
getAllowSleeping
in interfaceConstBodyCreationSettings
- Returns:
true
if allowed, otherwisefalse
-
getAngularDamping
public float getAngularDamping()Return the angular damping constant. The settings are unaffected. (native attribute: mAngularDamping)- Specified by:
getAngularDamping
in interfaceConstBodyCreationSettings
- Returns:
- the constant (in units of per second, ≥0, ≤1)
-
getAngularVelocity
Copy the (initial) angular velocity. The settings are unaffected. (native attribute: mAngularVelocity)- Specified by:
getAngularVelocity
in interfaceConstBodyCreationSettings
- Returns:
- a new velocity vector (radians per second in system coordinates)
-
getApplyGyroscopicForce
public boolean getApplyGyroscopicForce()Test whether the gyroscopic force will be applied. The settings are unaffected. (native attribute: mApplyGyroscopicForce)- Specified by:
getApplyGyroscopicForce
in interfaceConstBodyCreationSettings
- Returns:
true
if enabled, otherwisefalse
-
getCollisionGroup
Access the collision group to which the body will belong. (native attribute: mCollisionGroup)- Specified by:
getCollisionGroup
in interfaceConstBodyCreationSettings
- Returns:
- a new JVM object with the pre-existing native object assigned
-
getEnhancedInternalEdgeRemoval
public boolean getEnhancedInternalEdgeRemoval()Test whether extra effort should be made to remove ghost contacts. The settings are unaffected.- Specified by:
getEnhancedInternalEdgeRemoval
in interfaceConstBodyCreationSettings
- Returns:
true
for extra effort, otherwisefalse
-
getFriction
public float getFriction()Return the friction ratio. The settings are unaffected. (native attribute: mFriction)- Specified by:
getFriction
in interfaceConstBodyCreationSettings
- Returns:
- the ratio (typically ≥0 and ≤1)
-
getGravityFactor
public float getGravityFactor()Return the gravity factor. The settings are unaffected. (native attribute: mGravityFactor)- Specified by:
getGravityFactor
in interfaceConstBodyCreationSettings
- Returns:
- the factor
-
getIsSensor
public boolean getIsSensor()Test whether the body will be a sensor. The settings are unaffected. (native attribute: mIsSensor)- Specified by:
getIsSensor
in interfaceConstBodyCreationSettings
- Returns:
true
for a sensor, otherwisefalse
-
getLinearDamping
public float getLinearDamping()Return the linear damping constant. The settings are unaffected. (native attribute: mLinearDamping)- Specified by:
getLinearDamping
in interfaceConstBodyCreationSettings
- Returns:
- the constant (in units of per second, ≥0, ≤1)
-
getLinearVelocity
Copy the (initial) linear velocity. The settings are unaffected. (native attribute: mLinearVelocity)- Specified by:
getLinearVelocity
in interfaceConstBodyCreationSettings
- Returns:
- a new velocity vector (meters per second in system coordinates)
-
getMassProperties
Calculate the mass and inertia. The settings are unaffected.- Specified by:
getMassProperties
in interfaceConstBodyCreationSettings
- Returns:
- a new JVM object with a new native object assigned
-
getMassPropertiesOverride
Access the mass-properties override. (native attribute: mMassPropertiesOverride)- Specified by:
getMassPropertiesOverride
in interfaceConstBodyCreationSettings
- Returns:
- a new JVM object with the pre-existing native object assigned
-
getMaxAngularVelocity
public float getMaxAngularVelocity()Return the maximum angular speed. The settings are unaffected. (native attribute: mMaxAngularVelocity)- Specified by:
getMaxAngularVelocity
in interfaceConstBodyCreationSettings
- Returns:
- the maximum speed (in radians per second)
-
getMaxLinearVelocity
public float getMaxLinearVelocity()Return the maximum linear speed. The settings are unaffected. (native attribute: mMaxLinearVelocity)- Specified by:
getMaxLinearVelocity
in interfaceConstBodyCreationSettings
- Returns:
- the maximum speed (in meters per second)
-
getMotionQuality
Return the motion quality. The settings are unaffected. (native attribute: mMotionQuality)- Specified by:
getMotionQuality
in interfaceConstBodyCreationSettings
- Returns:
- an enum value (not null)
-
getMotionType
Return the motion type. The settings are unaffected. (native attribute: mMotionType)- Specified by:
getMotionType
in interfaceConstBodyCreationSettings
- Returns:
- an enum value (not null)
-
getObjectLayer
public int getObjectLayer()Return the index of the object layer. The settings are unaffected. (native attribute: mObjectLayer)- Specified by:
getObjectLayer
in interfaceConstBodyCreationSettings
- Returns:
- the layer index (≥0, <numObjectLayers)
-
getOverrideMassProperties
Return how the mass-properties override will be used. The settings are unaffected. (native attribute: mOverrideMassProperties)- Specified by:
getOverrideMassProperties
in interfaceConstBodyCreationSettings
- Returns:
- an enum value (not null)
-
getPosition
Copy the (initial) location. The settings are unaffected. (native attribute: mPosition)- Specified by:
getPosition
in interfaceConstBodyCreationSettings
- Returns:
- a new location vector (in system coordinates, all components finite)
-
getRestitution
public float getRestitution()Return the restitution ratio. The settings are unaffected. (native attribute: mRestitution)- Specified by:
getRestitution
in interfaceConstBodyCreationSettings
- Returns:
- the ratio (typically ≥0 and ≤1)
-
getRotation
Copy the (initial) orientation of the body's axes. The settings are unaffected. (native attribute: mRotation)- Specified by:
getRotation
in interfaceConstBodyCreationSettings
- Returns:
- a new rotation quaternion (relative to the system axes)
-
getShape
Acquire read-only access to theShape
. The settings are unaffected.- Specified by:
getShape
in interfaceConstBodyCreationSettings
- Returns:
- a new JVM object with the pre-existing native object assigned, or
null
-
hasMassProperties
public boolean hasMassProperties()Test whether the body's mass properties will be calculated. The settings are unaffected.- Specified by:
hasMassProperties
in interfaceConstBodyCreationSettings
- Returns:
true
if calculated, otherwisefalse
-