Package physx.physics

Class PxPhysics

java.lang.Object
physx.NativeObject
physx.physics.PxPhysics

public class PxPhysics extends NativeObject
Abstract singleton factory class used for instancing objects in the Physics SDK.

In addition you can use PxPhysics to set global parameters which will effect all scenes and create objects that can be shared across multiple scenes.

You can get an instance of this class by calling PxCreatePhysics().

See Also:
  • Field Details

    • SIZEOF

      public static final int SIZEOF
    • ALIGNOF

      public static final int ALIGNOF
      See Also:
  • Constructor Details

    • PxPhysics

      protected PxPhysics()
    • PxPhysics

      protected PxPhysics(long address)
  • Method Details

    • wrapPointer

      public static PxPhysics wrapPointer(long address)
    • arrayGet

      public static PxPhysics arrayGet(long baseAddress, int index)
    • destroy

      public void destroy()
    • release

      public void release()
      Destroys the instance it is called on.

      Use this release method to destroy an instance of this class. Be sure to not keep a reference to this object after calling release. Avoid release calls while a scene is simulating (in between simulate() and fetchResults() calls).

      Note that this must be called once for each prior call to PxCreatePhysics, as there is a reference counter. Also note that you mustn't destroy the PxFoundation instance (holding the allocator, error callback etc.) until after the reference count reaches 0 and the SDK is actually removed.

      Releasing an SDK will also release any objects created through it (scenes, triangle meshes, convex meshes, heightfields, shapes etc.), provided the user hasn't already done so.

      Note: Releasing the PxPhysics instance is a prerequisite to releasing the PxFoundation instance.

      See Also:
    • getFoundation

      public PxFoundation getFoundation()
      Retrieves the Foundation instance.
      Returns:
      A reference to the Foundation object.
    • createAggregate

      public PxAggregate createAggregate(int maxActor, int maxShape, boolean enableSelfCollision)
      Creates an aggregate with the specified maximum size and filtering hint.

      The previous API used "bool enableSelfCollision" which should now silently evaluates to a PxAggregateType::eGENERIC aggregate with its self-collision bit.

      Use PxAggregateType::eSTATIC or PxAggregateType::eKINEMATIC for aggregates that will only contain static or kinematic actors. This provides faster filtering when used in combination with PxPairFilteringMode.

      Returns:
      The new aggregate.
      See Also:
    • getTolerancesScale

      public PxTolerancesScale getTolerancesScale()
      Returns the simulation tolerance parameters.
      Returns:
      The current simulation tolerance parameters.
    • createScene

      public PxScene createScene(PxSceneDesc sceneDesc)
      Creates a scene.

      Note: Every scene uses a Thread Local Storage slot. This imposes a platform specific limit on the number of scenes that can be created.

      Returns:
      The new scene object.
      See Also:
    • createRigidStatic

      public PxRigidStatic createRigidStatic(PxTransform pose)
      Creates a static rigid actor with the specified pose and all other fields initialized to their default values.
      See Also:
    • createRigidDynamic

      public PxRigidDynamic createRigidDynamic(PxTransform pose)
      Creates a dynamic rigid actor with the specified pose and all other fields initialized to their default values.
      See Also:
    • createShape

      public PxShape createShape(PxGeometry geometry, PxMaterial material)
      Creates a shape which may be attached to multiple actors

      The shape will be created with a reference count of 1.

      Returns:
      The shape

      Note: Shared shapes are not mutable when they are attached to an actor

      See Also:
    • createShape

      public PxShape createShape(PxGeometry geometry, PxMaterial material, boolean isExclusive)
      Creates a shape which may be attached to multiple actors

      The shape will be created with a reference count of 1.

      Returns:
      The shape

      Note: Shared shapes are not mutable when they are attached to an actor

      See Also:
    • createShape

      public PxShape createShape(PxGeometry geometry, PxMaterial material, boolean isExclusive, PxShapeFlags shapeFlags)
      Creates a shape which may be attached to multiple actors

      The shape will be created with a reference count of 1.

      Returns:
      The shape

      Note: Shared shapes are not mutable when they are attached to an actor

      See Also:
    • createTriangleMesh

      public PxTriangleMesh createTriangleMesh(PxInputData stream)
      Creates a triangle mesh object.

      This can then be instanced into #PxShape objects.

      Returns:
      The new triangle mesh.
      See Also:
    • createConvexMesh

      public PxConvexMesh createConvexMesh(PxInputData stream)
      Creates a convex mesh object.

      This can then be instanced into #PxShape objects.

      Returns:
      The new convex mesh.
      See Also:
    • getNbShapes

      public int getNbShapes()
      Return the number of shapes that currently exist.
      Returns:
      Number of shapes.
    • createArticulationReducedCoordinate

      public PxArticulationReducedCoordinate createArticulationReducedCoordinate()
      Creates a reduced-coordinate articulation with all fields initialized to their default values.
      Returns:
      the new articulation
      See Also:
    • createMaterial

      public PxMaterial createMaterial(float staticFriction, float dynamicFriction, float restitution)
      Creates a new rigid body material with certain default properties.
      Returns:
      The new rigid body material.
      See Also:
    • getPhysicsInsertionCallback

      public PxInsertionCallback getPhysicsInsertionCallback()
      Gets PxPhysics object insertion interface.

      The insertion interface is needed for PxCreateTriangleMesh, PxCooking::createTriangleMesh etc., this allows runtime mesh creation.

      PxCooking::createTriangleMesh PxCooking::createHeightfield PxCooking::createTetrahedronMesh PxCooking::createBVH

    • createPBDParticleSystem

      public PxPBDParticleSystem createPBDParticleSystem(PxCudaContextManager cudaContextManager)
      Creates a particle system with a position-based dynamics (PBD) solver.

      A PBD particle system can be used to simulate particle systems with fluid and granular particles. It also allows simulating cloth using mass-spring constraints and rigid bodies by shape matching the bodies with particles.

      In order to accelerate neighborhood finding for particle-particle interactions (e.g.: for fluid density constraints) a regular grid is used. This grid is built every time step but may provide inaccurate neighborhood information during the solver iterations. The neighborhood scale parameter can be used to configure the grid such that it provides a more conservative neighborhood at the cost of run-time performance.

      The neighborhood scale parameter should typically not be much larger than 1.

      The maxNeighborhood defines how many particles fit into the neighborhood, at the cost of memory.

      Both maxNeighborhood and neighborhoodScale should be set as low as possible for performance, but high enough to not cause any behavioral degredation.

      Parameters:
      cudaContextManager - The PxCudaContextManager this instance is tied to.
      Returns:
      the new particle system
      See Also:
    • createPBDParticleSystem

      public PxPBDParticleSystem createPBDParticleSystem(PxCudaContextManager cudaContextManager, int maxNeighborhood)
      Creates a particle system with a position-based dynamics (PBD) solver.

      A PBD particle system can be used to simulate particle systems with fluid and granular particles. It also allows simulating cloth using mass-spring constraints and rigid bodies by shape matching the bodies with particles.

      In order to accelerate neighborhood finding for particle-particle interactions (e.g.: for fluid density constraints) a regular grid is used. This grid is built every time step but may provide inaccurate neighborhood information during the solver iterations. The neighborhood scale parameter can be used to configure the grid such that it provides a more conservative neighborhood at the cost of run-time performance.

      The neighborhood scale parameter should typically not be much larger than 1.

      The maxNeighborhood defines how many particles fit into the neighborhood, at the cost of memory.

      Both maxNeighborhood and neighborhoodScale should be set as low as possible for performance, but high enough to not cause any behavioral degredation.

      Parameters:
      cudaContextManager - The PxCudaContextManager this instance is tied to.
      maxNeighborhood - The maximum number of particles considered in neighborhood-based particle interaction calculations.
      Returns:
      the new particle system
      See Also:
    • createParticleBuffer

      public PxParticleBuffer createParticleBuffer(int maxParticles, int maxVolumes, PxCudaContextManager cudaContextManager)
      Create particle buffer to simulate fluid/granular material.
      Parameters:
      maxParticles - The maximum number of particles in this buffer.
      maxVolumes - The maximum number of volumes in this buffer. See PxParticleVolume.
      cudaContextManager - The PxCudaContextManager this buffer is tied to.
      Returns:
      PxParticleBuffer instance
      See Also:
    • createParticleClothBuffer

      public PxParticleClothBuffer createParticleClothBuffer(int maxParticles, int maxNumVolumes, int maxNumCloths, int maxNumTriangles, int maxNumSprings, PxCudaContextManager cudaContextManager)
      Create a particle buffer to simulate particle cloth.
      Parameters:
      maxParticles - The maximum number of particles in this buffer.
      maxNumVolumes - The maximum number of volumes in this buffer. See #PxParticleVolume.
      maxNumCloths - The maximum number of cloths in this buffer. See #PxParticleCloth.
      maxNumTriangles - The maximum number of triangles for aerodynamics.
      maxNumSprings - The maximum number of springs to connect particles. See #PxParticleSpring.
      cudaContextManager - The PxCudaContextManager this buffer is tied to.
      Returns:
      PxParticleClothBuffer instance
      See Also:
    • createPBDMaterial

      public PxPBDMaterial createPBDMaterial(float friction, float damping, float adhesion, float viscosity, float vorticityConfinement, float surfaceTension, float cohesion, float lift, float drag)
      Creates a new PBD material with certain default properties.
      Returns:
      The new PBD material.
      See Also:
    • createPBDMaterial

      public PxPBDMaterial createPBDMaterial(float friction, float damping, float adhesion, float viscosity, float vorticityConfinement, float surfaceTension, float cohesion, float lift, float drag, float cflCoefficient)
      Creates a new PBD material with certain default properties.
      Returns:
      The new PBD material.
      See Also:
    • createPBDMaterial

      public PxPBDMaterial createPBDMaterial(float friction, float damping, float adhesion, float viscosity, float vorticityConfinement, float surfaceTension, float cohesion, float lift, float drag, float cflCoefficient, float gravityScale)
      Creates a new PBD material with certain default properties.
      Returns:
      The new PBD material.
      See Also: