< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_bullet3 library

Description

gh_bullet3 is the module that manages the Bullet Physics engine.


Number of functions: 47

  1. gh_bullet3.init (Lua - Python)
  2. gh_bullet3.terminate (Lua - Python)
  3. gh_bullet3.get_api_version (Lua - Python)
  4. gh_bullet3.scene_init (Lua - Python)
  5. gh_bullet3.scene_init_sap (Lua - Python)
  6. gh_bullet3.scene_terminate (Lua - Python)
  7. gh_bullet3.scene_set_gravity (Lua - Python)
  8. gh_bullet3.scene_set_solver_num_iterations (Lua - Python)
  9. gh_bullet3.scene_step_simulation (Lua - Python)
  10. gh_bullet3.actor_set_3d_object (Lua - Python)
  11. gh_bullet3.scene_sync_3d_objects (Lua - Python)
  12. gh_bullet3.scene_add_actor (Lua - Python)
  13. gh_bullet3.scene_remove_actor (Lua - Python)
  14. gh_bullet3.actor_create_box (Lua - Python)
  15. gh_bullet3.actor_create_sphere (Lua - Python)
  16. gh_bullet3.actor_create_cylinder (Lua - Python)
  17. gh_bullet3.actor_create_static_plane (Lua - Python)
  18. gh_bullet3.actor_create_mesh (Lua - Python)
  19. gh_bullet3.actor_kill (Lua - Python)
  20. gh_bullet3.actor_apply_transform (Lua - Python)
  21. gh_bullet3.actor_set_position (Lua - Python)
  22. gh_bullet3.actor_set_orientation (Lua - Python)
  23. gh_bullet3.actor_get_position (Lua - Python)
  24. gh_bullet3.actor_get_orientation (Lua - Python)
  25. gh_bullet3.actor_set_linear_velocity (Lua - Python)
  26. gh_bullet3.actor_get_linear_velocity (Lua - Python)
  27. gh_bullet3.actor_get_linear_speed2 (Lua - Python)
  28. gh_bullet3.actor_set_angular_velocity (Lua - Python)
  29. gh_bullet3.actor_get_angular_velocity (Lua - Python)
  30. gh_bullet3.actor_get_angular_speed2 (Lua - Python)
  31. gh_bullet3.actor_set_gravity (Lua - Python)
  32. gh_bullet3.actor_set_linear_factor (Lua - Python)
  33. gh_bullet3.actor_set_angular_factor (Lua - Python)
  34. gh_bullet3.actor_apply_central_force (Lua - Python)
  35. gh_bullet3.actor_apply_central_impulse (Lua - Python)
  36. gh_bullet3.actor_apply_torque (Lua - Python)
  37. gh_bullet3.actor_clear_forces (Lua - Python)
  38. gh_bullet3.actor_set_damping (Lua - Python)
  39. gh_bullet3.actor_set_collision_margin (Lua - Python)
  40. gh_bullet3.material_create (Lua - Python)
  41. gh_bullet3.material_kill (Lua - Python)
  42. gh_bullet3.material_update (Lua - Python)
  43. gh_bullet3.actor_set_material (Lua - Python)
  44. gh_bullet3.actor_update_mass (Lua - Python)
  45. gh_bullet3.scene_check_contacts (Lua - Python)
  46. gh_bullet3.actor_get_contact_info (Lua - Python)
  47. gh_bullet3.scene_reset_all_contacts (Lua - Python)



init

Description

Initializes the Bullet3 plugin. This the first function to call.


Syntax

ret = gh_bullet3.init()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample

    
rc = gh_bullet3.init()
            


terminate

Description

Stops the Bullet engine and frees resources.


Syntax

ret = gh_bullet3.terminate()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample

    
rc = gh_bullet3.terminate()
            


get_api_version

Description

Gets the Bullet API version as a single integer (ex: 288).


Syntax

v = gh_bullet3.get_api_version()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample

    
v = gh_bullet3.get_api_version()
            


scene_init

Description

Initializes a physics scene (Bullet Dbvt broadphase)


Syntax

sid = gh_bullet3.scene_init()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample

    
sid = gh_bullet3.scene_init()
            


scene_init_sap

Description

Initializes a physics scene (Bullet AxisSweep3 broadphase). For this scene, you have to specify the expected scene dimensions.


Syntax

