< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_physx4 library
Description
gh_physx4 is the module that manages NVIDIA PhysX 4 engine. Thanks to gh_physx4, you will be able to play with rigid body collisions, and handling joints. Clothes and particles are no longer part of PhysX 4.
Number of functions: 75
- gh_physx4.actor_add_force ()
- gh_physx4.actor_add_force_at_position ()
- gh_physx4.actor_apply_transform ()
- gh_physx4.actor_get_transform_mat16 ()
- gh_physx4.actor_get_transform_pos_qrot ()
- gh_physx4.actor_clear_forces ()
- gh_physx4.actor_get_angular_speed2 ()
- gh_physx4.actor_get_angular_velocity ()
- gh_physx4.actor_get_linear_speed2 ()
- gh_physx4.actor_get_linear_velocity ()
- gh_physx4.actor_get_orientation ()
- gh_physx4.actor_get_position ()
- gh_physx4.actor_get_sleep_threshold ()
- gh_physx4.actor_is_sleeping ()
- gh_physx4.actor_kill ()
- gh_physx4.actor_put_to_sleep ()
- gh_physx4.actor_set_3d_object ()
- gh_physx4.actor_set_angular_damping ()
- gh_physx4.actor_set_angular_velocity ()
- gh_physx4.actor_set_euler_angles ()
- gh_physx4.actor_set_gravity_state ()
- gh_physx4.actor_set_kinematic_state ()
- gh_physx4.actor_set_kinematic_target ()
- gh_physx4.actor_set_linear_damping ()
- gh_physx4.actor_set_linear_velocity ()
- gh_physx4.actor_set_material ()
- gh_physx4.actor_set_orientation ()
- gh_physx4.actor_set_position ()
- gh_physx4.actor_set_sleep_threshold ()
- gh_physx4.actor_set_solver_iterations ()
- gh_physx4.actor_update_mass ()
- gh_physx4.actor_wake_up ()
- gh_physx4.check_results ()
- gh_physx4.create_actor_box ()
- gh_physx4.create_actor_capsule ()
- gh_physx4.create_actor_mesh ()
- gh_physx4.create_actor_mesh_v2 ()
- gh_physx4.create_actor_plane ()
- gh_physx4.create_actor_sphere ()
- gh_physx4.create_material ()
- gh_physx4.create_scene ()
- gh_physx4.create_scene_broadphase_abp ()
- gh_physx4.create_scene_broadphase_gpu ()
- gh_physx4.create_scene_broadphase_mbp ()
- gh_physx4.create_scene_broadphase_sap ()
- gh_physx4.fetch_results ()
- gh_physx4.gpu_get_clock_frequency_khz ()
- gh_physx4.gpu_get_name ()
- gh_physx4.gpu_get_num_multiprocessors ()
- gh_physx4.gpu_get_total_memory_size_mb ()
- gh_physx4.gpu_is_supported ()
- gh_physx4.joint_create ()
- gh_physx4.joint_distance_set_distances ()
- gh_physx4.joint_distance_set_spring ()
- gh_physx4.joint_kill ()
- gh_physx4.joint_prismatic_set_limits ()
- gh_physx4.joint_revolute_set_angular_limits ()
- gh_physx4.joint_revolute_set_rotational_limits ()
- gh_physx4.joint_set_break_force ()
- gh_physx4.joint_set_motor_params ()
- gh_physx4.joint_spherical_set_limit_cone ()
- gh_physx4.kill_material ()
- gh_physx4.run_simulation ()
- gh_physx4.run_simulation_step ()
- gh_physx4.scene_sync_3d_objects ()
- gh_physx4.set_max_depenetration_velocity ()
- gh_physx4.set_scene_gravity ()
- gh_physx4.set_simulation_scales ()
- gh_physx4.set_solver_iteration_counts ()
- gh_physx4.start ()
- gh_physx4.stop ()
- gh_physx4.update_material ()
- gh_physx4.scene_sync_3d_objects_v2 ()
- gh_physx4.scene_get_num_active_actors ()
- gh_physx4.create_scene_set_solver_type ()
actor_add_force
Description
Adds a force to an actor.
Syntax
gh_physx4.actor_add_force(
actor_id,
fx, fy, fz
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- fx, fy, fz [REAL]: force
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_add_force(actor_id, fx, fy, fz)
actor_add_force_at_position
Description
Adds a force to an actor at a particular position.
Syntax
gh_physx4.actor_add_force_at_position(
actor_id,
fx, fy, fz,
px, py, pz
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- fx, fy, fz [REAL]: force
- px, py, pz [REAL]: position
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
actor_apply_transform
Description
Applies the transformation (position + orientation) of an PhysX actor to a regular 3D object (a mesh for example).
Syntax
gh_physx4.actor_apply_transform(
actor_id,
obj_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- obj_id [ID]: object identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_apply_transform(actor_id, obj_id)
actor_get_transform_mat16
Description
Returns the transformation matrix of a physics actor.
Syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx4.actor_get_transform_mat16(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
- m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 [REAL]: the 16 floats that make the 4x4 matrix
Code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx4.actor_get_transform_mat16(actor_id)
actor_get_transform_pos_qrot
Description
Returns the position and orientation (quaternion) of a physics actor.
Syntax
px, py, pz, qx, qy, qz, qw = gh_physx4.actor_get_transform_pos_qrot(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
- px, py, pz [REAL]: position
- qx, qy, qz, qw [REAL]: rotation quaternion
Code sample
px, py, pz, qx, qy, qz, qw = gh_physx4.actor_get_transform_pos_qrot(actor_id)
actor_clear_forces
Description
Clears (resets) all forces that act on an actor.
Syntax
gh_physx4.actor_clear_forces(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_clear_forces(actor_id)
actor_get_angular_speed2
Description
Gets the squared angular speed of an actor.
Syntax
s = gh_physx4.actor_get_angular_speed2(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
Code sample
s = gh_physx4.actor_get_angular_speed2(actor_id)
actor_get_angular_velocity
Description
Gets the angular velocity of an actor.
Syntax
x, y, z = gh_physx4.actor_get_angular_velocity(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
- x, y, z [REAL]: velocity vector
Code sample
x, y, z = gh_physx4.actor_get_angular_velocity(actor_id)
actor_get_linear_speed2
Description
Gets the squared linear speed of an actor.
Syntax
speed = gh_physx4.actor_get_linear_speed2(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
- speed [REAL]: squared speed
Code sample
speed = gh_physx4.actor_get_linear_speed2(actor_id)
actor_get_linear_velocity
Description
Gets the linear velocity of an actor.
Syntax
x, y, z = gh_physx4.actor_get_linear_velocity(
actor_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
Return Values
- x, y, z [REAL]: velocity vector
Code sample
x, y, z = ggh_physx4.actor_get_linear_velocity(actor_id)
actor_get_orientation
Description
Gets the orientation of an actor (a quaternion).
Syntax
x, y, z, w = gh_physx4.actor_get_orientation(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
- x, y, z, w [REAL]: orientation
Code sample
x, y, z, w = gh_physx4.actor_get_orientation(actor_id)
actor_get_position
Description
Gets the global position of an actor.
Syntax
x, y, z = gh_physx4.actor_get_position(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
Code sample
x, y, z = gh_physx4.actor_get_position(actor_id)
actor_get_sleep_threshold
Description
Gets the sleep threshold.
Syntax
thres = gh_physx4.actor_get_sleep_threshold(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
Code sample
thres = gh_physx4.actor_get_sleep_threshold(actor_id)
actor_is_sleeping
Description
Gets the sleeping state of an actor.
Syntax
state = gh_physx4.actor_is_sleeping(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
- state [BOOLEAN]: state (0 or 1)
Code sample
is_sleeping = gh_physx4.actor_is_sleeping(actor_id)
actor_kill
Description
Destroys an actor.
Syntax
gh_physx4.actor_kill(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_kill(actor_id)
actor_put_to_sleep
Description
Forces an actor to sleep.
Syntax
gh_physx4.actor_put_to_sleep(
actor_id
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_put_to_sleep(actor_id)
actor_set_3d_object
Description
Allows to associate a physics actor and a 3D object. Useful for the scene_sync_3d_objects() function.
Syntax
gh_physx4.actor_set_3d_object(
actor_id,
o3d_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
- o3d_id [ID]: 3d object identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_3d_object(actor_id, o3d_id)
actor_set_angular_damping
Description
Sets the angular damping of an actor.
Syntax
gh_physx4.actor_set_angular_damping(
actor_id,
damping
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- damping [REAL]: damping
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_angular_damping(actor_id, 0.2)
actor_set_angular_velocity
Description
Sets the angular velocity of an actor.
Syntax
gh_physx4.actor_set_angular_velocity(
actor_id,
vx, vy, vz
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- vx, vy, vz [REAL]: 3D velocity vector
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
actor_set_euler_angles
Description
Sets the orientation of an actor using Euler's angles.
Syntax
gh_physx4.actor_set_euler_angles(
actor_id,
pitch, yaw, roll
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- pitch, yaw, roll [REAL]: Eurler's angles in degrees
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_euler_angles(actor_id, 90, 0, 0)
actor_set_gravity_state
Description
Sets the gravity state of an actor.
Syntax
gh_physx4.actor_set_gravity_state(
actor_id,
state
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- state [BOOLEAN]: state (0 or 1)
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_gravity_state(actor_id, 1)
actor_set_kinematic_state
Description
Sets the kinematic state of an actor.
Syntax
gh_physx4.actor_set_kinematic_state(
actor_id,
state
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- state [BOOLEAN]: state (0 or 1)
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_kinematic_state(actor_id, 1)
actor_set_kinematic_target
Description
Moves kinematically controlled dynamic actors through the 3d world.
Syntax
gh_physx4.actor_set_kinematic_target(
actor_id,
px, py, pz,
pitch, yaw, roll
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- px, py, pz [REAL]: destination position
- pitch, yaw, roll [REAL]: destination orientation
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
actor_set_linear_damping
Description
Sets the linear damping of an actor.
Syntax
gh_physx4.actor_set_linear_damping(
actor_id,
damping
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- damping [REAL]: damping
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_linear_damping(actor_id, 0.2)
actor_set_linear_velocity
Description
Sets the linear velocity of an actor.
Syntax
gh_physx4.actor_set_linear_velocity(
actor_id,
vx, vy, vz
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- vx, vy, vz [REAL]: 3D velocity vector
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_linear_velocity(actor_id, 10, 10, 10)
actor_set_material
Description
Sets a material to an actor.
Syntax
gh_physx4.actor_set_material(
actor_id,
mat_id
)
Languages
Parameters
- actor_id [ID]: actor identifier
- mat_id [ID]: material identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_material(actor_id, mat_id)
actor_set_orientation
Description
Sets the orientation of an actor (a quaternion).
Syntax
gh_physx4.actor_set_orientation(
actor_id,
x, y, z, w
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- x, y, z, w [REAL]: orientation quaternion
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_orientation(actor_id, x, y, z, w)
actor_set_position
Description
Sets the global position of an actor.
Syntax
gh_physx4.actor_set_position(
actor_id,
x, y, z
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- x, y, z [REAL]: position
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_position(actor_id, x, y, z)
actor_set_sleep_threshold
Description
Sets the sleep threshold.
Syntax
gh_physx4.actor_set_sleep_threshold(
actor_id,
thres
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- thres [REAL]: threshold
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_set_sleep_threshold(actor_id, 0.2)
actor_set_solver_iterations
Description
Sets the number of solver iterations for an actor.
Syntax
gh_physx4.actor_set_solver_iterations(
actor_id,
position_iterations,
velocity_iterations
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- position_iterations [INTEGER]: number of position iterations
- velocity_iterations [INTEGER]: number of velocity iterations
Return Values
This function has no return value(s).
Code sample
position_iterations = 4
velocity_iterations = 1
gh_physx4.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
actor_update_mass
Description
Update the mass of an actor from the density.
Syntax
gh_physx4.actor_update_mass(
actor_id,
density
)
Languages
Parameters
- actor_id [ID]: actor identifier
- density [REAL]: density
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_update_mass(actor_id, density)
actor_wake_up
Description
Wakes up an actor.
Syntax
gh_physx4.actor_wake_up(
actor_id,
sleep_counter
)
Languages
Parameters
- actor_id [ID]: PhysX actor identifier
- sleep_counter [REAL]: sleep counter
Return Values
This function has no return value(s).
Code sample
gh_physx4.actor_wake_up(actor_id, 1)
check_results
Description
Checks if results of a simulation step are available.
Syntax
ret = gh_physx4.check_results(
scene_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
Return Values
- ret [BOOLEAN]: available: 1 (true) or 0 (false)
Code sample
if (can_run_sim) then
gh_physx4.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_physx4.check_results(scene_id) == 1) then
gh_physx4.fetch_results(scene_id)
can_run_sim = true
end
create_actor_box
Description
Creates a box actor.
Syntax
actor_id = gh_physx4.create_actor_box(
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- w, h, d [REAL]: width, height and depth
- px, py, pz [REAL]: position
- density [REAL]: density
- mat_id [ID]: material identifier
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
actor_box = gh_physx4.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Description
Creates a capsule actor.
Syntax
actor_id = gh_physx4.create_actor_capsule(
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- radius [REAL]: radius of the capsule (actually the cylinder)
- half_height [REAL]: half height of the cylinder
- px, py, pz [REAL]: position
- density [REAL]: density
- mat_id [ID]: material identifier
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
actor_capsule = gh_physx4.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
create_actor_mesh
Description
Creates an actor from a mesh.
Syntax
actor_id = gh_physx4.create_actor_mesh(
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- mesh_id [ID]: mesh identifier
- px, py, pz [REAL]: position
- density [REAL]: density
- mat_id [ID]: material identifier
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
actor_mesh = gh_physx4.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
create_actor_mesh_v2
Description
Creates an actor from a mesh. You can specify if the mesh is convex or not. Only vertices of a convex mesh are used by PhysX. To be GPU friendly, the number of vertices must not exceed 64.
Syntax
actor_id = gh_physx4.create_actor_mesh_v2(
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- mesh_id [ID]: mesh identifier
- px, py, pz [REAL]: position
- density [REAL]: density
- mat_id [ID]: material identifier
- convex [BOOLEAN]: convex state: 1 (yes) or 0 (no)
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
convex = 1
actor_mesh = gh_physx4.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Description
Creates a plane actor.
Syntax
actor_id = gh_physx4.create_actor_plane(
scene_id,
nx, ny, nz, d,
mat_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- nx, ny, nz, d [REAL]: plane equation
- mat_id [ID]: material identifier
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
actor_plane = gh_physx4.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Description
Creates a sphere actor.
Syntax
actor_id = gh_physx4.create_actor_sphere(
scene_id,
radius,
px, py, pz,
density,
mat_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- radius [REAL]: radius
- px, py, pz [REAL]: position
- density [REAL]: density
- mat_id [ID]: material identifier
Return Values
- actor_id [ID]: PhysX actor identifier
Code sample
actor_sphere = gh_physx4.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
create_material
Description
Creates a PhysX material.
Syntax
mat_id = gh_physx4.create_material(
static_friction,
dynamic_friction,
resilience
)
Languages
Parameters
- static_friction [REAL]: static friction
- dynamic_friction [REAL]: dynamic friction
- resilience [REAL]: resilience
Return Values
- mat_id [ID]: PhysX material identifier
Code sample
mat_id = gh_physx4.create_material(0.5, 0.5, 0.5)
create_scene
Description
Creates a PhysX scene - DEPRECATED
Syntax
scene_id = gh_physx4.create_scene(
gpu_physx,
bounce_threshold_velocity
)
Languages
Parameters
- gpu_physx [BOOLEAN]: 1 (GPU) or 0 (CPU)
- bounce_threshold_velocity [REAL]: bounce threshold velocity
Return Values
- scene_id [ID]: PhysX scene identifier
Code sample
bounce_threshold_velocity = 0.2
scene_id = gh_physx4.create_scene(1, bounce_threshold_velocity)
create_scene_broadphase_abp
Description
Creates a CPU PhysX scene with ABP (revisited implementation of MBP, new in PhysX 4) broadphase algorithm.
Syntax
scene_id = gh_physx4.create_scene_broadphase_abp(
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
Languages
Parameters
- bounce_threshold_velocity [REAL]: bounce threshold velocity
- enable_ccd [BOOLEAN]: CCD: 1 (enabled) or 0 (disabled)
- enable_contact_reporting [BOOLEAN]: contact reporting: 1 (enabled) or 0 (disabled)
- enable_stabilization [BOOLEAN]: stabilization: 1 (enabled) or 0 (disabled)
Return Values
- scene_id [ID]: PhysX scene identifier
Code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_abp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
create_scene_broadphase_gpu
Description
Creates a GPU PhysX scene.
Syntax
scene_id = gh_physx4.create_scene_broadphase_gpu(
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
Languages
Parameters
- bounce_threshold_velocity [REAL]: bounce threshold velocity
- enable_ccd [BOOLEAN]: CCD: 1 (enabled) or 0 (disabled)
- enable_contact_reporting [BOOLEAN]: contact reporting: 1 (enabled) or 0 (disabled)
- enable_stabilization [BOOLEAN]: stabilization: 1 (enabled) or 0 (disabled)
Return Values
- scene_id [ID]: PhysX scene identifier
Code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
create_scene_broadphase_mbp
Description
Creates a CPU PhysX scene with MBP (Multi-Box Pruning) broadphase algorithm.
Syntax
scene_id = gh_physx4.create_scene_broadphase_mbp(
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
Languages
Parameters
- bounce_threshold_velocity [REAL]: bounce threshold velocity
- enable_ccd [BOOLEAN]: CCD: 1 (enabled) or 0 (disabled)
- enable_contact_reporting [BOOLEAN]: contact reporting: 1 (enabled) or 0 (disabled)
- enable_stabilization [BOOLEAN]: stabilization: 1 (enabled) or 0 (disabled)
- minX, minY, minZ [REAL]: world minimal dimension
- maxX, maxY, maxZ [REAL]: world maximal dimension
Return Values
- scene_id [ID]: PhysX scene identifier
Code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
minX = -100
minY = 0
minZ = -100
maxX = 100,
maxY = 100
maxZ = 100
scene_id = gh_physx4.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
create_scene_broadphase_sap
Description
Creates a CPU PhysX scene with SAP (Multi-Box Pruning) broadphase algorithm.
Syntax
scene_id = gh_physx4.create_scene_broadphase_sap(
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
Languages
Parameters
- bounce_threshold_velocity [REAL]: bounce threshold velocity
- enable_ccd [BOOLEAN]: CCD: 1 (enabled) or 0 (disabled)
- enable_contact_reporting [BOOLEAN]: contact reporting: 1 (enabled) or 0 (disabled)
- enable_stabilization [BOOLEAN]: stabilization: 1 (enabled) or 0 (disabled)
Return Values
- scene_id [ID]: PhysX scene identifier
Code sample
bounce_threshold_velocity = 0.2
enable_ccd = 1
enable_contact_reporting = 0
enable_stabilization = 1
scene_id = gh_physx4.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
fetch_results
Description
Fetches the results of a simulation step.
Syntax
ret = gh_physx4.fetch_results(
scene_id
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_physx4.run_simulation_step(scene_id, time_step)
ret = gh_physx4.fetch_results(scene_id)
gpu_get_clock_frequency_khz
Description
Gets the clock speed of the PhysX GPU.
Syntax
clock = gh_physx4.gpu_get_clock_frequency_khz()
Languages
Parameters
This function has no input parameter(s).
Return Values
- clock [INTEGER]: clock speed in kHz
Code sample
clock = gh_physx4.gpu_get_clock_frequency_khz()
gpu_get_name
Description
Gets the name of the PhysX GPU.
Syntax
name = gh_physx4.gpu_get_name()
Languages
Parameters
This function has no input parameter(s).
Return Values
- name [STRING]: name of the GPU
Code sample
gpu_name = gh_physx4.gpu_get_name()
gpu_get_num_multiprocessors
Description
Gets the number of SMs of the PhysX GPU.
Syntax
num_sm = gh_physx4.gpu_get_num_multiprocessors()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_sm [INTEGER]: number of SMs
Code sample
gpu_sm = gh_physx4.gpu_get_num_multiprocessors()
gpu_get_total_memory_size_mb
Description
Gets the size of the PhysX GPU memory.
Syntax
size = gh_physx4.gpu_get_total_memory_size_mb()
Languages
Parameters
This function has no input parameter(s).
Return Values
- size [INTEGER]: size of the memory in MB
Code sample
size = gh_physx4.gpu_get_total_memory_size_mb()
gpu_is_supported
Description
Checks for PhysX GPU support (Windows only).
Syntax
ret = gh_physx4.gpu_is_supported()
Languages
Parameters
This function has no input parameter(s).
Return Values
- ret [BOOLEAN]: supported: 1 (true) or 0 (false)
Code sample
gpu_physx = gh_physx4.gpu_is_supported()
joint_create
Description
Creates a PhysX joint between two PhysX actors.
Syntax
joint_id = gh_physx4.joint_create(
scene_id,
joint_type,
actor1_id,
x1, y1, z1,
pitch1, yaw1, roll1,
actor2_id,
x2, y2, z2,
pitch2, yaw2, roll2
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- joint_type [ENUM]: type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
- actor1_id [ID]: PhysX first actor identifier
- x1, y1, z1 [REAL]: position of the joint related to the first actor
- pitch1, yaw1, roll1 [REAL]: orientation of the joint related to the first actor
- actor2_id [ID]: PhysX second actor identifier
- x2, y2, z2 [REAL]: position of the joint related to the second actor
- pitch2, yaw2, roll2 [REAL]: orientation of the joint related to the second actor
Return Values
- joint_id [ID]: PhysX joint identifier
Code sample
joint_id = gh_physx4.joint_create(scene_id, joint_type, actor1, x1, y1, z1, pitch1, yaw1, roll1, actor2, x2, y2, z2, pitch2, yaw2, roll2)
joint_distance_set_distances
Description
Sets distance joint distance range.
Syntax
gh_physx4.joint_distance_set_distances(
joint_id,
min_distance, max_distance
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- min_distance, max_distance [REAL]: min / max distance of the joint
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_distance_set_distances(joint_id, min_distance, max_distance)
joint_distance_set_spring
Description
Sets distance joint spring parameters.
Syntax
gh_physx4.joint_distance_set_spring(
joint_id,
spring_coef, damping_coef
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- spring_coef, damping_coef [REAL]: spring parameters
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Description
Kills a PhysX joint.
Syntax
gh_physx4.joint_kill(
joint_id
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_kill(joint_id)
joint_prismatic_set_limits
Description
Sets prismatic joint parameters.
Syntax
gh_physx4.joint_prismatic_set_limits(
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- lower_limit, upper_limit [REAL]: the range of the limit. The upper limit must be no lower than the lower limit.
- limit_contact_distance [REAL]: the distance inside the limit value at which the limit will be considered to be active by the solver
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
joint_revolute_set_angular_limits
Description
Sets revolute joint angular limits.
Syntax
gh_physx4.joint_revolute_set_angular_limits(
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- lower_limit, upper_limit [REAL]: the range of the limit. The upper limit must be no lower than the lower limit.
- limit_contact_distance [REAL]: the distance inside the limit value at which the limit will be considered to be active by the solver
- damping [REAL]: damping of the limit spring
- stiffness [REAL]: if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
- restitution [REAL]: controls the amount of bounce when the joint hits a limit
- bounce_threshold [REAL]: determines the minimum impact velocity which will cause the joint to bounce
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
joint_revolute_set_rotational_limits
Description
Sets revolute joint parameters.
Syntax
gh_physx4.joint_revolute_set_rotational_limits(
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- lower_limit, upper_limit [REAL]: the range of the limit. The upper limit must be no lower than the lower limit.
- limit_contact_distance [REAL]: the distance inside the limit value at which the limit will be considered to be active by the solver
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
joint_set_break_force
Description
Set the breaking force of a PhysX joint.
Syntax
gh_physx4.joint_set_break_force(
joint_id,
force, torque
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- force, torque [REAL]: force and torque
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_set_break_force(joint_id, force, torque)
joint_set_motor_params
Description
Sets motor parameters of a revolute joint.
Syntax
gh_physx4.joint_set_motor_params(
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- velocity, max_force [REAL]: parameters
- drive_enabled, free_spin_enabled [BOOLEAN]: drive and free spin parameters: 1 (enabled) or 0 (disabled)
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_set_motor_params(joint_id, velocity, max_force, drive_enabled, free_spin_enabled)
joint_spherical_set_limit_cone
Description
Sets parameters of a spherical joint.
Syntax
gh_physx4.joint_spherical_set_limit_cone(
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
Languages
Parameters
- joint_id [ID]: PhysX joint identifier
- y_limit_angle, z_limit_angle, limit_contact_distance [REAL]: parameters
Return Values
This function has no return value(s).
Code sample
gh_physx4.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Description
Destroys a material.
Syntax
gh_physx4.kill_material(
mat_id
)
Languages
Parameters
- mat_id [ID]: material identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.kill_material(mat_id)
run_simulation
Description
Runs a complete simulation (step + fetch).
Syntax
ret = gh_physx4.run_simulation(
scene_id,
dt,
time_step
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- dt [REAL]: detla time
- time_step [REAL]: simulation time step
Return Values
- ret [BOOLEAN]: simulation done: 1 (true) or 0 (false)
Code sample
ret = gh_physx4.run_simulation(scene_id, dt, time_step)
run_simulation_step
Description
Runs a simulation step.
Syntax
ret = gh_physx4.run_simulation_step(
scene_id,
time_step
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- time_step [REAL]: simulation time step
Return Values
- ret [BOOLEAN]: simulation: 1 (started) or 0 (error)
Code sample
ret = gh_physx4.run_simulation_step(scene_id, time_step)
scene_sync_3d_objects
Description
Synchronizes physics and graphics objects. A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Syntax
gh_physx4.scene_sync_3d_objects(
scene_id
)
Languages
Parameters
- scene_id [ID]: scene identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.scene_sync_3d_objects(scene_id)
set_max_depenetration_velocity
Description
Sets the max depenetration velocity. This a global value applied to each new actor.
Syntax
gh_physx4.set_max_depenetration_velocity(
velocity
)
Languages
Parameters
- velocity [REAL]: depenetration velocity
Return Values
This function has no return value(s).
Code sample
velocity = 3.0
gh_physx4.set_max_depenetration_velocity(velocity)
...
actor_box = gh_physx4.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
set_scene_gravity
Description
Sets the scene gravity vector.
Syntax
gh_physx4.set_scene_gravity(
scene_id,
x, y, z
)
Languages
Parameters
- scene_id [ID]: PhysX scene identifier
- x, y, z [REAL]: gravity vector
Return Values
This function has no return value(s).
Code sample
gh_physx4.set_scene_gravity(scene_id, 0, -9.81, 0)
set_simulation_scales
Description
Sets the various scales to get realistic physics simulations (to avoid the famous Moon effect).
Syntax
gh_physx4.set_simulation_scales(
size,
mass,
speed
)
Languages
Parameters
- size [REAL]: the approximate size of objects in the simulation (default: 1.0)
- mass [REAL]: the approximate mass of a size * size * size block (default: 1000)
- speed [REAL]: the approximate velocities of objects in simulation (default: 10)
Return Values
This function has no return value(s).
Code sample
gh_physx4.set_simulation_scales(1, 1000, 10)
set_solver_iteration_counts
Description
Sets the number of solver iterations. This a global value applied to each new actor.
Syntax
gh_physx4.set_solver_iteration_counts(
position_iterations,
velocity_iterations
)
Languages
Parameters
- position_iterations [INTEGER]: number of position iterations
- velocity_iterations [INTEGER]: number of velocity iterations
Return Values
This function has no return value(s).
Code sample
position_iterations = 4
velocity_iterations = 1
gh_physx4.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_box = gh_physx4.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Description
Starts the PhysX engine.
Syntax
ret = gh_physx4.start()
Languages
Parameters
This function has no input parameter(s).
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_physx4.start()
stop
Description
Stops the PhysX engine.
Syntax
ret = gh_physx4.stop()
Languages
Parameters
This function has no input parameter(s).
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
ret = gh_physx4.stop()
update_material
Description
Updates the properties of a material.
Syntax
gh_physx4.update_material(
mat_id,
static_friction,
dynamic_friction,
resilience
)
Languages
Parameters
- mat_id [ID]: material identifier
- static_friction [REAL]: static friction
- dynamic_friction [REAL]: dynamic friction
- resilience [REAL]: resilience / restitution
Return Values
This function has no return value(s).
Code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_physx4.update_material(mat_id, static_friction, dynamic_friction, resilience)
scene_sync_3d_objects_v2
Description
Synchronizes physics and graphics objects. A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine).
Syntax
gh_physx4.scene_sync_3d_objects_v2(
scene_id
)
Languages
Parameters
- scene_id [ID]: scene identifier
Return Values
This function has no return value(s).
Code sample
gh_physx4.scene_sync_3d_objects_v2(scene_id)
scene_get_num_active_actors
Description
Get the number of active PhysX actors.
Syntax
n = gh_physx4.scene_get_num_active_actors(
scene_id
)
Languages
Parameters
- scene_id [ID]: scene identifier
Return Values
- n [INTEGER]: number of active actors
Code sample
n = gh_physx4.scene_get_num_active_actors(scene_id)
create_scene_set_solver_type
Description
Set the solver that will be used to create a PhysX scene.Synchronizes physics and graphics objects. A physcis actor is associated to a 3D object using the actor_set_3d_object() function.
Compared to scene_sync_3d_objects(), this function synchronizes only PhysX active actors (actors that have been updated by the PhysX engine). If used, create_scene_set_solver_type() must be called before any scene creation function.
Syntax
gh_physx4.create_scene_set_solver_type(
solver_type
)
Languages
Parameters
- solver_type [ENUM]: solver type
Return Values
This function has no return value(s).
Code sample
gh_physx4.create_scene_set_solver_type(solver_type)
| |