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

public class BodyCreationSettings extends JoltPhysicsObject implements ConstBodyCreationSettings
Settings used to create a rigid body.
  • 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

      public BodyCreationSettings setAllowDynamicOrKinematic(boolean setting)
      Alter whether a static body can be converted to kinematic or dynamic. (native attribute: mAllowDynamicOrKinematic)
      Parameters:
      setting - true to allow or false to inhibit (default=false)
      Returns:
      the modified settings, for chaining
    • setAllowedDofs

      public BodyCreationSettings setAllowedDofs(int bitmask)
      Alter the body's degrees of freedom. (native attribute: mAllowedDOFs)
      Parameters:
      bitmask - the desired bitmask (see EAllowedDofs for semantics)
      Returns:
      the modified settings, for chaining
    • setAllowSleeping

      public BodyCreationSettings setAllowSleeping(boolean allow)
      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

      public BodyCreationSettings setAngularDamping(float damping)
      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

      public BodyCreationSettings setAngularVelocity(Vec3Arg omega)
      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

      public BodyCreationSettings setApplyGyroscopicForce(boolean setting)
      Alter whether gyroscopic force will be applied. (native attribute: mApplyGyroscopicForce)
      Parameters:
      setting - true to enable the force, or false to disable it
      Returns:
      the modified settings, for chaining
    • setCollisionGroup

      public BodyCreationSettings setCollisionGroup(ConstCollisionGroup group)
      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

      public BodyCreationSettings setEnhancedInternalEdgeRemoval(boolean enhance)
      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

      public BodyCreationSettings setFriction(float friction)
      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

      public BodyCreationSettings setGravityFactor(float factor)
      Alter the gravity multiplier. (native attribute: mGravityFactor)
      Parameters:
      factor - the desired multiplier (default=1)
      Returns:
      the modified settings, for chaining
    • setIsSensor

      public BodyCreationSettings setIsSensor(boolean setting)
      Alter whether the body will be a sensor. (native attribute: mIsSensor)
      Parameters:
      setting - true for a sensor, otherwise false (default=false)
      Returns:
      the modified settings, for chaining
    • setLinearDamping

      public BodyCreationSettings setLinearDamping(float damping)
      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

      public BodyCreationSettings setLinearVelocity(Vec3Arg velocity)
      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

      public BodyCreationSettings setMassPropertiesOverride(MassProperties properties)
      Alter the mass-properties override. (native attribute: mMassPropertiesOverride)
      Parameters:
      properties - the desired properties (not null, unaffected)
      Returns:
      the modified settings, for chaining
    • setMaxAngularVelocity

      public BodyCreationSettings setMaxAngularVelocity(float maxSpeed)
      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

      public BodyCreationSettings setMaxLinearVelocity(float maxSpeed)
      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

      public BodyCreationSettings setMotionQuality(EMotionQuality motionQuality)
      Alter the motion quality. (native attribute: mMotionQuality)
      Parameters:
      motionQuality - the desired quality (not null, default=Discrete)
      Returns:
      the modified settings, for chaining
    • setMotionType

      public BodyCreationSettings setMotionType(EMotionType motionType)
      Alter the motion type. (native attribute: mMotionType)
      Parameters:
      motionType - the desired type (not null, default=Dynamic)
      Returns:
      the modified settings, for chaining
    • setObjectLayer

      public BodyCreationSettings setObjectLayer(int objLayer)
      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

      public BodyCreationSettings setOverrideMassProperties(EOverrideMassProperties setting)
      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

      public BodyCreationSettings 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). (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

      public BodyCreationSettings setPosition(RVec3Arg location)
      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

      public BodyCreationSettings setRestitution(float restitution)
      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

      public BodyCreationSettings setRotation(QuatArg quat)
      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

      public BodyCreationSettings setShape(ConstShape shape)
      Replace the shape.
      Parameters:
      shape - the desired shape (not null, unaffected)
      Returns:
      the modified settings, for chaining
    • setShapeSettings

      public BodyCreationSettings setShapeSettings(ConstShapeSettings shapeSettings)
      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 interface ConstBodyCreationSettings
      Returns:
      true if convertible, otherwise false
    • getAllowedDofs

      public int getAllowedDofs()
      Return the body's degrees of freedom. The settings are unaffected. (native attribute: mAllowedDOFs)
      Specified by:
      getAllowedDofs in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      true if allowed, otherwise false
    • getAngularDamping

      public float getAngularDamping()
      Return the angular damping constant. The settings are unaffected. (native attribute: mAngularDamping)
      Specified by:
      getAngularDamping in interface ConstBodyCreationSettings
      Returns:
      the constant (in units of per second, ≥0, ≤1)
    • getAngularVelocity

      public Vec3 getAngularVelocity()
      Copy the (initial) angular velocity. The settings are unaffected. (native attribute: mAngularVelocity)
      Specified by:
      getAngularVelocity in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      true if enabled, otherwise false
    • getCollisionGroup

      public CollisionGroup getCollisionGroup()
      Access the collision group to which the body will belong. (native attribute: mCollisionGroup)
      Specified by:
      getCollisionGroup in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      true for extra effort, otherwise false
    • getFriction

      public float getFriction()
      Return the friction ratio. The settings are unaffected. (native attribute: mFriction)
      Specified by:
      getFriction in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      true for a sensor, otherwise false
    • getLinearDamping

      public float getLinearDamping()
      Return the linear damping constant. The settings are unaffected. (native attribute: mLinearDamping)
      Specified by:
      getLinearDamping in interface ConstBodyCreationSettings
      Returns:
      the constant (in units of per second, ≥0, ≤1)
    • getLinearVelocity

      public Vec3 getLinearVelocity()
      Copy the (initial) linear velocity. The settings are unaffected. (native attribute: mLinearVelocity)
      Specified by:
      getLinearVelocity in interface ConstBodyCreationSettings
      Returns:
      a new velocity vector (meters per second in system coordinates)
    • getMassProperties

      public MassProperties getMassProperties()
      Calculate the mass and inertia. The settings are unaffected.
      Specified by:
      getMassProperties in interface ConstBodyCreationSettings
      Returns:
      a new JVM object with a new native object assigned
    • getMassPropertiesOverride

      public MassProperties getMassPropertiesOverride()
      Access the mass-properties override. (native attribute: mMassPropertiesOverride)
      Specified by:
      getMassPropertiesOverride in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      the maximum speed (in meters per second)
    • getMotionQuality

      public EMotionQuality getMotionQuality()
      Return the motion quality. The settings are unaffected. (native attribute: mMotionQuality)
      Specified by:
      getMotionQuality in interface ConstBodyCreationSettings
      Returns:
      an enum value (not null)
    • getMotionType

      public EMotionType getMotionType()
      Return the motion type. The settings are unaffected. (native attribute: mMotionType)
      Specified by:
      getMotionType in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      the layer index (≥0, <numObjectLayers)
    • getOverrideMassProperties

      public EOverrideMassProperties getOverrideMassProperties()
      Return how the mass-properties override will be used. The settings are unaffected. (native attribute: mOverrideMassProperties)
      Specified by:
      getOverrideMassProperties in interface ConstBodyCreationSettings
      Returns:
      an enum value (not null)
    • getPosition

      public RVec3 getPosition()
      Copy the (initial) location. The settings are unaffected. (native attribute: mPosition)
      Specified by:
      getPosition in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      the ratio (typically ≥0 and ≤1)
    • getRotation

      public Quat getRotation()
      Copy the (initial) orientation of the body's axes. The settings are unaffected. (native attribute: mRotation)
      Specified by:
      getRotation in interface ConstBodyCreationSettings
      Returns:
      a new rotation quaternion (relative to the system axes)
    • getShape

      public ConstShape getShape()
      Acquire read-only access to the Shape. The settings are unaffected.
      Specified by:
      getShape in interface ConstBodyCreationSettings
      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 interface ConstBodyCreationSettings
      Returns:
      true if calculated, otherwise false