Package physx.physics

Class PxShape


public class PxShape extends PxRefCounted
Abstract class for collision shapes.

Shapes are shared, reference counted objects.

An instance can be created by calling the createShape() method of the PxRigidActor class, or the createShape() method of the PxPhysics class.

Visualizations

\li PxVisualizationParameter::eCOLLISION_AABBS \li PxVisualizationParameter::eCOLLISION_SHAPES \li PxVisualizationParameter::eCOLLISION_AXES
See Also:
  • Field Details

    • SIZEOF

      public static final int SIZEOF
    • ALIGNOF

      public static final int ALIGNOF
      See Also:
  • Constructor Details

    • PxShape

      protected PxShape()
    • PxShape

      protected PxShape(long address)
  • Method Details

    • wrapPointer

      public static PxShape wrapPointer(long address)
    • arrayGet

      public static PxShape arrayGet(long baseAddress, int index)
    • getUserData

      public NativeObject getUserData()
      *********************************************************************************************
    • setUserData

      public void setUserData(NativeObject value)
      *********************************************************************************************
    • setGeometry

      public void setGeometry(PxGeometry geometry)
      Adjust the geometry of the shape.

      Note: The type of the passed in geometry must match the geometry type of the shape. Note: It is not allowed to change the geometry type of a shape. Note: This function does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry.

      Parameters:
      geometry - New geometry of the shape.
      See Also:
    • getGeometry

      public PxGeometry getGeometry()
      Retrieve a reference to the shape's geometry.

      \warning The returned reference has the same lifetime as the PxShape it comes from.

      Returns:
      Reference to internal PxGeometry object.
      See Also:
    • getActor

      public PxRigidActor getActor()
      Retrieves the actor which this shape is associated with.
      Returns:
      The actor this shape is associated with, if it is an exclusive shape, else NULL
      See Also:
    • setMaterials

      public void setMaterials(PxMaterialPtr materials, short materialCount)
      Assigns material(s) to the shape. Will remove existing materials from the shape.

      Sleeping: Does NOT wake the associated actor up automatically.

      Parameters:
      materials - List of material pointers to assign to the shape. See #PxMaterial
      materialCount - The number of materials provided.
      See Also:
    • getNbMaterials

      public short getNbMaterials()
      Returns the number of materials assigned to the shape.

      You can use #getMaterials() to retrieve the material pointers.

      Returns:
      Number of materials associated with this shape.
      See Also:
    • getMaterials

      public int getMaterials(PxMaterialPtr userBuffer, int bufferSize, int startIndex)
      Retrieve all the material pointers associated with the shape.

      You can retrieve the number of material pointers by calling #getNbMaterials()

      Note: The returned data may contain invalid pointers if you release materials using #PxMaterial::release().

      Parameters:
      userBuffer - The buffer to store the material pointers.
      bufferSize - Size of provided user buffer.
      startIndex - Index of first material pointer to be retrieved
      Returns:
      Number of material pointers written to the buffer.
      See Also:
    • getMaterialFromInternalFaceIndex

      public PxBaseMaterial getMaterialFromInternalFaceIndex(int faceIndex)
      Retrieve material from given triangle index.

      The input index is the internal triangle index as used inside the SDK. This is the index returned to users by various SDK functions such as raycasts.

      This function is only useful for triangle meshes or heightfields, which have per-triangle materials. For other shapes or SDF triangle meshes, the function returns the single material associated with the shape, regardless of the index.

      Parameters:
      faceIndex - The internal triangle index whose material you want to retrieve.
      Returns:
      Material from input triangle

      Note: If faceIndex value of 0xFFFFffff is passed as an input for mesh and heightfield shapes, this function will issue a warning and return NULL. Note: Scene queries set the value of PxQueryHit::faceIndex to 0xFFFFffff whenever it is undefined or does not apply.

      See Also:
    • setContactOffset

      public void setContactOffset(float contactOffset)
      Sets the contact offset.

      Shapes whose distance is less than the sum of their contactOffset values will generate contacts. The contact offset must be positive and greater than the rest offset. Having a contactOffset greater than than the restOffset allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated. This prevents jitter that would occur if the constraint were enforced only when shapes were within the rest distance.

      Default: 0.02f * PxTolerancesScale::length

      Sleeping: Does NOT wake the associated actor up automatically.

      Parameters:
      contactOffset - Range: [maximum(0,restOffset), PX_MAX_F32)
      See Also:
    • getContactOffset

      public float getContactOffset()
      Retrieves the contact offset.
      Returns:
      The contact offset of the shape.
      See Also:
    • setRestOffset

      public void setRestOffset(float restOffset)
      Sets the rest offset.

      Two shapes will come to rest at a distance equal to the sum of their restOffset values. If the restOffset is 0, they should converge to touching exactly. Having a restOffset greater than zero is useful to have objects slide smoothly, so that they do not get hung up on irregularities of each others' surfaces.

      Default: 0.0f

      Sleeping: Does NOT wake the associated actor up automatically.

      Parameters:
      restOffset - Range: (-PX_MAX_F32, contactOffset)
      See Also:
    • getRestOffset

      public float getRestOffset()
      Retrieves the rest offset.
      Returns:
      The rest offset of the shape.
      See Also:
    • setTorsionalPatchRadius

      public void setTorsionalPatchRadius(float radius)
      Sets torsional patch radius.

      This defines the radius of the contact patch used to apply torsional friction. If the radius is 0, no torsional friction will be applied. If the radius is > 0, some torsional friction will be applied. This is proportional to the penetration depth so, if the shapes are separated or penetration is zero, no torsional friction will be applied. It is used to approximate rotational friction introduced by the compression of contacting surfaces.

      Default: 0.0

      Parameters:
      radius - Range: (0, PX_MAX_F32)
    • getTorsionalPatchRadius

      public float getTorsionalPatchRadius()
      Gets torsional patch radius.

      This defines the radius of the contact patch used to apply torsional friction. If the radius is 0, no torsional friction will be applied. If the radius is > 0, some torsional friction will be applied. This is proportional to the penetration depth so, if the shapes are separated or penetration is zero, no torsional friction will be applied. It is used to approximate rotational friction introduced by the compression of contacting surfaces.

      Returns:
      The torsional patch radius of the shape.
    • setMinTorsionalPatchRadius

      public void setMinTorsionalPatchRadius(float radius)
      Sets minimum torsional patch radius.

      This defines the minimum radius of the contact patch used to apply torsional friction. If the radius is 0, the amount of torsional friction that will be applied will be entirely dependent on the value of torsionalPatchRadius.

      If the radius is > 0, some torsional friction will be applied regardless of the value of torsionalPatchRadius or the amount of penetration.

      Default: 0.0

      Parameters:
      radius - Range: (0, PX_MAX_F32)
    • getMinTorsionalPatchRadius

      public float getMinTorsionalPatchRadius()
      Gets minimum torsional patch radius.

      This defines the minimum radius of the contact patch used to apply torsional friction. If the radius is 0, the amount of torsional friction that will be applied will be entirely dependent on the value of torsionalPatchRadius.

      If the radius is > 0, some torsional friction will be applied regardless of the value of torsionalPatchRadius or the amount of penetration.

      Returns:
      The minimum torsional patch radius of the shape.
    • setFlag

      public void setFlag(PxShapeFlagEnum flag, boolean value)
      Sets shape flags

      Sleeping: Does NOT wake the associated actor up automatically.

      Parameters:
      flag - The shape flag to enable/disable. See #PxShapeFlag.
      value - True to set the flag. False to clear the flag specified in flag.

      Default: PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eSCENE_QUERY_SHAPE

      See Also:
    • setFlags

      public void setFlags(PxShapeFlags inFlags)
      Sets shape flags
      See Also:
    • getFlags

      public PxShapeFlags getFlags()
      Retrieves shape flags.
      Returns:
      The values of the shape flags.
      See Also:
    • isExclusive

      public boolean isExclusive()
      Returns true if the shape is exclusive to an actor.
    • setName

      public void setName(String name)
      Sets a name string for the object that can be retrieved with #getName().

      This is for debugging and is not used by the SDK. The string is not copied by the SDK, only the pointer is stored.

      Default: NULL

      Parameters:
      name - The name string to set the objects name to.
      See Also:
    • getName

      public String getName()
      retrieves the name string set with setName().
      Returns:
      The name associated with the shape.
      See Also:
    • setLocalPose

      public void setLocalPose(PxTransform pose)
      Sets the pose of the shape in actor space, i.e. relative to the actors to which they are attached.

      This transformation is identity by default.

      The local pose is an attribute of the shape, and so will apply to all actors to which the shape is attached.

      Sleeping: Does NOT wake the associated actor up automatically.

      Note: Does not automatically update the inertia properties of the owning actor (if applicable); use the PhysX extensions method #PxRigidBodyExt::updateMassAndInertia() to do this.

      Default: the identity transform

      Parameters:
      pose - The new transform from the actor frame to the shape frame. Range: rigid body transform
      See Also:
    • getLocalPose

      public PxTransform getLocalPose()
      Retrieves the pose of the shape in actor space, i.e. relative to the actor they are owned by.

      This transformation is identity by default.

      Returns:
      Pose of shape relative to the actor's frame.
      See Also:
    • setSimulationFilterData

      public void setSimulationFilterData(PxFilterData data)
      Sets the user definable collision filter data.

      Sleeping: Does wake up the actor if the filter data change causes a formerly suppressed collision pair to be enabled.

      Default: (0,0,0,0)

      See Also:
    • getSimulationFilterData

      public PxFilterData getSimulationFilterData()
      Retrieves the shape's collision filter data.
      See Also:
    • setQueryFilterData

      public void setQueryFilterData(PxFilterData data)
      Sets the user definable query filter data.

      Default: (0,0,0,0)

      See Also:
    • getQueryFilterData

      public PxFilterData getQueryFilterData()
      Retrieves the shape's Query filter data.
      See Also: