GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



» Back to Reference Guide Index

gh_physx3 Library

Description

gh_physx3 is the module that manages NVIDIA PhysX 3 engine. Thanks to gh_physx3, you will be able to create rigid bodies and do collisions, create particles and fluids, creates clothes and joints.

Number of functions: 52



gh_physx3.start

Description

starts the PhysX engine.

Languages

Lua - Python

Parameters

This function has no input parameter(s).

Return Values

  • ret [INTEGER]: returns 1 of ok, returns 0 if error

    Code sample


    ret = gh_physx3.start()



    gh_physx3.stop

    Description

    stops the PhysX engine.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • ret [INTEGER]: returns 1 of ok, returns 0 if error

    Code sample


    ret = gh_physx3.stop()



    gh_physx3.gpu_is_supported

    Description

    checks for PhysX GPU support (Windows only).

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • ret [INTEGER]: returns 1 supported, returns 0 if not supported

    Code sample


    gpu_physx = gh_physx3.gpu_is_supported()



    gh_physx3.gpu_get_name

    Description

    gets the name of the PhysX GPU.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • name [STRING]: name of the GPU

    Code sample


    gpu_name = gh_physx3.gpu_get_name()



    gh_physx3.gpu_get_num_multiprocessors

    Description

    gets the number of SMs of the PhysX GPU.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • sm [INTEGER]: number of SMs

    Code sample


    gpu_sm = gh_physx3.gpu_get_num_multiprocessors()



    gh_physx3.gpu_get_clock_frequency_khz

    Description

    gets the clock speed of the PhysX GPU.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • clock [INTEGER]: clock speed in kHz

    Code sample


    clock = gh_physx3.gpu_get_clock_frequency_khz()



    gh_physx3.gpu_get_total_memory_size_mb

    Description

    gets the size of the PhysX GPU memory.

    Languages

    Lua - Python

    Parameters

    This function has no input parameter(s).

    Return Values

  • size [INTEGER]: size of the memory in MB

    Code sample


    size = gh_physx3.gpu_get_total_memory_size_mb()



    gh_physx3.set_simulation_scales

    Description

    Sets the various scales to get realistic physics simulations (to avoid the famous Moon effect)

    Languages

    Lua - Python

    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_physx3.set_simulation_scales(1, 1000, 10)



    gh_physx3.run_simulation

    Description

    runs a simulation.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • dt [REAL]: detla time.
  • time_step [REAL]: simulation time step.

    Return Values

  • ret [INTEGER]: 1 means simulation done, 0 means no simulation done

    Code sample


    ret = gh_physx3.run_simulation(px_scene_id, dt, time_step)



    gh_physx3.create_scene

    Description

    creates a physx scene.

    Languages

    Lua - Python

    Parameters

  • gpu_physx [INTEGER]: GPU (1) or CPU (0).
  • bounce_threshold_velocity [REAL]: bounce threshold velocity.

    Return Values

  • px_scene [INTEGER]: Physx scene

    Code sample


    bounce_threshold_velocity = 0.2
    px_scene = gh_physx3.create_scene(1, bounce_threshold_velocity)



    gh_physx3.set_scene_gravity

    Description

    sets the scene gravity vector.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • x, y, z [REAL]: gravity vector.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.set_scene_gravity(px_scene, 0, -9.81, 0)



    gh_physx3.create_material

    Description

    creates a physx material.

    Languages

    Lua - Python

    Parameters

  • static_friction [REAL]: static friction.
  • dynamic_friction [REAL]: dynamic friction.
  • resilience [REAL]: resilience.

    Return Values

  • px_material [INTEGER]: PhysX material

    Code sample


    px_material = gh_physx3.create_material(0.5, 0.5, 0.5)



    gh_physx3.create_actor_plane

    Description

    creates a plane actor.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • nx, ny, nz, d [REAL]: plane equation.
  • material [INTEGER]: material identifier.

    Return Values

  • px_actor [INTEGER]: PhysX actor

    Code sample


    px_actor_plane = gh_physx3.create_actor_plane(px_scene, 0, 1, 0, 0, px_material)



    gh_physx3.create_actor_sphere

    Description

    creates a sphere actor.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • radius [REAL]: radius.
  • px, py, pz [REAL]: position.
  • density [REAL]: density.
  • material [INTEGER]: material identifier.

    Return Values

  • px_actor [INTEGER]: PhysX actor

    Code sample


    px_actor_plane = gh_physx3.create_actor_sphere(px_scene, 10, 0, 0, 0, density, px_material)



    gh_physx3.create_actor_box

    Description

    creates a box actor.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • w, h, d [REAL]: width, height and depth.
  • px, py, pz [REAL]: position.
  • density [REAL]: density.
  • material [INTEGER]: material identifier.

    Return Values

  • px_actor [INTEGER]: PhysX actor

    Code sample


    px_actor_box = gh_physx3.create_actor_box(px_scene, 4, 4, 4, 0, 0, 0, density, px_material)



    gh_physx3.create_actor_mesh

    Description

    creates an actor from a mesh.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: physx scene identifier.
  • mesh_id [REAL]: identifier of the mesh.
  • px, py, pz [REAL]: position.
  • density [REAL]: density.
  • material [INTEGER]: material identifier.

    Return Values

  • px_actor [INTEGER]: PhysX actor

    Code sample


    px_actor_box = gh_physx3.create_actor_mesh(px_scene, mesh, 0, 0, 0, density, px_material)



    gh_physx3.actor_kill

    Description

    destroys an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.kill_actor(px_actor)



    gh_physx3.actor_set_position

    Description

    sets the global position of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • x, y, z [REAL]: position.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_position(px_actor, x, y, z)



    gh_physx3.actor_get_position

    Description

    gets the global position of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

  • x, y, z [REAL]: position.

    Code sample


    x, y, z = gh_physx3.actor_get_position(px_actor)



    gh_physx3.actor_set_euler_angles

    Description

    sets the orientation of an actor using Euler's angles.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • pitch, yaw, roll [REAL]: eurler's angles in degrees.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_euler_angles(px_actor, 90, 0, 0)



    gh_physx3.actor_set_orientation

    Description

    sets the orientation of an actor (a quaternion).

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • x, y, z, w [REAL]: orientation quaternion.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_orientation(px_actor, x, y, z, w)



    gh_physx3.actor_get_orientation

    Description

    gets the orientation of an actor (a quaternion).

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

  • x, y, z, w [REAL]: orientation.

    Code sample


    x, y, z, w = gh_physx3.actor_get_orientation(px_actor)



    gh_physx3.actor_apply_transform

    Description

    applies the transformation (position + orientation) of an PhysX actor to a regular 3D object (a mesh for example).

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • object [INTEGER]: identifier of the object.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_apply_transform(px_actor, object)



    gh_physx3.actor_set_sleep_threshold

    Description

    sets the sleep threshold.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • thres [REAL]: threshold.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_sleep_threshold(px_actor, 0.2)



    gh_physx3.actor_get_sleep_threshold

    Description

    gets the sleep threshold.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

  • thres [REAL]: threshold.

    Code sample


    t = gh_physx3.actor_get_sleep_threshold(px_actor)



    gh_physx3.actor_is_sleeping

    Description

    gets the sleeping state of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

  • state [INTEGER]: state (0 or 1)

    Code sample


    is_sleeping = gh_physx3.actor_is_sleeping(px_actor)



    gh_physx3.actor_put_to_sleep

    Description

    forces an actor to sleep.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_put_to_sleep(px_actor)



    gh_physx3.actor_wake_up

    Description

    wakes up an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • sleep_counter [REAL]: sleep counter.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_wake_up(px_actor, 1)



    gh_physx3.actor_set_linear_damping

    Description

    sets the linear damping of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • damping [REAL]: damping.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_linear_damping(px_actor, 0.2)



    gh_physx3.actor_set_angular_damping

    Description

    sets the angular damping of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • damping [REAL]: damping.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_angular_damping(px_actor, 0.2)



    gh_physx3.actor_set_linear_velocity

    Description

    sets the linear velocity of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • vx, vy, vz [REAL]: 3D velocity vector.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_linear_velocity(px_actor, 10, 10, 10)



    gh_physx3.actor_set_angular_velocity

    Description

    sets the angular velocity of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • vx, vy, vz [REAL]: 3D velocity vector.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_angular_velocity(px_actor, 0.8, 12, 1.6)



    gh_physx3.actor_set_kinematic_state

    Description

    sets the kinematic state of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • state [INTEGER]: state (0 or 1).

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_kinematic_state(px_actor, 1)



    gh_physx3.actor_set_kinematic_target

    Description

    moves kinematically controlled dynamic actors through the 3d world.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • px, py, pz [REAL]: destination position.
  • pitch, yaw, roll [REAL]: destination orientation.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_kinematic_target(px_actor, px, py, pz, pitch, yaw, roll)



    gh_physx3.actor_add_force

    Description

    adds a force to an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • fx, fy, fz [REAL]: force.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_add_force(px_actor, fx, fy, fz)



    gh_physx3.actor_add_force_at_position

    Description

    adds a force to an actor at a particular position.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • fx, fy, fz [REAL]: force.
  • px, py, pz [REAL]: position.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_add_force_at_position(px_actor, fx, fy, fz, px, py, pz)



    gh_physx3.actor_set_gravity_state

    Description

    sets the gravity state of an actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • state [INTEGER]: state (0 or 1).

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.actor_set_gravity_state(px_actor, 1)



    gh_physx3.cloth_create_from_mesh

    Description

    creates a PhysX cloth from a mesh.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: identifier of the PhysX scene.
  • mesh [INTEGER]: identifier of the mesh.
  • gpu_cloth [INTEGER]: run on gpu (1) or not (0).
  • x, y, z [REAL]: position.
  • pitch, yaw, roll [REAL]: euler's angles.
  • gx, gy, gz [REAL]: gravity vector.

    Return Values

  • px_actor [INTEGER]: identifier of the cloth actor.

    Code sample


    px_actor = gh_physx3.cloth_create_from_mesh(px_scene, mesh, gpu_cloth, x, y, z, pitch. yaw, roll, gravity_x, gravity_y, gravity_z)



    gh_physx3.cloth_is_running_on_gpu

    Description

    gets the GPU state of a cloth actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.

    Return Values

  • state [INTEGER]: state (0 or 1).

    Code sample


    state = gh_physx3.cloth_is_running_on_gpu(px_actor)



    gh_physx3.cloth_set_gpu_state

    Description

    sets the GPU state of a cloth actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • state [INTEGER]: state (0 or 1).

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.cloth_set_gpu_state(px_actor, state)



    gh_physx3.cloth_update_mesh_vertex_data

    Description

    updates a mesh data (positions + normals ) from a PhysX cloth actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • mesh [INTEGER]: mesh identifier.
  • update_position [INTEGER]: updates (1) positions or not( 0).
  • update_normals [INTEGER]: updates (1) normals or not( 0).

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.cloth_update_mesh_vertex_data(px_actor, mesh, 1, 0)



    gh_physx3.cloth_update_particles_from_mesh_particles

    Description

    updates a PhysX cloth actor from a mesh.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • mesh [INTEGER]: mesh identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.cloth_update_particles_from_mesh_particles(px_actor, mesh)



    gh_physx3.cloth_set_external_acceleration

    Description

    sets the external acceleration to a PhysX cloth actor.

    Languages

    Lua - Python

    Parameters

  • px_actor [INTEGER]: identifier of the actor.
  • x, y, z [REAL]: acceleration vector.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.cloth_set_external_acceleration(px_actor, x, y, z)



    gh_physx3.particle_system_create

    Description

    creates a particle system. A PhysX particle system must run with a regular gxl3d particle system.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: identifier of the PhysX scene.
  • max_particles [INTEGER]: max number of particles.
  • run_on_gpu [INTEGER]: GPU (1) or CPU (0).
  • init_particles [INTEGER]: initializes particles positions (1) or not (0).

    Return Values

  • px_ps [INTEGER]: identifier of the particle system actor.

    Code sample


    px_ps = gh_physx3.particle_system_create(px_scene, max_particles, run_on_gpu, 0)



    gh_physx3.particle_system_create_fluid

    Description

    creates a PhysX fluid (particle system). A PhysX particle system must run with a regular gxl3d particle system.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: identifier of the PhysX scene.
  • max_particles [INTEGER]: max number of particles.
  • particle_size [REAL]: size of a particle.
  • viscosity [REAL]: fluid viscosity.
  • stiffness [REAL]: fluid stiffness.
  • run_on_gpu [INTEGER]: GPU (1) or CPU (0).
  • init_particles [INTEGER]: initializes particles positions (1) or not (0).

    Return Values

  • px_ps [INTEGER]: identifier of the particle system actor.

    Code sample


    px_ps = gh_physx3.particle_system_create_fluid(px_scene, max_particles, particle_size, viscosity, stiffness, run_on_gpu, 0)



    gh_physx3.particle_system_position_from_vertex_pool

    Description

    updates the positions of a PhysX particle system from a gxl3d vertex pool.

    Languages

    Lua - Python

    Parameters

  • px_ps [INTEGER]: identifier of the PhysX particle system actor.
  • vp [INTEGER]: identifier of the vertex pool.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.particle_system_position_from_vertex_pool(px_ps, vp)



    gh_physx3.particle_system_position_to_vertex_pool

    Description

    updates the positions of a gxl3d vertex pool from a PhysX particle system.

    Languages

    Lua - Python

    Parameters

  • px_ps [INTEGER]: identifier of the PhysX particle system actor.
  • vp [INTEGER]: identifier of the vertex pool.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.particle_system_position_to_vertex_pool(px_ps, vp)



    gh_physx3.particle_system_to_gxl3d_ps

    Description

    updates a gxl3d particle system from a PhysX particle system.

    Languages

    Lua - Python

    Parameters

  • px_ps [INTEGER]: identifier of the PhysX particle system actor.
  • ps [INTEGER]: identifier of the gxl3d particle system.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.particle_system_to_gxl3d_ps(px_ps, ps)



    gh_physx3.particle_system_from_gxl3d_ps

    Description

    updates a PhysX particle system from a gxl3d particle system.

    Languages

    Lua - Python

    Parameters

  • px_ps [INTEGER]: identifier of the PhysX particle system actor.
  • ps [INTEGER]: identifier of the gxl3d particle system.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.particle_system_from_gxl3d_ps(px_ps, ps)



    gh_physx3.joint_create

    Description

    creates a PhysX joint between two PhysX actors.

    Languages

    Lua - Python

    Parameters

  • px_scene [INTEGER]: identifier of the PhysX scene.
  • joint_type [INTEGER]: type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
  • px_actor1 [INTEGER]: identifier of the first PhysX actor.
  • 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.
  • px_actor2 [INTEGER]: identifier of the second PhysX actor.
  • 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

  • px_joint [INTEGER]: identifier of the PhysX joint.

    Code sample


    px_joint = gh_physx3.joint_create(px_scene, joint_type, px_actor1, x1, y1, z1, pitch1, yaw1, roll1, px_actor2, x2, y2, z2, pitch2, yaw2, roll2)



    gh_physx3.joint_kill

    Description

    kills a PhysX joint.

    Languages

    Lua - Python

    Parameters

  • px_joint [INTEGER]: identifier of the PhysX joint.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.joint_kill(px_joint)



    gh_physx3.joint_set_break_force

    Description

    set the breaking force of a PhysX joint.

    Languages

    Lua - Python

    Parameters

  • px_joint [INTEGER]: identifier of the PhysX joint.
  • force, torque [REAL]: force and torque.

    Return Values

    This function has no return value(s).

    Code sample


    gh_physx3.joint_set_break_force(px_joint, force, torque)





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.