sid = gh_bullet3.scene_init_sap(
 min_x, min_y, min_z,
 max_x, max_y, max_z
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
sid = gh_bullet3.scene_init_sap(x0, y0, z0,  x1, x1, z1)
            


scene_terminate

Description

Terminates a physics scene.


Syntax

gh_bullet3.scene_terminate(
 sid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_terminate(sid)
            


scene_set_gravity

Description

Sets the global gravity of the scene (ex: [0.0, -10; 0.0]).


Syntax

gh_bullet3.scene_set_gravity(
 sid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_set_gravity(sid, x, y, z)
            


scene_set_solver_num_iterations

Description

Sets the number of iterations of the solver. The simulation stability increases with the number of iterations but the simulation is slower.


Syntax

gh_bullet3.scene_set_solver_num_iterations(
 sid,
 iterations
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_set_solver_num_iterations(sid, iterations)
            


scene_step_simulation

Description

Performs a scene simulation step. The relation between the parameters should follow this rule: timeStep < maxSubSteps * fixedTimeStep.


Syntax

gh_bullet3.scene_step_simulation(
 sid,
 time_step,
 max_sub_steps,
 fixed_time_step
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_step_simulation(sid, dt, max_sub_steps, 1.0/60.0)
            


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_bullet3.actor_set_3d_object(
 aid,
 oid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_3d_object(aid, oid)
            


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_bullet3.scene_sync_3d_objects(
 sid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_sync_3d_objects(sid)
            


scene_add_actor

Description

Adds a physics actor to a physics scene.


Syntax

gh_bullet3.scene_add_actor(
 sid,
 aid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_add_actor(sid, aid)
            


scene_remove_actor

Description

Removes a physics actor from a physics scene.


Syntax

gh_bullet3.scene_remove_actor(
 sid,
 aid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_remove_actor(sid, aid)
            


actor_create_box

Description

Creates a box actor.


Syntax

aid = gh_bullet3.actor_create_box(
 w, h, d,
 x, y, z,
 mass,
 mid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
aid = gh_bullet3.actor_create_box(w, h, d, x, y, z, mass, mid)
            


actor_create_sphere

Description

Creates a sphere actor.


Syntax

aid = gh_bullet3.actor_create_sphere(
 radius,
 x, y, z,
 mass,
 mid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
aid = gh_bullet3.actor_create_sphere(radius, x, y, z, mass, mid)
            


actor_create_cylinder

Description

Creates a cylinder actor.


Syntax

aid = gh_bullet3.actor_create_cylinder(
 central_axis,
 height,
 radius,
 x, y, z,
 mass,
 mid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
aid = gh_bullet3.actor_create_cylinder(central_axis, height, radius, x, y, z, mass, mid)
            


actor_create_static_plane

Description

Creates a static plane actor. This is an infinite plane defined by a plane eqution.


Syntax

aid = gh_bullet3.actor_create_static_plane(
 nx, ny, nz, d,
 mid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
nx = 0
ny = 1
nz = 0
d = 0            
aid = gh_bullet3.actor_create_static_plane(nx, ny, nz, d, mid)
            


actor_create_mesh

Description

Creates an actor from a mesh.


Syntax

aid = gh_bullet3.actor_create_mesh(
 mesh_id,
 convex,
 x, y, z,
 mass,
 mid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
aid = gh_bullet3.actor_create_mesh(meshid, convex, x, y, z, mass, mid)
            


actor_kill

Description

Destroys an actor.


Syntax

gh_bullet3.actor_kill(
 aid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_kill(aid)
            


actor_apply_transform

Description

Apply the transformation matrix of a physics actor to a 3D object. It's a manual physcis/graphics synchronization. Use this function if you don't use scene_sync_3d_objects().


Syntax

gh_bullet3.actor_apply_transform(
 aid,
 oid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_apply_transform(aid, oid)
            


actor_set_position

Description

Sets the position of an actor.


Syntax

gh_bullet3.actor_set_position(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_position(aid, x, y, z)
            


actor_set_orientation

Description

Sets the orientation of an actor.


Syntax

gh_bullet3.actor_set_orientation(
 aid,
 qx, qy, qz, qw
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_orientation(aid, qx, qy, qz, qw)
            


actor_get_position

Description

Gets the position of an actor.


Syntax

x, y, z = gh_bullet3.actor_get_position(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z = gh_bullet3.actor_get_position(aid)
            


actor_get_orientation

Description

Gets the orientation of an actor.


Syntax

qx, qy, qz, qw = gh_bullet3.actor_get_orientation(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
qx, qy, qz, qw = gh_bullet3.actor_get_orientation(aid)
            


actor_set_linear_velocity

Description

Sets the linear velocity of an actor.


Syntax

gh_bullet3.actor_set_linear_velocity(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_linear_velocity(aid, x, y, z)
            


actor_get_linear_velocity

Description

Gets the linear velocity of an actor.


Syntax

x, y, z = gh_bullet3.actor_get_linear_velocity(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z= gh_bullet3.actor_get_linear_velocity(aid)
            


actor_get_linear_speed2

Description

Gets the squared linear speed of an actor.


Syntax

s = gh_bullet3.actor_get_linear_speed2(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
s = gh_bullet3.actor_get_linear_speed2(aid)
            


actor_set_angular_velocity

Description

Sets the angular velocity of an actor.


Syntax

gh_bullet3.actor_set_angular_velocity(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_angular_velocity(aid, x, y, z)
            


actor_get_angular_velocity

Description

Gets the angular velocity of an actor.


Syntax

x, y, z = gh_bullet3.actor_get_angular_velocity(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z= gh_bullet3.actor_get_angular_velocity(aid)
            


actor_get_angular_speed2

Description

Gets the squared angular speed of an actor.


Syntax

s = gh_bullet3.actor_get_angular_speed2(
 aid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
s = gh_bullet3.actor_get_angular_speed2(aid)
            


actor_set_gravity

Description

Sets a gravity vector for an actor.


Syntax

gh_bullet3.actor_set_gravity(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_gravity(aid, x, y, z)
            


actor_set_linear_factor

Description

Allows to limit (or amplify) the linear velocity along some axis.


Syntax

gh_bullet3.actor_set_linear_factor(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_linear_factor(aid, x, y, z)
            


actor_set_angular_factor

Description

Allows to limit (or amplify) the angular velocity along some axis.


Syntax

gh_bullet3.actor_set_angular_factor(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_angular_factor(aid, x, y, z)
            


actor_apply_central_force

Description

Applies a force to an actor.


Syntax

gh_bullet3.actor_apply_central_force(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_apply_central_force(aid, x, y, z)
            


actor_apply_central_impulse

Description

Applies an impulse force to an actor.


Syntax

gh_bullet3.actor_apply_central_impulse(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_apply_central_impulse(aid, x, y, z)
            


actor_apply_torque

Description

Applies a torque to an actor.


Syntax

gh_bullet3.actor_apply_torque(
 aid,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_apply_torque(aid, x, y, z)
            


actor_clear_forces

Description

Clears (resets) all forces that act on an actor.


Syntax

gh_bullet3.actor_clear_forces(
 aid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_clear_forces(aid)
            


actor_set_damping

Description

Sets damping factors.


Syntax

gh_bullet3.actor_set_damping(
 aid,
 linear,
 angular
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_damping(aid, linear, angular)
            


actor_set_collision_margin

Description

Sets the collision margin of an actor. Useful to improve simulation stability.


Syntax

gh_bullet3.actor_set_collision_margin(
 aid,
 margin
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_collision_margin(aid, margin)
            


material_create

Description

Creates a new material.


Syntax

mid = gh_bullet3.material_create(
 restitution,
 friction
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
mid = gh_bullet3.material_create(restitution, friction)
            


material_kill

Description

Destroys a material.


Syntax

gh_bullet3.material_kill(
 mid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.material_kill(mid)
            


material_update

Description

updates the properties of a material


Syntax

gh_bullet3.material_update(
 mid,
 friction,
 restitution
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
restitution = 0.9
friction = 0.5
gh_bullet3.material_update(mid, restitution, friction)
-- now update the material for a particular actor.
gh_bullet3.actor_set_material(aid, mid)
            


actor_set_material

Description

updates an actor's material


Syntax

gh_bullet3.actor_set_material(
 aid,
 mid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_set_material(aid, mid)
            


actor_update_mass

Description

updates the mass of an actor


Syntax

gh_bullet3.actor_update_mass(
 aid,
 mass
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.actor_update_mass(aid, mass)
            


scene_check_contacts

Description

Checks all contacts in a scene.


Syntax

num_contacts = gh_bullet3.scene_check_contacts(
 sid
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
num_contacts = gh_bullet3.scene_check_contacts(mid)
            


actor_get_contact_info

Description

Gets information about contacts of an actor.


Syntax

num_contacts = gh_bullet3.actor_get_contact_info(
 aid,
 px, py, pz
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
num_contacts, px, py, pz = gh_bullet3.actor_get_contact_info(aid)
            


scene_reset_all_contacts

Description

Resets all contacts in a scene. Should be called before scene_step_simulation()


Syntax

gh_bullet3.scene_reset_all_contacts(
 sid
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_bullet3.scene_reset_all_contacts(sid)
            






GeeXLab Rootard Guide | Downloads | Contact | Newsletter