Class PxTriangleMesh


public class PxTriangleMesh extends PxRefCounted
A triangle mesh, also called a 'polygon soup'.

It is represented as an indexed triangle list. There are no restrictions on the triangle data.

To avoid duplicating data when you have several instances of a particular mesh positioned differently, you do not use this class to represent a mesh object directly. Instead, you create an instance of this mesh via the PxTriangleMeshGeometry and PxShape classes.

Creation

To create an instance of this class call PxPhysics::createTriangleMesh(), and release() to delete it. This is only possible once you have released all of its PxShape instances.

Visualizations:

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

    • SIZEOF

      public static final int SIZEOF
    • ALIGNOF

      public static final int ALIGNOF
      See Also:
  • Constructor Details

    • PxTriangleMesh

      protected PxTriangleMesh()
    • PxTriangleMesh

      protected PxTriangleMesh(long address)
  • Method Details

    • wrapPointer

      public static PxTriangleMesh wrapPointer(long address)
    • arrayGet

      public static PxTriangleMesh arrayGet(long baseAddress, int index)
    • getNbVertices

      public int getNbVertices()
      Returns the number of vertices.
      Returns:
      number of vertices
      See Also:
    • getVertices

      public PxVec3 getVertices()
      Returns the vertices.
      Returns:
      array of vertices
      See Also:
    • getVerticesForModification

      public PxVec3 getVerticesForModification()
      Returns all mesh vertices for modification.

      This function will return the vertices of the mesh so that their positions can be changed in place. After modifying the vertices you must call refitBVH for the refitting to actually take place. This function maintains the old mesh topology (triangle indices).

      Returns:
      inplace vertex coordinates for each existing mesh vertex.

      Note: It is recommended to use this feature for scene queries only. Note: Size of array returned is equal to the number returned by getNbVertices(). Note: This function operates on cooked vertex indices. Note: This means the index mapping and vertex count can be different from what was provided as an input to the cooking routine. Note: To achieve unchanged 1-to-1 index mapping with orignal mesh data (before cooking) please use the following cooking flags: Note: eWELD_VERTICES = 0, eDISABLE_CLEAN_MESH = 1. Note: It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled.

      See Also:
    • refitBVH

      public PxBounds3 refitBVH()
      Refits BVH for mesh vertices.

      This function will refit the mesh BVH to correctly enclose the new positions updated by getVerticesForModification. Mesh BVH will not be reoptimized by this function so significantly different new positions will cause significantly reduced performance.

      Returns:
      New bounds for the entire mesh.

      Note: For PxMeshMidPhase::eBVH34 trees the refit operation is only available on non-quantized trees (see PxBVH34MidphaseDesc::quantized) Note: PhysX does not keep a mapping from the mesh to mesh shapes that reference it. Note: Call PxShape::setGeometry on each shape which references the mesh, to ensure that internal data structures are updated to reflect the new geometry. Note: PxShape::setGeometry does not guarantee correct/continuous behavior when objects are resting on top of old or new geometry. Note: It is also recommended to make sure that a call to validateTriangleMesh returns true if mesh cleaning is disabled. Note: Active edges information will be lost during refit, the rigid body mesh contact generation might not perform as expected.

      See Also:
    • getNbTriangles

      public int getNbTriangles()
      Returns the number of triangles.
      Returns:
      number of triangles
      See Also:
    • getTriangles

      public NativeObject getTriangles()
      Returns the triangle indices.

      The indices can be 16 or 32bit depending on the number of triangles in the mesh. Call getTriangleMeshFlags() to know if the indices are 16 or 32 bits.

      The number of indices is the number of triangles * 3.

      Returns:
      array of triangles
      See Also:
    • getTriangleMeshFlags

      public PxTriangleMeshFlags getTriangleMeshFlags()
      Reads the PxTriangleMesh flags.

      See the list of flags #PxTriangleMeshFlag

      Returns:
      The values of the PxTriangleMesh flags.
      See Also:
    • getTrianglesRemap

      public PxU32ConstPtr getTrianglesRemap()
      Returns the triangle remapping table.

      The triangles are internally sorted according to various criteria. Hence the internal triangle order does not always match the original (user-defined) order. The remapping table helps finding the old indices knowing the new ones:

      remapTable[ internalTriangleIndex ] = originalTriangleIndex

      Returns:
      the remapping table (or NULL if 'PxCookingParams::suppressTriangleMeshRemapTable' has been used)
      See Also:
    • getTriangleMaterialIndex

      public short getTriangleMaterialIndex(int triangleIndex)
      Returns material table index of given triangle

      This function takes a post cooking triangle index.

      Parameters:
      triangleIndex - (internal) index of desired triangle
      Returns:
      Material table index, or 0xffff if no per-triangle materials are used
    • getLocalBounds

      public PxBounds3 getLocalBounds()
      Returns the local-space (vertex space) AABB from the triangle mesh.
      Returns:
      local-space bounds