syntax
gh_bullet3.actor_apply_central_force (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL force
return values
none
code sample
gh_bullet3.actor_apply_central_force(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_central_impulse (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL force
return values
none
code sample
gh_bullet3.actor_apply_central_impulse(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_torque (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL torque
return values
none
code sample
gh_bullet3.actor_apply_torque(actor_id, x, y, z)
syntax
gh_bullet3.actor_apply_transform (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_bullet3.actor_apply_transform(actor_id, o3d_id)
syntax
gh_bullet3.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.actor_clear_forces(actor_id)
actor_create_box
Creates a box actor.
syntax
actor_id = gh_bullet3.actor_create_box (
w, h, d,
x, y, z,
mass,
mat_id
)
parameters
w, h, d REAL dimensions of the box
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_box(w, h, d, x, y, z, mass, mat_id)
actor_create_box_v2
Creates a box actor.
syntax
actor_id = gh_bullet3.actor_create_box_v2 (
w, h, d,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
w, h, d REAL dimensions of the box
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_box_v2(w, h, d, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_cylinder (
main_axis,
height,
radius,
x, y, z,
mass,
mat_id
)
parameters
main_axis ENUM( along_axis ) direction of the main axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
height REAL cylinder height
radius REAL cylinder radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_cylinder(central_axis, height, radius, x, y, z, mass, mat_id)
syntax
actor_id = gh_bullet3.actor_create_cylinder_v2 (
main_axis,
height,
radius,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
main_axis ENUM( along_axis ) direction of the main axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
height REAL cylinder height
radius REAL cylinder radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_cylinder_v2(central_axis, height, radius, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_mesh (
mesh_id,
convex,
x, y, z,
mass,
mat_id
)
parameters
mesh_id ID mesh identifier
convex BOOLEAN convex mesh: 1 (yes) or 0 (no)
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_mesh(mesh_id, convex, x, y, z, mass, mat_id)
syntax
actor_id = gh_bullet3.actor_create_mesh_v2 (
mesh_id,
convex,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
mesh_id ID mesh identifier
convex BOOLEAN convex mesh: 1 (yes) or 0 (no)
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_mesh_v2(mesh_id, convex, x, y, z, mass, ix, iy, iz, mat_id)
actor_create_sphere
Creates a sphere actor.
syntax
actor_id = gh_bullet3.actor_create_sphere (
radius,
x, y, z,
mass,
mat_id
)
parameters
radius REAL sphere radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_sphere(radius, x, y, z, mass, mat_id)
actor_create_sphere_v2
Creates a sphere actor.
syntax
actor_id = gh_bullet3.actor_create_sphere_v2 (
radius,
x, y, z,
mass,
ix, iy, iz,
mat_id
)
parameters
radius REAL sphere radius
x, y, z REAL initial position of the actor
mass REAL mass (set the mass = 0 for a kinematic actor)
ix, iy, iz REAL initial local inertia
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
actor_id = gh_bullet3.actor_create_sphere_v2(radius, x, y, z, mass, ix, iy, iz, mat_id)
syntax
actor_id = gh_bullet3.actor_create_static_plane (
nx, ny, nz, d,
mat_id
)
parameters
nx, ny, nz, d REAL plane equation
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
nx = 0
ny = 1
nz = 0
d = 0
actor_id = gh_bullet3.actor_create_static_plane(nx, ny, nz, d, mat_id)
syntax
actor_id = gh_bullet3.actor_create_static_plane_v2 (
nx, ny, nz,
px, py, pz,
mat_id
)
parameters
nx, ny, nz REAL plane normal vector
px, py, pz REAL plane position
mat_id ID material identifier
return values
actor_id ID actor identifier
code sample
nx = 1
ny = 0
nz = 0
px = 5
py = 0
pz = 0
actor_id = gh_bullet3.actor_create_static_plane_v2(nx, ny, nz, px, py, pz, mat_id)
syntax
state = gh_bullet3.actor_get_activation_state (
actor_id
)
parameters
actor_id ID actor identifier
return values
state INTEGER activation state (0 or 1)
code sample
state = gh_bullet3.actor_get_activation_state(actor_id)
syntax
s = gh_bullet3.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_bullet3.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z= gh_bullet3.actor_get_angular_velocity(actor_id)
syntax
contact_actor_id = gh_bullet3.actor_get_contact_actor (
actor_id,
contact_index
)
parameters
actor_id ID actor identifier
contact_index INTEGER contact index
return values
contact_actor_id ID ID of the actor in contact
code sample
num_contacts, x, y, z = gh_bullet3.actor_get_contact_info(actor_id)
for i=0, num_contacts-1 do
contact_actor_id = gh_bullet3.actor_get_contact_actor(actor_id, i)
...
end
syntax
num_contacts = gh_bullet3.actor_get_contact_info (
actor_id,
px, py, pz
)
parameters
actor_id ID actor identifier
px, py, pz REAL position of the first contact
return values
num_contacts INTEGER number of contacts
code sample
num_contacts, px, py, pz = gh_bullet3.actor_get_contact_info(actor_id)
syntax
s = gh_bullet3.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_bullet3.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z= gh_bullet3.actor_get_linear_velocity(actor_id)
syntax
qx, qy, qz, qw = gh_bullet3.actor_get_orientation (
actor_id
)
parameters
actor_id ID actor identifier
return values
qx, qy, qz, qw REAL orientation quaternion
code sample
qx, qy, qz, qw = gh_bullet3.actor_get_orientation(actor_id)
syntax
x, y, z = gh_bullet3.actor_get_position (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL 3D position
code sample
x, y, z = gh_bullet3.actor_get_position(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_bullet3.actor_get_transform_mat16 (
actor_id
)
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_bullet3.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_bullet3.actor_get_transform_pos_qrot (
actor_id
)
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_bullet3.actor_get_transform_pos_qrot(actor_id)
actor_kill
Destroys an actor.
syntax
gh_bullet3.actor_kill (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.actor_kill(actor_id)
syntax
gh_bullet3.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_bullet3.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_bullet3.actor_set_activation_state (
actor_id,
state
)
parameters
actor_id ID actor identifier
state INTEGER activation state (0 or 1)
return values
none
code sample
gh_bullet3.actor_set_activation_state(actor_id, state)
syntax
gh_bullet3.actor_set_angular_factor (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL XX factor
return values
none
code sample
gh_bullet3.actor_set_angular_factor(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_angular_velocity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL velocity vector
return values
none
code sample
gh_bullet3.actor_set_angular_velocity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_ccd_params (
actor_id,
motion_threshold,
swept_sphere_radius
)
parameters
actor_id ID actor identifier
motion_threshold REAL CCD is not performed if the motion (in one step) is less then motion_threshold
swept_sphere_radius REAL swept sphere radius (0.0 by default)
return values
none
code sample
gh_bullet3.actor_set_ccd_params(actor_id, motion_threshold, swept_sphere_radius)
syntax
gh_bullet3.actor_set_collision_margin (
actor_id,
margin
)
parameters
actor_id ID actor identifier
margin REAL collision margin
return values
none
code sample
gh_bullet3.actor_set_collision_margin(actor_id, margin)
actor_set_damping
Sets damping factors.
syntax
gh_bullet3.actor_set_damping (
actor_id,
linear,
angular
)
parameters
actor_id ID actor identifier
linear REAL linear damping
angular REAL angular damping
return values
none
code sample
gh_bullet3.actor_set_damping(actor_id, linear, angular)
syntax
gh_bullet3.actor_set_gravity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_bullet3.actor_set_gravity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_linear_factor (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL XX factor
return values
none
code sample
gh_bullet3.actor_set_linear_factor(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_linear_velocity (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL velocity vector
return values
none
code sample
gh_bullet3.actor_set_linear_velocity(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_bullet3.actor_set_material(actor_id, mid)
syntax
gh_bullet3.actor_set_orientation (
actor_id,
qx, qy, qz, qw
)
parameters
actor_id ID actor identifier
qx, qy, qz, qw REAL orientation quaternion
return values
none
code sample
gh_bullet3.actor_set_orientation(actor_id, qx, qy, qz, qw)
syntax
gh_bullet3.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID actor identifier
x, y, z REAL 3d position
return values
none
code sample
gh_bullet3.actor_set_position(actor_id, x, y, z)
syntax
gh_bullet3.actor_set_sleeping_thresholds (
actor_id,
linear,
angular
)
parameters
actor_id ID actor identifier
linear REAL linear sleeping threshold
angular REAL angular sleeping threshold
return values
none
code sample
gh_bullet3.actor_set_sleeping_thresholds(actor_id, linear, angular)
syntax
gh_bullet3.actor_update_mass (
actor_id,
mass
)
parameters
actor_id ID actor identifier
mass REAL mass
return values
none
code sample
gh_bullet3.actor_update_mass(actor_id, mass)
syntax
version = gh_bullet3.get_version()
parameters
none
return values
version INTEGER API version
code sample
version = gh_bullet3.get_version()
syntax
ret = gh_bullet3.init()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_bullet3.init()
material_create
Creates a new material.
syntax
mat_id = gh_bullet3.material_create (
restitution,
friction
)
parameters
restitution REAL restitution factor
friction REAL friction factor
return values
mat_id ID material identifier
code sample
mat_id = gh_bullet3.material_create(restitution, friction)
material_kill
Destroys a material.
syntax
gh_bullet3.material_kill (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_bullet3.material_kill(mat_id)
syntax
gh_bullet3.material_update (
mat_id,
friction,
restitution
)
parameters
mat_id ID material identifier
friction REAL friction
restitution REAL resilience / restitution
return values
none
code sample
restitution = 0.9
friction = 0.5
gh_bullet3.material_update(mat_id, restitution, friction)
-- now update the material for a particular actor
gh_bullet3.actor_set_material(actor_id, mat_id)
syntax
gh_bullet3.scene_add_actor (
scene_id,
actor_id
)
parameters
scene_id ID scene identifier
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.scene_add_actor(scene_id, actor_id)
syntax
num_contacts = gh_bullet3.scene_check_contacts (
scene_id
)
parameters
scene_id ID scene identifier
return values
num_contacts INTEGER number of contacts
code sample
num_contacts = gh_bullet3.scene_check_contacts(scene_id)
syntax
scene_id = gh_bullet3.scene_create()
parameters
none
return values
scene_id ID scene identifier
code sample
scene_id = gh_bullet3.scene_create()
syntax
scene_id = gh_bullet3.scene_create_sap (
min_x, min_y, min_z,
max_x, max_y, max_z
)
parameters
min_x, min_y, min_z REAL world dimensions (minimal AABB values)
max_x, max_y, max_z REAL world dimensions (maximal AABB values)
return values
scene_id ID scene identifier
code sample
scene_id = gh_bullet3.scene_create_sap(x0, y0, z0, x1, x1, z1)
syntax
gh_bullet3.scene_kill (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_kill(scene_id)
syntax
gh_bullet3.scene_remove_actor (
scene_id,
actor_id
)
parameters
scene_id ID scene identifier
actor_id ID actor identifier
return values
none
code sample
gh_bullet3.scene_remove_actor(scene_id, actor_id)
syntax
gh_bullet3.scene_reset_all_contacts (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_reset_all_contacts(scene_id)
syntax
gh_bullet3.scene_set_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_bullet3.scene_set_gravity(scene_id, x, y, z)
syntax
gh_bullet3.scene_set_solver_num_iterations (
scene_id,
num_iterations
)
parameters
scene_id ID scene identifier
num_iterations INTEGER number of iterations - default value is 10.
return values
none
code sample
gh_bullet3.scene_set_solver_num_iterations(scene_id, iterations)
syntax
gh_bullet3.scene_step_simulation (
scene_id,
time_step,
max_sub_steps,
fixed_time_step
)
parameters
scene_id ID scene identifier
time_step REAL time step between two frames
max_sub_steps INTEGER number of sub steps
fixed_time_step REAL fixed time step - default value: 1.0/60.0
return values
none
code sample
gh_bullet3.scene_step_simulation(scene_id, dt, max_sub_steps, 1.0/60.0)
syntax
gh_bullet3.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_bullet3.scene_sync_3d_objects(scene_id)
syntax
ret = gh_bullet3.terminate()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_bullet3.terminate()
gh_camera
Camera module
gh_camera is the module that manages cameras: creation, destruction, setting the parameters (position, filed of view, etc.).
syntax
gh_camera.bind (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.bind(camera)
syntax
gh_camera.bind_v2 (
cam_id,
update_viewport,
update_scissor,
update_proj_mat,
update_view_mat,
update_fixed_pipeline
)
parameters
cam_id ID camera identifier
update_viewport BOOLEAN updates the viewport: 1 (true) or 0 (false)
update_scissor BOOLEAN updates the scissor rectangle (same size than the viewport): 1 (true) or 0 (false)
update_proj_mat BOOLEAN updates the projection matrix: 1 (true) or 0 (false)
update_view_mat BOOLEAN updates the view matrix: 1 (true) or 0 (false)
update_fixed_pipeline BOOLEAN updates the fixed pipeline (so you will have access to gl_ModelViewProjectionMatrix in a vertex shader for example): 1 (true) or 0 (false)
return values
none
code sample
local update_viewport = 1
local update_scissor = 0
local update_proj_mat = 1
local update_view_mat = 1
local update_fixed_pipeline = 0
gh_camera.bind_v2(cam_id, update_viewport, update_scissor, update_proj_mat, update_view_mat, update_fixed_pipeline)
syntax
cam_id = gh_camera.create_ortho (
left,
right,
bottom,
top,
znear,
zfar
)
parameters
left REAL left clipping plane
right REAL right clipping plane
bottom REAL bottom clipping plane
top REAL top clipping plane
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
w = screen_width
h = screen_height
cam_id = gh_camera.create_ortho(-w/2, w/2, -h/2, h/2, -1.0, 1.0)
create_orthographic
Creates an orthographic camera with default values: left, right, top, bottom are derived from the window size.
syntax
cam_id = gh_camera.create_orthographic()
parameters
none
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_orthographic()
syntax
cam_id = gh_camera.create_persp (
fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp(60, 1.333, 0.1, 1000.0)
syntax
cam_id = gh_camera.create_persp_v2 (
fov,
is_vertical_fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
is_vertical_fov BOOLEAN 1 (vertical fov) or 0 (horizontal fov)
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp_v2(60, 1, 1.333, 0.1, 1000.0)
syntax
cam_id = gh_camera.create_persp_v3 (
fov_x,
fov_y,
aspect,
znear,
zfar
)
parameters
fov_x REAL horizontal field of view in degres
fov_y REAL vertical field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_persp_v3(60, 70, 1.333, 0.1, 1000.0)
create_perspective
Creates a perspective camera with default values (fov=60, znear=1, zfar=1000, aspect=win_width/win_height).
syntax
cam_id = gh_camera.create_perspective (
pos_x, pos_y, pos_z,
lookat_x, lookat_y, lookat_z
)
parameters
pos_x, pos_y, pos_z REAL position of the camera
lookat_x, lookat_y, lookat_z REAL look at point of the camera
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_perspective(0, 20, 0, 0, 0, 0)
syntax
cam_id = gh_camera.create_perspective_vk (
fov,
aspect,
znear,
zfar
)
parameters
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
cam_id ID camera identifier
code sample
cam_id = gh_camera.create_perspective_vk(60.0, winW/winH, 1.0, 1000.0)
syntax
collision = gh_camera.frustum_check_object_aa_box (
cam_id,
obj_id
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_object_aa_box(cam_id, obj_id)
syntax
collision = gh_camera.frustum_check_object_sphere (
cam_id,
obj_id
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_object_sphere(cam_id, obj_id)
syntax
collision = gh_camera.frustum_check_point (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL position of the point
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_point(cam_id, x, y, z)
syntax
collision = gh_camera.frustum_check_sphere (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL position of the sphere center
return values
collision BOOLEAN collision: 1 (true) or 0 (false)
code sample
collision = gh_camera.frustum_check_sphere(cam_id, radius, x, y, z)
frustum_update
Updates the frustum volume of the camera.
The frustum needs to be updated as soon as the camera view matrix has changed (position or orientation).
Once the frustumn is updated, you can perform collision checks (frustum_check_sphere for example).
syntax
gh_camera.frustum_update (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.frustum_update(cam_id)
get_euler_angles
Gets the Euler's angles.
syntax
pitch, yaw, roll = gh_camera.get_euler_angles (
cam_id
)
parameters
cam_id ID camera identifier
return values
pitch, yaw, roll REAL Euler's angles in degrees
code sample
pitch, yaw, roll = gh_camera.get_euler_angles(cam_id)
syntax
fov = gh_camera.get_fov (
cam_id
)
parameters
cam_id ID camera identifier
return values
fov REAL vertical field of view in degrees
code sample
fov = gh_camera.get_fov(cam_id)
syntax
x, y, z = gh_camera.get_position (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_camera.get_position(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix (
cam_id
)
parameters
cam_id ID camera 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_camera.get_projection_matrix(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_projection_matrix_4x4 (
cam_id
)
parameters
cam_id ID camera 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_camera.get_projection_matrix_4x4(cam_id)
syntax
x, y, z = gh_camera.get_up_vector (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL up vector
code sample
x, y, z = gh_camera.get_up_vector(cam_id)
syntax
x, y, z = gh_camera.get_view (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z REAL view vector
code sample
x, y, z = gh_camera.get_view(cam_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_camera.get_view_matrix (
cam_id
)
parameters
cam_id ID camera 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_camera.get_view_matrix(cam_id)
syntax
x, y, z, w = gh_camera.get_view_quaternion (
cam_id
)
parameters
cam_id ID camera identifier
return values
x, y, z, w REAL view quaternion
code sample
x, y, z, w = gh_camera.get_view_quaternion(cam_id)
syntax
gh_camera.load_gl2_matrix (
cam_id,
load_proj_mat,
load_view_mat,
object_id
)
parameters
cam_id ID camera identifier
load_proj_mat BOOLEAN load the projection matrix (0 or 1)
load_view_mat BOOLEAN load the view matrix (0 or 1)
object_id ID object identifier
return values
none
code sample
load_proj_mat = 1
load_view_mat = 1
gh_camera.load_gl2_matrix(cam_id, load_proj_mat, load_view_mat, object_id)
reset_reflection_matrix
Resets the reflection matrix initialized by set_reflection_matrix_v1() or set_reflection_matrix_v2().
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix.
syntax
gh_camera.reset_reflection_matrix (
cam_id
)
parameters
cam_id ID camera identifier
return values
none
code sample
gh_camera.reset_reflection_matrix(cam_id)
syntax
gh_camera.set_fov (
cam_id,
fov
)
parameters
cam_id ID camera identifier
fov REAL vertical field of view in degrees
return values
none
code sample
gh_camera.set_fov(cam_id, 90)
syntax
gh_camera.set_lookat (
cam_id,
x, y, z,
lookat_mode
)
parameters
cam_id ID camera identifier
x, y, z REAL the target
lookat_mode REAL 1: the target is a point (3D position) or 0: the target is a direction (3D vector)
return values
none
code sample
-- Look at the center of the scene:
gh_camera.set_lookat(cam_id, 0, 0, 0, 1)
syntax
gh_camera.set_orientation_cubemap (
cam_id,
face
)
parameters
cam_id ID camera identifier
face INTEGER cubemap face (0 to 5)
return values
none
code sample
for face = 0, 5 do
gh_camera.set_orientation_cubemap(cam_id, face)
...
end
syntax
gh_camera.set_pitch (
cam_id,
pitch
)
parameters
cam_id ID camera identifier
pitch REAL pitch in degrees
return values
none
code sample
gh_camera.set_pitch(cam_id, pitch)
syntax
gh_camera.set_position (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL 3D position of the camera
return values
none
code sample
gh_camera.set_position(cam_id, 0, 10, 20)
syntax
gh_camera.set_projection_matrix (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
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
return values
none
code sample
gh_camera.set_projection_matrix(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
set_reflection_matrix_v1
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v1 (
cam_id,
px, py, pz,
nx, ny, nz,
y
)
parameters
cam_id ID camera identifier
px, py, pz REAL mirror plane position
nx, ny, nz REAL mirror plane normal
y REAL y offset - default: 0
return values
none
code sample
gh_camera.set_reflection_matrix_v1(cam_id, 0, 10, 0, 0, 0, 1)
set_reflection_matrix_v2
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v2 (
cam_id,
a, b, c, d
)
parameters
cam_id ID camera identifier
a, b, c, d REAL mirror plane equation
return values
none
code sample
a, b, c, d = gh_object.get_plane_equation(mirror_plane)
gh_camera.set_reflection_matrix_v2(cam_id, a, b, c, d)
set_reflection_matrix_v3
Sets / initializes the reflection matrix.
The reflection matrix is used in scenes where reflection effect (mirror) is required.
When reflection rendering is done, you have to reset the reflection matrix with reset_reflection_matrix().
syntax
gh_camera.set_reflection_matrix_v3 (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
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
return values
none
code sample
gh_camera.set_reflection_matrix_v3(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_camera.set_roll (
cam_id,
roll
)
parameters
cam_id ID camera identifier
roll REAL roll in degrees
return values
none
code sample
gh_camera.set_roll(cam_id, roll)
syntax
gh_camera.set_up_vec (
cam_id,
x, y, z
)
parameters
cam_id ID camera identifier
x, y, z REAL direction of the up vector
return values
none
code sample
-- The up vector is the unit Y axis.
gh_camera.set_up_vec(cam_id, 0, 1, 0)
syntax
gh_camera.set_view_matrix (
cam_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
cam_id ID camera identifier
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
return values
none
code sample
gh_camera.set_view_matrix(cam_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_camera.set_viewport (
cam_id,
x,
y,
width,
height
)
parameters
cam_id ID camera identifier
x INTEGER x offset - default: 0
y INTEGER y offset - default: 0
width INTEGER width of the viewport
height INTEGER height of the viewport
return values
none
code sample
gh_camera.set_viewport(cam_id, 0, 0, screen_width, screen_height)
syntax
gh_camera.set_yaw (
cam_id,
yaw
)
parameters
cam_id ID camera identifier
yaw REAL yaw in degrees
return values
none
code sample
gh_camera.set_yaw(cam_id, yaw)
syntax
gh_camera.update_ortho (
cam_id,
left,
right,
bottom,
top,
znear,
zfar
)
parameters
cam_id ID camera identifier
left REAL left clipping plane
right REAL right clipping plane
bottom REAL bottom clipping plane
top REAL top clipping plane
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
w = screen_width
h = screen_height
gh_camera.update_ortho(cam_id, -w/2, w/2, -h/2, h/2, 1.0, -1.0)
syntax
gh_camera.update_persp (
cam_id,
fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
gh_camera.update_persp(cam_id, 60, 1.333, 0.1, 1000.0)
syntax
gh_camera.update_persp_v2 (
cam_id,
fov,
is_vertical_fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
is_vertical_fov BOOLEAN 1 (vertical fov) or 0 (horizontal fov)
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
local is_vertical_fov = 1
gh_camera.update_persp_v2(cam_id, 60, is_vertical_fov, 1.333, 0.1, 1000.0)
syntax
gh_camera.update_perspective_vk (
cam_id,
fov,
aspect,
znear,
zfar
)
parameters
cam_id ID camera identifier
fov REAL field of view in degres
aspect REAL aspect ratio (usually screen_width / screen_height)
znear REAL near clipping plane
zfar REAL far clipping plane
return values
none
code sample
gh_camera.update_perspective_vk(cam_id, 60.0, winW/winH, 1.0, 1000.0)
gh_gpu_program
GPU program module
gh_gpu_program is the module that manages GPU programs based on the GLSL language: creation, destruction, binding, uniforms settings.
add_shader_from_buffer
Adds a shader, specified by a memory buffer, to an existing GPU program, created by create_empty().
syntax
ret = gh_gpu_program.add_shader_from_buffer (
gpuprog_id,
buff_ptr,
buff_size,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
-- shader types:
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
filename = demo_dir .. "assets/vertex_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_VERTEX)
gh_utils.file_buffer_kill(buffer)
filename = demo_dir .. "assets/pixel_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_PIXEL)
gh_utils.file_buffer_kill(buffer)
syntax
gh_gpu_program.bind (
gpuprog_id
)
parameters
gpuprog_id ID gpu program identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id) -- Binding
...
gh_gpu_program.bind(0) -- Unbinding
create
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control and evaluation (tcs and tes) or compute (cs) shaders.
syntax
gpuprog_id = gh_gpu_program.create (
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
vs STRING vertex shader source code string
ps STRING pixel shader source code string
gs STRING geometry shader source code string
tcs STRING tessellation control shader source code string
tes STRING tessellation eval shader source code string
cs STRING compute shader source code string
return values
gpuprog_id ID gpu program identifier
code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create(vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_empty (
program_name
)
parameters
program_name STRING name of the GPU program
return values
gpuprog_id ID gpu program identifier
code sample
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
syntax
gpuprog_id = gh_gpu_program.create_from_file (
filename,
absolute_path
)
parameters
filename STRING GPU program source code filename
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
gpuprog_id ID gpu program identifier
code sample
abs_path = 0 -- relative path
gpuprog_id = gh_gpu_program.create_from_file("data/shader.glsl", abs_path)
syntax
gpuprog_id = gh_gpu_program.create_from_file_v3 (
program_name,
filename
)
parameters
program_name STRING name of the GPU program
filename STRING absolute path of the GPU program source code file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
gpuprog_id = gh_gpu_program.create_from_file_v3("LightingProg", demo_dir .. "./data/lighting_prog.glsl")
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files (
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
parameters
program_name STRING name of the GPU program
vs_filename STRING absolute path of the vertex shader file
ps_filename STRING absolute path of the pixel shader file
gs_filename STRING absolute path of the geometry shader file
tcs_filename STRING absolute path of the tessellation control shader file
tes_filename STRING absolute path of the tessellation eval shader file
cs_filename STRING absolute path of the compute shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.txt"
ps = demo_dir .. "./shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_shader_files("LightingProg", vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv (
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
program_name STRING name of the GPU program
vs_fname STRING vertex shader: absolute path of the SMOL-V file
ps_fname STRING pixel shader: absolute path of the SMOL-V file
gs_fname STRING geometry shader: absolute path of the SMOL-V file
tcs_fname STRING tessellation control shader: absolute path of the SMOL-V file
tes_fname STRING tessellation eval shader: absolute path of the SMOL-V file
cs_fname STRING compute shader: absolute path of the SMOL-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv (
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
program_name STRING name of the GPU program
vs_fname STRING vertex shader: absolute path of the SPIR-V file
ps_fname STRING pixel shader: absolute path of the SPIR-V file
gs_fname STRING geometry shader: absolute path of the SPIR-V file
tcs_fname STRING tessellation control shader: absolute path of the SPIR-V file
tes_fname STRING tessellation eval shader: absolute path of the SPIR-V file
cs_fname STRING compute shader: absolute path of the SPIR-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_from_zip_file (
zip_filename,
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
parameters
zip_filename STRING absolute path of the zip file
program_name STRING name of the GPU program
vs_filename STRING absolute path of the vertex shader file
ps_filename STRING absolute path of the pixel shader file
gs_filename STRING absolute path of the geometry shader file
tcs_filename STRING absolute path of the tessellation control shader file
tes_filename STRING absolute path of the tessellation eval shader file
cs_filename STRING absolute path of the compute shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
local zip_filename = demo_dir .. "demo.zip"
vs = "shaders/vs.txt"
ps = "shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_zip_file(zip_filename, "LightingProg", vs, ps, "", "", "", "")
syntax
gpuprog_id = gh_gpu_program.create_from_zip_file_gl_spirv (
zip_fname,
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
parameters
zip_fname STRING absolute path to the zip file
program_name STRING name of the GPU program
vs_fname STRING vertex shader: path of the SPIR-V file in the zip archive
ps_fname STRING pixel shader: path of the SPIR-V file in the zip archive
gs_fname STRING geometry shader: path of the SPIR-V file in the zip archive
tcs_fname STRING tessellation control shader: path of the SPIR-V file in the zip archive
tes_fname STRING tessellation eval shader: path of the SPIR-V file in the zip archive
cs_fname STRING compute shader: path of the SPIR-V file in the zip archive
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zip_fname = demo_dir .. "data.zip"
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv(zip_fname, "prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_gl_spirv (
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
program_name STRING name of the GPU program
vs STRING vertex shader source code
ps STRING pixel shader source code
gs STRING geometry shader source code
tcs STRING tessellation control shader source code
tes STRING tessellation eval shader source code
cs STRING compute shader source code
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = "void main(){ ... }"
ps = "void main(){ ... }"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files (
program_name,
ms_filename,
ts_filename,
ps_filename
)
parameters
program_name STRING name of the GPU program
ms_filename STRING absolute path of the mesh shader file
ts_filename STRING absolute path of the task shader file
ps_filename STRING absolute path of the pixel shader file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/ms.txt"
ps = demo_dir .. "./shaders/ps.txt"
mesh_prog = gh_gpu_program.create_mesh_task_from_shader_files("MeshProg", ms, "", ps)
syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv (
program_name,
ms_fname,
ts_fname,
ps_fname
)
parameters
program_name STRING name of the GPU program
ms_fname STRING mesh shader: absolute path of the SPIR-V file
ts_fname STRING task shader: absolute path of the SPIR-V file
ps_fname STRING pixel shader: absolute path of the SPIR-V file
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
ts = ""
meshprog = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv("prog", ms, ts, ps)
create_v2
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control (tcs), evaluation (tes) or compute (cs) shaders.
All these shaders are memory buffers.
syntax
gpuprog_id = gh_gpu_program.create_v2 (
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
parameters
program_name STRING name of the GPU program
vs STRING vertex shader source code string
ps STRING pixel shader source code string
gs STRING geometry shader source code string
tcs STRING tessellation control shader source code string
tes STRING tessellation eval shader source code string
cs STRING compute shader source code string
return values
gpuprog_id ID gpu program identifier
code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create_v2("LightingProg", vs, ps, "", "", "", "")
syntax
block_index = gh_gpu_program.get_interface_block_index (
gpuprog_id,
block_type,
block_name
)
parameters
gpuprog_id ID gpu program identifier
block_type ENUM( gpu_buffer_type ) type of the block: 'UNIFORM', 'SHADER_STORAGE'
block_name STRING name of the block
return values
block_index INTEGER block index
code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
syntax
stride = gh_gpu_program.get_uniform_array_stride (
gpuprog_id,
variable_name
)
parameters
gpuprog_id ID gpu program identifier
variable_name STRING name of the variable
return values
stride INTEGER stride in bytes
code sample
stride = gh_gpu_program.get_uniform_array_stride(gpuprog_id, "positions")
syntax
block_size = gh_gpu_program.get_uniform_block_size (
gpuprog_id,
block_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
return values
block_size INTEGER block size in bytes
code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
size = gh_gpu_program.get_uniform_block_size(gpuprog_id, index)
syntax
size, offset = gh_gpu_program.get_uniform_size_and_offset (
gpuprog_id,
variable_name
)
parameters
gpuprog_id ID gpu program identifier
variable_name STRING name of the variable
return values
size, offset INTEGER size and offset in bytes
code sample
size, offset = gh_gpu_program.get_uniform_size_and_offset(gpuprog_id, "positions")
syntax
name = gh_gpu_program.get_vertex_attrib_name (
gpuprog_id,
vertex_index
)
parameters
gpuprog_id ID gpu program identifier
vertex_index INTEGER vertex attribute index
return values
name STRING vertex attrib name
code sample
gh_gpu_program.bind(gpuprog_id)
name = gh_gpu_program.get_vertex_attrib_name(gpuprog_id, 0)
syntax
gh_gpu_program.run_compute (
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z
)
parameters
gpuprog_id ID gpu program identifier
num_groups_x, num_groups_y, num_groups_z INTEGER specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute(gpuprog_id, 16, 16, 16)
syntax
gh_gpu_program.run_compute_group_size (
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z,
work_group_size_x, work_group_size_y, work_group_size_z
)
parameters
gpuprog_id ID gpu program identifier
num_groups_x, num_groups_y, num_groups_z INTEGER specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
work_group_size_x, work_group_size_y, work_group_size_z INTEGER specifies the work group size in the X, Y and Z dimensions
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute_group_size(gpuprog_id, num_groups_x, num_groups_y, num_groups_z, work_group_size_x, work_group_size_y, work_group_size_z)
syntax
gh_gpu_program.set_livecoding_state (
gpuprog_id,
shader_type,
state
)
parameters
gpuprog_id ID gpu program identifier
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
state BOOLEAN live coding: 1 (enabled) or 0 (disabled)
return values
none
code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
shader_type = GPU_SHADER_PIXEL
state = 1
gh_gpu_program.set_livecoding_state(gpuprog_id, shader_type, state)
syntax
gh_gpu_program.set_shader_storage_block_binding (
gpuprog_id,
block_index,
binding_point_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
binding_point_index INTEGER index of a GPU buffer binding point
return values
none
code sample
gh_gpu_program.set_shader_storage_block_binding(gpuprog_id, index, 3)
syntax
gh_gpu_program.set_uniform_block_binding (
gpuprog_id,
block_index,
binding_point_index
)
parameters
gpuprog_id ID gpu program identifier
block_index INTEGER block index
binding_point_index INTEGER index of a GPU buffer binding point
return values
none
code sample
gh_gpu_program.set_uniform_block_binding(gpuprog_id, index, 2)
syntax
gh_gpu_program.set_vertex_attrib_name (
gpuprog_id,
vertex_index,
name
)
parameters
gpuprog_id ID gpu program identifier
vertex_index INTEGER vertex attribute index
name STRING vertex attrib name
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.set_vertex_attrib_name(gpuprog_id, 0, "gxl3d_Position")
syntax
gh_gpu_program.uniform1d (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1d(gpuprog_id, "r", 0.25)
syntax
gh_gpu_program.uniform1f (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x REAL uniform value
return values
none
code sample
elapsed_time = gh_utils.get_elapsed_time()
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1f(gpuprog_id, "time", elapsed_time)
syntax
gh_gpu_program.uniform1fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
temperatures = {}
temperatures[1] = 20.0
temperatures[2] = 21.0
temperatures[3] = 24.0
temperatures[4] = 29.0
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1fv(gpuprog_id, "temperatures", 4, temperatures)
syntax
gh_gpu_program.uniform1i (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1i(gpuprog_id, "index", 2)
syntax
gh_gpu_program.uniform1iv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
material_ids = {}
InitMaterialIDs(material_ids)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1iv(gpuprog_id, "material_ids", material_ids, 10)
syntax
gh_gpu_program.uniform1ui64 (
gpuprog_id,
uniform_name,
x
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64(gpuprog_id, "tex", bindless_texture_handle)
syntax
gh_gpu_program.uniform1ui64v (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array
return values
none
code sample
all_texture_handles = {}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64v(gpuprog_id, "all_textures", 32, all_texture_handles)
syntax
gh_gpu_program.uniform2d (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2d(gpuprog_id, "rg", 0.25, 0.22)
syntax
gh_gpu_program.uniform2f (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2f(gpuprog_id, "uv", 0.1, 1.0)
syntax
gh_gpu_program.uniform2fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=...}. In Python, each element is a tuple: (0.25, 0.59)
return values
none
code sample
uv = {}
uv[1]={x=0, y=0}
uv[2]={x=0.2, y=0}
uv[3]={x=0.4, y=0.2}
uv[4]={x=0.6, y=0.25}
uv[5]={x=0.8, y=0.5}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2fv(gpuprog_id, "uv", 5, uv)
syntax
gh_gpu_program.uniform2i (
gpuprog_id,
uniform_name,
x, y
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2i(gpuprog_id, "rg", 250, 25)
syntax
gh_gpu_program.uniform3d (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3d(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
syntax
gh_gpu_program.uniform3f (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3f(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
syntax
gh_gpu_program.uniform3fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0)
return values
none
code sample
xyz = {} -- array element: {x=0, y=0, z=0}
InitXYZ(xyz)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3fv(gpuprog_id, "xyz", 10, xyz)
syntax
gh_gpu_program.uniform3i (
gpuprog_id,
uniform_name,
x, y, z
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3i(gpuprog_id, "rgb", 250, 25, 45)
syntax
gh_gpu_program.uniform4d (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4d(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
syntax
gh_gpu_program.uniform4f (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
syntax
gh_gpu_program.uniform4f_array (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w REAL Uniform value. The four elements of an uniform array: float xyzw[4]
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f_array(gpuprog_id, "all_params", 0.2, 10.4, 0.003, 0.001)
syntax
gh_gpu_program.uniform4fv (
gpuprog_id,
uniform_name,
array_count,
array
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
array_count INTEGER number of entries of the uniform array
array TABLE uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=..., w=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0, 1.0)
return values
none
code sample
xyzw = {} -- array element: {x=0, y=0, z=0, w=0}
InitXYZW(xyzw)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4fv(gpuprog_id, "xyzw", 10, xyzw)
syntax
gh_gpu_program.uniform4i (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w INTEGER uniform value
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i(gpuprog_id, "rgba", 250, 25, 45, 100)
syntax
gh_gpu_program.uniform4i_array (
gpuprog_id,
uniform_name,
x, y, z, w
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
x, y, z, w INTEGER Uniform value. The four elements of an uniform array: int xyzw[4]
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i_array(gpuprog_id, "all_textures", 0, 1, 2, 3)
syntax
gh_gpu_program.uniform_3x3f (
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
m0,m1,m2,m3,m4,m5,m6,m7,m8 REAL the 9 floats that make the 3x3 matrix
return values
none
code sample
gh_gpu_program.uniform_3x3f(gpuprog_id, "rotMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8)
syntax
gh_gpu_program.uniform_4x4f (
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
gpuprog_id ID gpu program identifier
uniform_name STRING uniform name
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
return values
none
code sample
gh_gpu_program.uniform_4x4f(gpuprog_id, "myMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_gpu_program.uniform_camera_matrices (
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
uniform_name_view_mat STRING name of the view matrix
uniform_name_proj_mat STRING name of the projection matrix
return values
none
code sample
gh_gpu_program.uniform_camera_matrices(gpuprog_id, camera, "ViewMat", "ProjMat")
syntax
gh_gpu_program.uniform_camera_matrices_v2 (
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat,
uniform_name_viewproj_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
uniform_name_view_mat STRING name of the view matrix
uniform_name_proj_mat STRING name of the projection matrix
uniform_name_viewproj_mat STRING name of the view projection matrix
return values
none
code sample
gh_gpu_program.uniform_camera_matrices_v2(gpuprog_id, camera, "ViewMat", "ProjMat", "ViewProjMat")
uniform_matrix
Sets an uniform 4x4 matrix (mat4 in GLSL) built from the transformation matrix of an object (camera, mesh, etc.).
syntax
gh_gpu_program.uniform_matrix (
gpuprog_id,
object_id,
uniform_name,
matrix_type,
upload_to_gpu
)
parameters
gpuprog_id ID gpu program identifier
object_id ID object identifier
uniform_name STRING name of the uniform 4x4 matrix
matrix_type INTEGER type of the matrix: 'camera_view_projection', 'camera_view', 'camera_inv_view', 'camera_projection', 'camera_inv_projection' 'object_local_tranform', 'object_global_tranform'
upload_to_gpu INTEGER If 1, the uniform value is immedialtly uploaded to the GPU. If 0, the value will be uploaded later during the rendering.
return values
none
code sample
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ViewMatrix", "camera_view")
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ProjMatrix", "camera_projection")
gh_gpu_program.uniform_matrix(gpuprog_id, object_id, "ModelMatrix", "object_global_tranform")
syntax
gh_gpu_program.uniform_modelviewproj_matrices (
gpuprog_id,
cam_id,
obj_id,
uniform_name_modelviewproj_mat,
uniform_name_modelview_mat
)
parameters
gpuprog_id ID gpu program identifier
cam_id ID camera identifier
obj_id ID object identifier
uniform_name_modelviewproj_mat STRING name of the model view projection matrix
uniform_name_modelview_mat STRING name of the model view matrix
return values
none
code sample
gh_gpu_program.uniform_modelviewproj_matrices(gpuprog_id, camera, mesh, "ModelViewProj", "ModelView")
syntax
gh_gpu_program.uniform_object_matrix (
gpuprog_id,
obj_id,
uniform_name_mat
)
parameters
gpuprog_id ID gpu program identifier
obj_id ID object identifier
uniform_name_mat STRING name of the uniform variable
return values
none
code sample
gh_gpu_program.uniform_object_matrix(gpuprog_id, object, "ModelMat")
syntax
gh_gpu_program.uniform_subroutine (
gpuprog_id,
shader_type,
subroutine_uniform_name,
subroutine_name
)
parameters
gpuprog_id ID gpu program identifier
shader_type ENUM( gpu_program_shader_type ) type of shader (vertex, pixel, etc.)
subroutine_uniform_name STRING uniform name of the subroutine
subroutine_name STRING name of the real subroutine
return values
none
code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gh_gpu_program.uniform_subroutine(gpuprog_id, GPU_SHADER_PIXEL, "Color", "ColorBlue")
syntax
gh_gpu_program.uniform_transform_matrix_v1 (
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
pitch, yaw, roll,
sx, sy, sz,
transform_order
)
parameters
gpuprog_id ID gpu program identifier
uniform_matrix_name STRING name of the uniform variable
posx, posy, posz REAL 3D position
pitch, yaw, roll REAL Euler angles in degrees
sx, sy, sz REAL 3D scale
transform_order INTEGER order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
return values
none
code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, pitch, yaw, roll, sx, sy, sz, transform_order)
syntax
gh_gpu_program.uniform_transform_matrix_v2 (
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
qx, qy, qz, qw,
sx, sy, sz,
transform_order
)
parameters
gpuprog_id ID gpu program identifier
uniform_matrix_name STRING name of the uniform variable
posx, posy, posz REAL 3D position
qx, qy, qz, qw REAL Orientation quaternion
sx, sy, sz REAL 3D scale
transform_order INTEGER order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
return values
none
code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, qx, qy, qz, qw, sx, sy, sz, transform_order)
syntax
gh_gpu_program.update_shader_from_file (
gpuprog_id,
filename,
is_abs_path,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
filename STRING shader filename
is_abs_path INTEGER filename is specified with an absolute (1) or relative (0) path
shader_type STRING type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
return values
none
code sample
gh_gpu_program.update_shader_from_file(gpuprog_id, "data/ps.txt", 0, "pixel")
syntax
gh_gpu_program.update_shader_from_memory (
gpuprog_id,
shader_code,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
shader_code STRING shader code (a string)
shader_type STRING type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
return values
none
code sample
pixel_shader = "....."
gh_gpu_program.update_shader_from_memory(gpuprog_id, pixel_shader, "pixel")
syntax
gh_gpu_program.vk_add_spirv_module_file (
gpuprog_id,
filename,
entry_point,
shader_type
)
parameters
gpuprog_id ID gpu program identifier
filename STRING filename of the SPIR-V module
entry_point STRING entry point of the SPIR-V module. Usually main.
shader_type INTEGER type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
filename_vs = demo_dir .. "./spirv/vs.spv"
filename_ps = demo_dir .. "./spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_file(prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_file(prog, filename_ps, "main", GPU_SHADER_PIXEL)
syntax
gh_gpu_program.vk_add_spirv_module_zip (
zip_filename,
gpuprog_id,
filename,
entry_point,
shader_type
)
parameters
zip_filename STRING filename of the zip archive
gpuprog_id ID gpu program identifier
filename STRING filename of the SPIR-V module in the zip archive
entry_point STRING entry point of the SPIR-V module. Usually main.
shader_type INTEGER type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
return values
none
code sample
demo_dir = gh_utils.get_demo_dir()
zip_filename = demo_dir .. "data.zip"
filename_vs = "spirv/vs.spv"
filename_ps = "spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_ps, "main", GPU_SHADER_PIXEL)
syntax
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file (
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file (
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip (
zip_filename,
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
parameters
zip_filename STRING absolute path to the zip archive
program_name STRING name of the GPU program
vs_fname, vs_entry_point STRING vertex shader: absolute path of the shader file, entry point name
ps_fname, ps_entry_point STRING pixel shader: ...
gs_fname, gs_entry_point STRING geometry shader: ...
tcs_fname, tcs_entry_point STRING tessellation control shader: ...
tes_fname, tes_entry_point STRING tessellation eval shader: ...
cs_fname, cs_entry_point STRING compute shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
vs = "shaders/vs.spv"
ps = "shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip(zipfile, "LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file (
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
parameters
program_name STRING name of the GPU program
ms_fname, ms_entry_point STRING mesh shader: absolute path of the shader file, entry point name
ts_fname, ts_entry_point STRING task shader: ...
ps_fname, ps_entry_point STRING pixel shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file("MeshProg", ms,"main", "","", ps,"main")
syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip (
zip_filename,
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
parameters
zip_filename STRING absolute path to the zip archive
program_name STRING name of the GPU program
ms_fname, ms_entry_point STRING mesh shader: absolute path of the shader file, entry point name
ts_fname, ts_entry_point STRING task shader: ...
ps_fname, ps_entry_point STRING pixel shader: ...
return values
gpuprog_id ID gpu program identifier
code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
ms = "shaders/ms.spv"
ps = "shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip(zipfile, "MeshProg", ms,"main", "","", ps,"main")
syntax
gh_imgui.add_bezier_curve_to_drawlist (
x0, y0,
cp0x, cp0y,
cp1x, cp1y,
x1, y1,
r, g, b, a
)
parameters
x0, y0 REAL start position
cp0x, cp0y REAL control point 0
cp1x, cp1y REAL control point 1
x1, y1 REAL end position
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.add_bezier_curve_to_drawlist(p0_x, p0_y, ctrl0_x, ctrl0_y, ctrl1_x, ctrl1_y, p1_x, p1_y, r, g, b, a)
syntax
gh_imgui.add_circle_to_drawlist (
center_x, center_y,
radius,
r, g, b, a,
line_thickness,
num_segments,
filled
)
parameters
center_x, center_y REAL position of the circle center
radius REAL radius of the circle
r, g, b, a REAL RGBA color
line_thickness REAL line thickness
num_segments INTEGER number of segments of the circle
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
num_segments = 20
filled = 1
gh_imgui.add_circle_to_drawlist(center_x, center_y, radius, r, g, b, a, thickness, num_segments, filled)
syntax
font_id = gh_imgui.add_font_from_buffer (
buff_ptr,
buff_size,
font_size
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
filename = demo_dir .. "assets/arial.ttf"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
font_id = gh_imgui.add_font_from_buffer(buffer, buffer_size, 24)
gh_utils.file_buffer_kill(buffer)
syntax
font_id = gh_imgui.add_font_from_file (
font_filename,
font_size
)
parameters
font_filename STRING absolute path of the font file
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
font_id = gh_imgui.add_font_from_file(font_filename, 24)
syntax
font_id = gh_imgui.add_font_from_zip_file (
zip_filename,
font_filename,
font_size
)
parameters
zip_filename STRING absolute path of the zip file
font_filename STRING absolute path of the font file
font_size INTEGER size of the font
return values
font_id ID font identifier
code sample
font_id = gh_imgui.add_font_from_zip_file(zip_filename, font_filename, 24)
syntax
gh_imgui.add_line_to_drawlist (
x0, y0,
x1, y1,
r, g, b, a
)
parameters
x0, y0 REAL start position
x1, y1 REAL end position
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.add_line_to_drawlist(start_x, start_y, end_x, end_y, r, g, b, a)
syntax
gh_imgui.add_quad_to_drawlist (
ax, ay,
bx, by,
cx, cy,
dx, dy,
r, g, b, a,
thickness,
filled
)
parameters
ax, ay REAL position of the 1st point
bx, by REAL position of the 2nd point
cx, cy REAL position of the 3rd point
dx, dy REAL position of the 4th point
r, g, b, a REAL RGBA color
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
filled = 1
gh_imgui.add_quad_to_drawlist(ax, ay, bx, by, cx, cy, dx, dy, r, g, b, a, thickness, filled)
syntax
gh_imgui.add_rect_filled_multicolor_to_drawlist (
p_min_x, p_min_y,
p_max_x, p_max_y,
r0, g0, b0, a0,
r1, g1, b1, a1,
r2, g2, b2, a2,
r3, g3, b3, a3
)
parameters
p_min_x, p_min_y REAL position of the bottom_left corner
p_max_x, p_max_y REAL position of the top right corner
r0, g0, b0, a0 REAL RGBA up-left
r1, g1, b1, a1 REAL RGBA up-right
r2, g2, b2, a2 REAL RGBA bottom-right
r3, g3, b3, a3 REAL RGBA bottom-left
return values
none
code sample
gh_imgui.add_rect_filled_multicolor_to_drawlist(p_min_x, p_min_y, p_max_x, p_max_y,
r0, g0, b0, a0,
r1, g1, b1, a1,
r2, g2, b2, a2,
r3, g3, b3, a3)
syntax
gh_imgui.add_rect_to_drawlist (
p_min_x, p_min_y,
p_max_x, p_max_y,
r, g, b, a,
rounding,
thickness,
filled
)
parameters
p_min_x, p_min_y REAL position of the bottom_left corner
p_max_x, p_max_y REAL position of the top right corner
r, g, b, a REAL RGBA color
rounding REAL corner rounding
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
rounding = 0
thickness = 2
filled = 1
gh_imgui.add_rect_to_drawlist(p_min_x, p_min_y, p_max_x, p_max_y, r, g, b, a, rounding, thickness, filled)
syntax
gh_imgui.add_triangle_to_drawlist (
p1x, p1y,
p2x, p2y,
p3x, p3y,
r, g, b, a,
thickness,
filled
)
parameters
p1x, p1y REAL position of the first vertex
p2x, p2y REAL position of the second vertex
p3x, p3y REAL position of the third vertex
r, g, b, a REAL RGBA color
thickness REAL line thickness
filled INTEGER solid (1) or wireframe (0)
return values
none
code sample
thickness = 2
filled = 1
gh_imgui.add_triangle_to_drawlist(p1x, p1y, p2x, p2y, p3x, p3y, r, g, b, a, thickness, filled)
syntax
gh_imgui.begin_child (
label,
width, height,
border,
flags
)
parameters
label STRING name of the button
width, height REAL size of the region
border BOOLEAN border: 1 (enabled) or 0 (disabled)
flags ENUM( imgui_WindowFlags ) see window flags (ImGuiWindowFlags_xxx) in imgui.lua
return values
none
code sample
gh_imgui.begin_child(label, w, h, border, flags)
syntax
gh_imgui.begin_disabled (
disabled
)
parameters
disabled INTEGER 0 or 1
return values
none
code sample
gh_imgui.begin_disabled(1)
syntax
gh_imgui.bullet()
parameters
none
return values
none
code sample
gh_imgui.bullet()
syntax
pressed = gh_imgui.button (
label,
width, height
)
parameters
label STRING name of the button
width, height INTEGER width and height of the button
return values
pressed BOOLEAN pressed: 1 (true) or 0 (false)
code sample
pressed = gh_imgui.button("Fire", 200, 20)
syntax
pressed = gh_imgui.button_arrow (
label,
direction
)
parameters
label STRING name of the button
direction ENUM( arrow_dir ) arrow direction: 0 (left), 1 (right), 2(up) and 3(down)
return values
pressed BOOLEAN pressed: 1 (true) or 0 (false)
code sample
pressed = gh_imgui.button_arrow("Fire", 1)
syntax
x, y = gh_imgui.calc_text_size (
text
)
parameters
text STRING text
return values
x, y REAL size of the text
code sample
x, y = gh_imgui.calc_text_size("Hello")
checkbox
Create a checkbox.
syntax
checked = gh_imgui.checkbox (
label,
current_state
)
parameters
label STRING name of the button
current_state BOOLEAN checked: 1 (true) or 0 (false)
return values
checked BOOLEAN checked: 1 (true) or 0 (false)
code sample
checked = gh_imgui.checkbox("Wireframe", checked)
syntax
r, g, b, a = gh_imgui.color_edit_rgba (
label,
r0, b0, g0, a0
)
parameters
label STRING name of the slider
r0, b0, g0, a0 REAL initial 4D value
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_imgui.color_edit_rgba("coloredit01", r0, b0, g0, a0)
syntax
r, g, b, a = gh_imgui.color_edit_rgba_v2 (
label,
r0, b0, g0, a0,
flags
)
parameters
label STRING name of the slider
r0, b0, g0, a0 REAL initial 4D value
flags ENUM( imgui_ColorEditFlags ) ImGuiColorEditFlags_xxx options
return values
r, g, b, a REAL RGBA color value
code sample
flags = ImGuiColorEditFlags_None
r, g, b, a = gh_imgui.color_edit_rgba_v2("coloredit01", r0, b0, g0, a0, flags)
color_picker_rgba
Displays a color picker.
syntax
r, g, b, a = gh_imgui.color_picker_rgba (
label,
r0, b0, g0, a0
)
parameters
label STRING name of the color picker
r0, b0, g0, a0 REAL initial 4D value
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_imgui.color_picker_rgba("coloredit01", r0, b0, g0, a0)
color_picker_rgba_v2
Displays a color picker.
syntax
r, g, b, a = gh_imgui.color_picker_rgba_v2 (
label,
r0, b0, g0, a0,
flags
)
parameters
label STRING name of the color picker
r0, b0, g0, a0 REAL initial 4D value
flags ENUM( imgui_ColorEditFlags ) ImGuiColorEditFlags_xxx options
return values
r, g, b, a REAL RGBA color value
code sample
flags = ImGuiColorEditFlags_None
r, g, b, a = gh_imgui.color_picker_rgba_v2("coloredit01", r0, b0, g0, a0, flags)
syntax
gh_imgui.color_text_editor_copy_paste_cut (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING operation: copy, paste or cut
return values
none
code sample
gh_imgui.color_text_editor_copy_paste_cut(te_id, "copy")
syntax
te_id = gh_imgui.color_text_editor_create()
parameters
none
return values
te_id ID text editor identifier
code sample
te_id = gh_imgui.color_text_editor_create()
color_text_editor_get_current_line_text
Gets the current line.
syntax
line = gh_imgui.color_text_editor_get_current_line_text (
te_id
)
parameters
te_id ID text editor identifier
return values
line STRING current line
code sample
line = gh_imgui.color_text_editor_get_current_line_text(te_id)
syntax
x, y = gh_imgui.color_text_editor_get_cursor_position (
te_id
)
parameters
te_id ID text editor identifier
return values
x, y INTEGER current cursor position
code sample
x, y = gh_imgui.color_text_editor_get_cursor_position(te_id)
color_text_editor_get_selected_text
Gets the selected text.
syntax
text = gh_imgui.color_text_editor_get_selected_text (
te_id
)
parameters
te_id ID text editor identifier
return values
text STRING selected text
code sample
text = gh_imgui.color_text_editor_get_selected_text(te_id)
syntax
text = gh_imgui.color_text_editor_get_text (
te_id
)
parameters
te_id ID text editor identifier
return values
text STRING text
code sample
text = gh_imgui.color_text_editor_get_text(te_id)
syntax
n = gh_imgui.color_text_editor_get_total_lines (
te_id
)
parameters
te_id ID text editor identifier
return values
n INTEGER number of lines
code sample
n = gh_imgui.color_text_editor_get_total_lines(te_id)
syntax
x = gh_imgui.color_text_editor_is_text_changed (
te_id
)
parameters
te_id ID text editor identifier
return values
x INTEGER 1 if text changed, 0 if not.
code sample
x = gh_imgui.color_text_editor_is_text_changed(te_id)
color_text_editor_kill
Destroys a text editor.
syntax
gh_imgui.color_text_editor_kill (
te_id
)
parameters
te_id ID text editor identifier
return values
none
code sample
gh_imgui.color_text_editor_kill(te_id)
syntax
r, g, b, a = gh_imgui.color_text_editor_palette_get_color (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING element name: Default, Keyword, Number, String, Punctuation, Preprocessor, Identifier, KnownIdentifier, PreprocIdentifier, Comment, MultiLineComment, Background, Cursor, Selection, ErrorMarker, Breakpoint, LineNumber, CurrentLineFill, CurrentLineFillInactive, CurrentLineEdge
return values
r, g, b, a REAL RGBA color
code sample
r, g, b, a = gh_imgui.color_text_editor_palette_get_color(te_id, "Background")
syntax
gh_imgui.color_text_editor_palette_set_color (
te_id,
what,
r, g, b, a
)
parameters
te_id ID text editor identifier
what STRING element name: Default, Keyword, Number, String, Punctuation, Preprocessor, Identifier, KnownIdentifier, PreprocIdentifier, Comment, MultiLineComment, Background, Cursor, Selection, ErrorMarker, Breakpoint, LineNumber, CurrentLineFill, CurrentLineFillInactive, CurrentLineEdge, XT95Line
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.color_text_editor_palette_set_color(te_id, "Background", r, g, b, a)
gh_imgui.color_text_editor_palette_set_color(te_id, "XT95Line", 0.2, 0.2, 0.2, 0.8)
color_text_editor_render
Draws a text editor.
syntax
gh_imgui.color_text_editor_render (
te_id,
title,
size_x, size_y,
border
)
parameters
te_id ID text editor identifier
title STRING title
size_x, size_y REAL frame size
border INTEGER border (1: yes, 0: no)
return values
none
code sample
gh_imgui.color_text_editor_render(te_id, "Lua Editor", 400, 600, 0)
syntax
gh_imgui.color_text_editor_selection (
te_id,
what
)
parameters
te_id ID text editor identifier
what STRING operation: start, end or clear
return values
none
code sample
gh_imgui.color_text_editor_selection(te_id, "start")
syntax
gh_imgui.color_text_editor_set_language (
te_id,
lang
)
parameters
te_id ID text editor identifier
lang STRING langaue: lua, glsl, hlsl, cpp, c, sql
return values
none
code sample
gh_imgui.color_text_editor_set_language(te_id, "lua")
syntax
gh_imgui.color_text_editor_set_palette (
te_id,
pal
)
parameters
te_id ID text editor identifier
pal STRING palette: dark, light, retro_blue
return values
none
code sample
gh_imgui.color_text_editor_set_palette(te_id, "dark")
syntax
gh_imgui.color_text_editor_set_property_bool (
te_id,
what,
x
)
parameters
te_id ID text editor identifier
what STRING property name: whitespaces, readonly, colorizer, handle_mouse_inputs, handle_keyboard_inputs
x INTEGER value
return values
none
code sample
gh_imgui.color_text_editor_set_property_bool(te_id, "whitespaces", 1)
syntax
gh_imgui.color_text_editor_set_property_int (
te_id,
what,
x
)
parameters
te_id ID text editor identifier
what STRING property name: tabsize
x INTEGER value
return values
none
code sample
gh_imgui.color_text_editor_set_property_int(te_id, "tabsize", 2)
syntax
gh_imgui.color_text_editor_set_text (
te_id,
text
)
parameters
te_id ID text editor identifier
text STRING text
return values
none
code sample
gh_imgui.color_text_editor_set_text(te_id, text)
syntax
offset = gh_imgui.column_get_offset (
index
)
parameters
index INTEGER column index
return values
offset REAL offset
code sample
offset = gh_imgui.column_get_offset(index)
syntax
width = gh_imgui.column_get_width (
index
)
parameters
index INTEGER column index
return values
width REAL width
code sample
width = gh_imgui.column_get_width(index)
column_next
Starts a new column.
syntax
gh_imgui.column_next()
parameters
none
return values
none
code sample
gh_imgui.columns(2, 1)
-- display widgets
...
-- next column
gh_imgui.column_next()
-- display widgets
...
-- reset to default layout (one column)
gh_imgui.columns(1, 0)
syntax
gh_imgui.column_set_offset (
index,
offset
)
parameters
index INTEGER column index
offset REAL offset
return values
none
code sample
gh_imgui.column_set_offset(index, width)
syntax
gh_imgui.column_set_width (
index,
width
)
parameters
index INTEGER column index
width REAL width
return values
none
code sample
gh_imgui.column_set_width(index, width)
syntax
gh_imgui.columns (
num_columns,
border
)
parameters
num_columns INTEGER number of columns
border INTEGER display column border ot not
return values
none
code sample
gh_imgui.columns(2, 1)
-- display widgets
...
-- next column
gh_imgui.column_next()
-- display widgets
...
-- reset to default layout (one column)
gh_imgui.columns(1, 0)
syntax
gh_imgui.combo_box_add_item (
cb_id,
item_label
)
parameters
cb_id ID combo box identifier
item_label STRING label of the item
return values
none
code sample
gh_imgui.combo_box_add_item(cb_id, "Item1")
syntax
cb_id = gh_imgui.combo_box_create (
label
)
parameters
label STRING combo box label
return values
cb_id ID combo box identifier
code sample
cb_id = gh_imgui.combo_box_create(label)
combo_box_draw
Draws the combo box.
syntax
selected_item = gh_imgui.combo_box_draw (
cb_id,
initial_selected_item
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.combo_box_draw(cb_id, 0)
combo_box_draw_v2
Draws the combo box.
syntax
selected_item = gh_imgui.combo_box_draw_v2 (
cb_id,
initial_selected_item,
height_in_items
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
height_in_items INTEGER height of the combo box in items
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.combo_box_draw_v2(cb_id, 0, 10)
syntax
gh_imgui.dummy (
width, height
)
parameters
width, height INTEGER dimensions of the box in pixels
return values
none
code sample
gh_imgui.dummy(10, 5)
end_child
End a scrolling region.
syntax
gh_imgui.end_child()
parameters
none
return values
none
code sample
gh_imgui.end_child()
end_disabled
Ends a disabled section.
syntax
gh_imgui.end_disabled()
parameters
none
return values
none
code sample
gh_imgui.end_disabled()
file_browser_add_type_filter
Adds a type filter.
syntax
gh_imgui.file_browser_add_type_filter (
type
)
parameters
type STRING type filter
return values
none
code sample
gh_imgui.file_browser_add_type_filter(".lua")
gh_imgui.file_browser_add_type_filter(".xml")
gh_imgui.file_browser_add_type_filter(".txt")
syntax
gh_imgui.file_browser_clear_type_filters()
parameters
none
return values
none
code sample
gh_imgui.file_browser_clear_type_filters()
syntax
gh_imgui.file_browser_close()
parameters
none
return values
none
code sample
gh_imgui.file_browser_close()
syntax
gh_imgui.file_browser_display (
width, height
)
parameters
width, height INTEGER size of the file browser window
return values
none
code sample
gh_imgui.file_browser_display(600, 400)
syntax
filename = gh_imgui.file_browser_get_selected()
parameters
none
return values
filename STRING the selected filename
code sample
if (gh_imgui.file_browser_has_selected() == 1) then
filename = gh_imgui.file_browser_get_selected()
end
syntax
ret = gh_imgui.file_browser_has_selected()
parameters
none
return values
ret INTEGER 1 (selected) or 0 (not selected)
code sample
if (gh_imgui.file_browser_has_selected() == 1) then
DoSomething()
end
syntax
gh_imgui.file_browser_init (
flags
)
parameters
flags INTEGER options. See ImGuiFileBrowserFlags_xxxx values in imgui.lua
return values
none
code sample
gh_imgui.file_browser_init(0)
syntax
gh_imgui.file_browser_open()
parameters
none
return values
none
code sample
gh_imgui.file_browser_open()
syntax
gh_imgui.file_browser_set_current_directory (
dir
)
parameters
dir STRING directory
return values
none
code sample
gh_imgui.file_browser_set_current_directory(demo_dir)
syntax
gh_imgui.file_browser_set_title (
text
)
parameters
text STRING title
return values
none
code sample
gh_imgui.file_browser_set_title(title)
syntax
gh_imgui.frame_begin (
width, height,
mouse_x, mouse_y,
mouse_left_button, mouse_right_button,
dt
)
parameters
width, height INTEGER size of the main 3D window (gh_window.getsize(0))
mouse_x, mouse_y INTEGER position of the mouse (gh_input.mouse_get_position())
mouse_left_button, mouse_right_button BOOLEAN state of mouse left and right buttons (gh_input.mouse_get_button_state())
dt REAL time step
return values
none
code sample
gh_imgui.frame_begin(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button, dt)
syntax
gh_imgui.frame_begin_v2 (
width, height,
mouse_x, mouse_y,
mouse_left_button, mouse_right_button,
mouse_wheel,
dt
)
parameters
width, height INTEGER size of the main 3D window (gh_window.getsize(0))
mouse_x, mouse_y INTEGER position of the mouse (gh_input.mouse_get_position())
mouse_left_button, mouse_right_button BOOLEAN state of mouse left and right buttons (gh_input.mouse_get_button_state())
mouse_wheel INTEGER mouse wheel delta
dt REAL time step
return values
none
code sample
gh_imgui.frame_begin_v2(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button, mouse_wheel, dt)
syntax
gh_imgui.frame_end()
parameters
none
return values
none
code sample
gh_imgui.frame_end()
syntax
gh_imgui.fx_drawlist_coding_party_demo (
fx_name,
title,
window_flags,
width, height,
size_flags,
x, y,
position_flags
)
parameters
fx_name STRING name of the demo or effect
title STRING window title
window_flags INTEGER window flags
width, height INTEGER window size
size_flags INTEGER size flags
x, y INTEGER window position
position_flags INTEGER position flags
return values
none
code sample
Current demos:
"ocornut_squares"
"ocornut_waves"
"kudaba_thunder_storm"
"crowbarous_blobs"
"badlydrawnrod_racetrack"
"floooh_googly_eyes"
"bdero_particles"
pos_size_flag_always = 1
pos_size_flag_once = 2
pos_size_flag_first_use_ever = 4
pos_size_flag_appearing = 8
pos_size_flag = pos_size_flag_always
window_default = 0
window_no_resize = 2
window_no_move = 4
window_no_collapse = 32
window_show_border = 128
window_no_save_settings = 256
window_flags = window_default
gh_imgui.fx_drawlist_coding_party_demo("ocornut_squares", "squares", window_flags, 320, 180, pos_size_flag, 20, 20, pos_size_flag_once)
syntax
r, g, b, a = gh_imgui.get_color (
item_type
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see values in the code sample)
return values
r, g, b, a REAL RGBA color value
code sample
widget_type = IMGUI_BUTTON_COLOR
r, g, b, a = gh_imgui.get_color(widget_type)
syntax
width = gh_imgui.get_content_region_available_width()
parameters
none
return values
width REAL available width
code sample
width = gh_imgui.get_content_region_available_width()
syntax
x, y = gh_imgui.get_cur_font_display_offset()
parameters
none
return values
x, y REAL offsets
code sample
x, y = gh_imgui.get_cur_font_display_offset()
syntax
x, y = gh_imgui.get_cursor_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_cursor_pos()
syntax
x, y = gh_imgui.get_cursor_screen_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_cursor_screen_pos()
syntax
x, y = gh_imgui.get_cursor_start_pos()
parameters
none
return values
x, y REAL cursor position
code sample
x, y = gh_imgui.get_cursor_start_pos()
syntax
size = gh_imgui.get_font_size()
parameters
none
return values
size REAL size
code sample
size = gh_imgui.get_font_size()
syntax
x, y, z, w = gh_imgui.get_item_rect()
parameters
none
return values
x, y, z, w INTEGER size of the current item
code sample
x, y, z, w = gh_imgui.get_item_rect()
syntax
x, y = gh_imgui.get_item_rect_max()
parameters
none
return values
x, y REAL 2D coordinates
code sample
x, y = gh_imgui.get_item_rect_max()
syntax
x, y = gh_imgui.get_item_rect_min()
parameters
none
return values
x, y REAL 2D coordinates
code sample
x, y = gh_imgui.get_item_rect_min()
syntax
x, y = gh_imgui.get_item_spacing()
parameters
none
return values
x, y REAL spacing
code sample
x, y = gh_imgui.get_item_spacing()
get_mouse_pos
Gets the mouse position.
syntax
x, y = gh_imgui.get_mouse_pos()
parameters
none
return values
x, y REAL mouse position
code sample
x, y = gh_imgui.get_mouse_pos()
syntax
scroll_x, scroll_y = gh_imgui.get_scroll()
parameters
none
return values
scroll_x, scroll_y REAL scrolling values in X and Y
code sample
scroll_x, scroll_y = gh_imgui.get_scroll()
syntax
scroll_x, scroll_y = gh_imgui.get_scroll_max()
parameters
none
return values
scroll_x, scroll_y REAL scrolling values in X and Y
code sample
scroll_x, scroll_y = gh_imgui.get_scroll_max()
syntax
h = gh_imgui.get_text_line_heigh_with_spacing()
parameters
none
return values
h REAL height
code sample
h = gh_imgui.get_text_line_heigh_with_spacing()
syntax
h = gh_imgui.get_text_line_height()
parameters
none
return values
h REAL line height
code sample
h = gh_imgui.get_text_line_height()
syntax
h = gh_imgui.get_text_line_height_with_spacing()
parameters
none
return values
h REAL line height
code sample
h = gh_imgui.get_text_line_height_with_spacing()
syntax
version = gh_imgui.get_version()
parameters
none
return values
version STRING ImGui version
code sample
version_str = gh_imgui.get_version()
syntax
x, y = gh_imgui.get_window_pos()
parameters
none
return values
x, y REAL position
code sample
x, y = gh_imgui.get_window_pos()
syntax
x, y, width, height = gh_imgui.get_window_pos_size()
parameters
none
return values
x, y, width, height REAL position and size
code sample
x, y, width, height = gh_imgui.get_window_pos_size()
syntax
width, height = gh_imgui.get_window_size()
parameters
none
return values
width, height REAL size
code sample
width, height = gh_imgui.get_window_size()
syntax
gh_imgui.gizmo_begin_frame()
parameters
none
return values
none
code sample
gh_imgui.frame_begin(...)
gh_imgui.gizmo_begin_frame()
...
syntax
tx,ty,tz, rx,ry,rz, sx,sy,sz = gh_imgui.gizmo_decompose_matrix_to_components (
obj_id
)
parameters
obj_id ID object identifier
return values
tx,ty,tz, rx,ry,rz, sx,sy,sz REAL translation vector, rotation vector and scale vector
code sample
tx,ty,tz, rx,ry,rz, sx,sy,sz = gh_imgui.gizmo_decompose_matrix_to_components(obj_id)
syntax
gh_imgui.gizmo_enable (
state
)
parameters
state INTEGER 0 or 1
return values
none
code sample
gh_imgui.gizmo_enable(1)
syntax
state = gh_imgui.gizmo_is_over()
parameters
none
return values
state BOOLEAN 1 (yes) or 0 (no)
code sample
is_over = gh_imgui.gizmo_is_over()
syntax
state = gh_imgui.gizmo_is_using()
parameters
none
return values
state BOOLEAN 1 (yes) or 0 (no)
code sample
is_using = gh_imgui.gizmo_is_using()
syntax
gh_imgui.gizmo_manipulate (
cam_id,
obj_id,
oper_type,
trans_mode
)
parameters
cam_id ID camera identifier
obj_id ID object identifier
oper_type ENUM( imgui_OperationType ) operation type: 'translate', 'rotate' or 'scale'
trans_mode ENUM( imgui_TransformationMode ) transformation mode: 'local' or 'world'
return values
none
code sample
gh_imgui.gizmo_manipulate(cam_id, obj_id, "rotate", "local")
syntax
gh_imgui.gizmo_set_rect (
x, y, width, height
)
parameters
x, y, width, height INTEGER viewport size
return values
none
code sample
gh_imgui.gizmo_set_rect(0, 0, winW, winH)
syntax
gh_imgui.group_begin()
parameters
none
return values
none
code sample
gh_imgui.group_begin()
-- display widgets
...
gh_imgui.group_end()
syntax
gh_imgui.group_end()
parameters
none
return values
none
code sample
gh_imgui.group_begin()
-- display widgets
...
gh_imgui.group_end()
syntax
gh_imgui.image (
tex_id,
width, height
)
parameters
tex_id ID texture identifier as returned by gh_texture.create_xxx() functions
width, height REAL image size
return values
none
code sample
gh_imgui.image(tex0, 200, 200)
syntax
gh_imgui.image_button (
tex_id,
width, height,
frame_padding
)
parameters
tex_id ID texture identifier as returned by gh_texture.create_xxx() functions
width, height REAL image size
frame_padding INTEGER frame padding
return values
none
code sample
gh_imgui.image_button(tex0, 200, 200, 1)
imgui_plot_create
Creates a plotline.
syntax
plot_id = gh_imgui.imgui_plot_create (
label
)
parameters
label STRING name of the plotline
return values
plot_id ID plotline identifier
code sample
plot_id = gh_imgui.imgui_plot_create("myPlotline")
syntax
gh_imgui.imguizmoquat_gizmo3d_v1 (
label,
size,
mode,
object_id
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
object_id REAL object identifier
return values
none
code sample
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
gh_imgui.imguizmoquat_gizmo3d_v1("##gizmo01", 100.0, modeDirection + cubeAtOrigin, torus)
syntax
qx, qy, qz, qw = gh_imgui.imguizmoquat_gizmo3d_v2 (
label,
size,
mode,
q0x, q0y, q0z, q0w
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
q0x, q0y, q0z, q0w REAL initial orientation quaternion
return values
qx, qy, qz, qw REAL orientation quaternion
code sample
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
q0 = {x=0, y=0, z=0, w=0}
qr = {x=0, y=0, z=0, w=0}
qr.x, qr.w, qr.z, qr.w = gh_imgui.imguizmoquat_gizmo3d_v2("##gizmo01", 100.0, modeDirection + cubeAtOrigin, q0.x, q0.y, q0.z, q0.w)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_imgui.imguizmoquat_gizmo3d_v3 (
label,
size,
mode,
q0x, q0y, q0z, q0w
)
parameters
label STRING label of the gizmo
size REAL size of the item
mode INTEGER gizmo mode
q0x, q0y, q0z, q0w REAL initial orientation quaternion
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
local mode3Axes = 1
local modeDirection = 2
local modeDirPlane = 4
local modeDual = 8
local modeMask = 15
local cubeAtOrigin = 16
local sphereAtOrigin = 32
local noSolidAtOrigin = 64
local modeFullAxes = 128
local axesModeMask = 240
q0 = {x=0, y=0, z=0, w=0}
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_imgui.imguizmoquat_gizmo3d_v3("##gizmo01", 100.0, modeDirection + cubeAtOrigin, q0.x, q0.y, q0.z, q0.w)
imnodes_begin_input_attribute
syntax
gh_imgui.imnodes_begin_input_attribute (
input_attr_id,
pin_shape
)
parameters
input_attr_id INTEGER
pin_shape INTEGER
return values
none
code sample
ImNodesPinShape_Circle = 0
ImNodesPinShape_CircleFilled = 1
ImNodesPinShape_Triangle = 2
ImNodesPinShape_TriangleFilled = 3
ImNodesPinShape_Quad = 4
ImNodesPinShape_QuadFilled = 5
pin_shape = ImNodesPinShape_CircleFilled
gh_imgui.imnodes_begin_input_attribute(input_attr_id, pin_shape)
syntax
gh_imgui.imnodes_begin_node (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_begin_node(node_id)
syntax
gh_imgui.imnodes_begin_node_editor()
parameters
none
return values
none
code sample
gh_imgui.imnodes_begin_node_editor()
imnodes_begin_node_title_bar
syntax
gh_imgui.imnodes_begin_node_title_bar()
parameters
none
return values
none
code sample
gh_imgui.imnodes_begin_node_title_bar()
imnodes_begin_output_attribute
syntax
gh_imgui.imnodes_begin_output_attribute (
output_attr_id,
pin_shape
)
parameters
output_attr_id INTEGER
pin_shape INTEGER
return values
none
code sample
ImNodesPinShape_Circle = 0
ImNodesPinShape_CircleFilled = 1
ImNodesPinShape_Triangle = 2
ImNodesPinShape_TriangleFilled = 3
ImNodesPinShape_Quad = 4
ImNodesPinShape_QuadFilled = 5
pin_shape = ImNodesPinShape_CircleFilled
gh_imgui.imnodes_begin_output_attribute(output_attr_id, pin_shape)
imnodes_clear_link_selection
syntax
gh_imgui.imnodes_clear_link_selection (
link_id
)
parameters
link_id INTEGER
return values
none
code sample
gh_imgui.imnodes_clear_link_selection(link_id)
imnodes_clear_links_selection
syntax
gh_imgui.imnodes_clear_links_selection()
parameters
none
return values
none
code sample
gh_imgui.imnodes_clear_links_selection()
imnodes_clear_node_selection
syntax
gh_imgui.imnodes_clear_node_selection (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_clear_node_selection(node_id)
imnodes_clear_nodes_selection
syntax
gh_imgui.imnodes_clear_nodes_selection()
parameters
none
return values
none
code sample
gh_imgui.imnodes_clear_nodes_selection()
syntax
gh_imgui.imnodes_end_node()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node()
syntax
gh_imgui.imnodes_end_node_editor()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node_editor()
imnodes_end_node_title_bar
syntax
gh_imgui.imnodes_end_node_title_bar()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_node_title_bar()
imnodes_end_output_attribute_DUP1
syntax
gh_imgui.imnodes_end_output_attribute_DUP1()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_output_attribute()
imnodes_end_output_attribute_DUP2
syntax
gh_imgui.imnodes_end_output_attribute_DUP2()
parameters
none
return values
none
code sample
gh_imgui.imnodes_end_output_attribute()
imnodes_get_node_editor_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_editor_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_editor_space_pos(node_id)
imnodes_get_node_grid_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_grid_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_grid_space_pos(node_id)
imnodes_get_node_screen_space_pos
syntax
x, y = gh_imgui.imnodes_get_node_screen_space_pos (
node_id
)
parameters
node_id INTEGER
return values
x, y REAL
code sample
x, y = gh_imgui.imnodes_get_node_screen_space_pos(node_id)
imnodes_get_selected_link
syntax
link_id = gh_imgui.imnodes_get_selected_link (
index
)
parameters
index INTEGER
return values
link_id INTEGER
code sample
link_id = gh_imgui.imnodes_get_selected_link(index)
imnodes_get_selected_node
syntax
node_id = gh_imgui.imnodes_get_selected_node (
index
)
parameters
index INTEGER
return values
node_id INTEGER
code sample
node_id = gh_imgui.imnodes_get_selected_node(index)
imnodes_is_editor_hovered
syntax
state = gh_imgui.imnodes_is_editor_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
code sample
state = gh_imgui.imnodes_is_editor_hovered()
syntax
state, started_at_attribute_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created()
parameters
none
return values
state BOOLEAN
started_at_attribute_id INTEGER
ended_at_attribute_id INTEGER
code sample
state, started_at_attribute_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created()
imnodes_is_link_created_v2
syntax
state, started_at_node_id, started_at_attribute_id, ended_at_node_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created_v2()
parameters
none
return values
state BOOLEAN
started_at_node_id INTEGER
started_at_attribute_id INTEGER
ended_at_node_id INTEGER
ended_at_attribute_id INTEGER
code sample
state, started_at_node_id, started_at_attribute_id, ended_at_node_id, ended_at_attribute_id = gh_imgui.imnodes_is_link_created_v2()
imnodes_is_link_destroyed
syntax
state, link_id = gh_imgui.imnodes_is_link_destroyed()
parameters
none
return values
state BOOLEAN
link_id INTEGER
code sample
state, link_id = gh_imgui.imnodes_is_link_destroyed()
syntax
state, started_at_attribute_id = gh_imgui.imnodes_is_link_dropped (
including_detached_links
)
parameters
including_detached_links INTEGER
return values
state BOOLEAN
started_at_attribute_id INTEGER
code sample
state, started_at_attribute_id = gh_imgui.imnodes_is_link_dropped(including_detached_links)
syntax
state, link_id = gh_imgui.imnodes_is_link_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
link_id INTEGER
code sample
state, link_id = gh_imgui.imnodes_is_link_hovered()
syntax
state = gh_imgui.imnodes_is_link_selected (
link_id
)
parameters
link_id INTEGER
return values
state BOOLEAN
code sample
state = gh_imgui.imnodes_is_link_selected(link_id)
syntax
state, started_at_attribute_id = gh_imgui.imnodes_is_link_started()
parameters
none
return values
state BOOLEAN
started_at_attribute_id INTEGER
code sample
state, started_at_attribute_id = gh_imgui.imnodes_is_link_started()
syntax
state, node_id = gh_imgui.imnodes_is_node_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
node_id INTEGER
code sample
state, node_id = gh_imgui.imnodes_is_node_hovered()
syntax
state = gh_imgui.imnodes_is_node_selected (
node_id
)
parameters
node_id INTEGER
return values
state BOOLEAN
code sample
state = gh_imgui.imnodes_is_node_selected(node_id)
syntax
state, pin_id = gh_imgui.imnodes_is_pin_hovered()
parameters
none
return values
state BOOLEAN 1 or 0
pin_id INTEGER
code sample
state, pin_id = gh_imgui.imnodes_is_pin_hovered()
syntax
gh_imgui.imnodes_link (
link_id,
start_attribute_id,
end_attribute_id
)
parameters
link_id INTEGER
start_attribute_id INTEGER
end_attribute_id INTEGER
return values
none
code sample
gh_imgui.imnodes_link(link_id, start_attribute_id, end_attribute_id)
syntax
gh_imgui.imnodes_minimap (
minimap_size_fraction,
minimap_location
)
parameters
minimap_size_fraction REAL
minimap_location INTEGER
return values
none
code sample
ImNodesMiniMapLocation_BottomLeft = 0
ImNodesMiniMapLocation_BottomRight = 1
ImNodesMiniMapLocation_TopLeft = 2
ImNodesMiniMapLocation_TopRight = 3
minimap_size_fraction = 0.2
minimap_location = ImNodesMiniMapLocation_BottomLeft
gh_imgui.imnodes_minimap(minimap_size_fraction, minimap_location)
imnodes_num_selected_links
syntax
n = gh_imgui.imnodes_num_selected_links()
parameters
none
return values
n INTEGER
code sample
n = gh_imgui.imnodes_num_selected_links()
imnodes_num_selected_nodes
syntax
n = gh_imgui.imnodes_num_selected_nodes()
parameters
none
return values
n INTEGER
code sample
n = gh_imgui.imnodes_num_selected_nodes()
syntax
gh_imgui.imnodes_pop_color_style()
parameters
none
return values
none
code sample
gh_imgui.imnodes_pop_color_style()
syntax
gh_imgui.imnodes_pop_style_var()
parameters
none
return values
none
code sample
gh_imgui.imnodes_pop_style_var()
syntax
r, g, b, a = gh_imgui.imnodes_push_color_style (
color_item
)
parameters
color_item INTEGER
return values
r, g, b, a REAL
code sample
ImNodesCol_NodeBackground = 0
ImNodesCol_NodeBackgroundHovered = 1
ImNodesCol_NodeBackgroundSelected = 2
ImNodesCol_NodeOutline = 3
ImNodesCol_TitleBar = 4
ImNodesCol_TitleBarHovered = 5
ImNodesCol_TitleBarSelected = 6
ImNodesCol_Link = 7
ImNodesCol_LinkHovered = 8
ImNodesCol_LinkSelected = 9
ImNodesCol_Pin = 10
ImNodesCol_PinHovered = 11
ImNodesCol_BoxSelector = 12
ImNodesCol_BoxSelectorOutline = 13
ImNodesCol_GridBackground = 14
ImNodesCol_GridLine = 15
ImNodesCol_MiniMapBackground = 16
ImNodesCol_MiniMapBackgroundHovered = 17
ImNodesCol_MiniMapOutline = 18
ImNodesCol_MiniMapOutlineHovered = 19
ImNodesCol_MiniMapNodeBackground = 20
ImNodesCol_MiniMapNodeBackgroundHovered = 21
ImNodesCol_MiniMapNodeBackgroundSelected = 22
ImNodesCol_MiniMapNodeOutline = 23
ImNodesCol_MiniMapLink = 24
ImNodesCol_MiniMapLinkSelected = 25
color_item = ImNodesCol_TitleBar
gh_imgui.imnodes_push_color_style(color_item, r, g, b, a)
syntax
value = gh_imgui.imnodes_push_style_var (
style_item
)
parameters
style_item INTEGER
return values
value REAL
code sample
ImNodesStyleVar_GridSpacing = 0
ImNodesStyleVar_NodeCornerRounding = 1
ImNodesStyleVar_NodePaddingHorizontal = 2
ImNodesStyleVar_NodePaddingVertical = 3
ImNodesStyleVar_NodeBorderThickness = 4
ImNodesStyleVar_LinkThickness = 5
ImNodesStyleVar_LinkLineSegmentsPerLength = 6
ImNodesStyleVar_LinkHoverDistance = 7
ImNodesStyleVar_PinCircleRadius = 8
ImNodesStyleVar_PinQuadSideLength = 9
ImNodesStyleVar_PinTriangleSideLength = 10
ImNodesStyleVar_PinLineThickness = 11
ImNodesStyleVar_PinHoverRadius = 12
ImNodesStyleVar_PinOffset = 13
style_item = ImNodesStyleVar_GridSpacing
value = 24
gh_imgui.imnodes_push_style_var(style_item, value)
imnodes_read_selected_links
syntax
gh_imgui.imnodes_read_selected_links()
parameters
none
return values
none
code sample
gh_imgui.imnodes_read_selected_links()
imnodes_read_selected_nodes
syntax
gh_imgui.imnodes_read_selected_nodes()
parameters
none
return values
none
code sample
gh_imgui.imnodes_read_selected_nodes()
syntax
gh_imgui.imnodes_select_link (
link_id
)
parameters
link_id INTEGER
return values
none
code sample
gh_imgui.imnodes_select_link(link_id)
syntax
gh_imgui.imnodes_select_node (
node_id
)
parameters
node_id INTEGER
return values
none
code sample
gh_imgui.imnodes_select_node(node_id)
imnodes_set_node_draggable
syntax
gh_imgui.imnodes_set_node_draggable (
node_id,
state
)
parameters
node_id INTEGER
state BOOLEAN 1 or 0
return values
none
code sample
gh_imgui.imnodes_set_node_draggable(state)
imnodes_set_node_editor_space_pos
syntax
gh_imgui.imnodes_set_node_editor_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_editor_space_pos(node_id, x, y)
imnodes_set_node_grid_space_pos
syntax
gh_imgui.imnodes_set_node_grid_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_grid_space_pos(node_id, x, y)
imnodes_set_node_screen_space_pos
syntax
gh_imgui.imnodes_set_node_screen_space_pos (
node_id,
x, y
)
parameters
node_id INTEGER
x, y REAL
return values
none
code sample
gh_imgui.imnodes_set_node_screen_space_pos(node_id, x, y)
syntax
gh_imgui.implot_add_data (
plotid,
x, y
)
parameters
plotid INTEGER plot identifier.
x, y REAL plot data.
return values
none
code sample
gh_imgui.implot_add_data(plotid, x, y)
syntax
gh_imgui.implot_begin_plot (
label_DUP1,
x_label,
y_label,
label_DUP2,
x, y,
flags,
x_flags,
y_flags,
y2_flags,
y3_flags
)
parameters
label_DUP1 STRING plot label.
x_label STRING X axis label.
y_label STRING y axis label.
label_DUP2 STRING plot label.
x, y REAL plot size.
flags INTEGER plot flags/options.
x_flags INTEGER X axis flags/options.
y_flags INTEGER Y axis flags/options.
y2_flags INTEGER Y axis additional flags/options.
y3_flags INTEGER Y axis additional flags/options.
return values
none
code sample
gh_imgui.implot_begin_plot(label, x_label, y_label, x_size, y_size, flags, x_flags, y_flags, y2_flags, y3_flags)
gh_imguiimplot_draw_plotline(plotid0, ...)
gh_imguiimplot_draw_plotline(plotid1, ...)
gh_imgui.implot_end_plot()
syntax
plotid = gh_imgui.implot_create_dataplot (
max_points
)
parameters
max_points INTEGER max number of points of the data plot. Can be 0
return values
plotid INTEGER plot identifier.
code sample
plotid = gh_imgui.implot_create_dataplot(max_points)
implot_draw_plotbars
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotbars (
plotid,
label,
count,
offset,
size,
vertical
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
size REAL size.
vertical INTEGER vertical (1) or hozizontal (0) bars.
return values
none
code sample
gh_imgui.implot_draw_plotbars(plotid, label, count, offset, size, vertical)
implot_draw_plotline
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotline (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotline(plotid, label, count, offset)
implot_draw_plotscatter
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotscatter (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotscatter(plotid, label, count, offset)
implot_draw_plotshaded
Draws a plot data set.
syntax
gh_imgui.implot_draw_plotshaded (
plotid,
label,
count,
offset
)
parameters
plotid INTEGER plot identifier.
label STRING plot data label.
count INTEGER number of points to draw.
offset INTEGER plot data offset.
return values
none
code sample
gh_imgui.implot_draw_plotshaded(plotid, label, count, offset)
implot_end_plot
Ends plot rendering.
syntax
gh_imgui.implot_end_plot()
parameters
none
return values
none
code sample
gh_imgui.implot_end_plot()
implot_get_mouse_pos
Gets mouse position
syntax
x, y = gh_imgui.implot_get_mouse_pos()
parameters
none
return values
x, y REAL mouse position.
code sample
x, y = gh_imgui.implot_get_mouse_pos()
syntax
state = gh_imgui.implot_is_hovered()
parameters
none
return values
state INTEGER 1 (hovered) or 0 (not hovered).
code sample
is_hovered = gh_imgui.implot_is_hovered()
implot_kill_dataplot
Destroy a plot data set.
syntax
gh_imgui.implot_kill_dataplot (
plotid
)
parameters
plotid INTEGER plot identifier.
return values
none
code sample
gh_imgui.implot_kill_dataplot(plotid)
syntax
gh_imgui.implot_plottext (
text,
x, y,
vertical,
offset_x, offset_y
)
parameters
text STRING text
x, y REAL text position
vertical INTEGER vertical (1) or horizontal (0) text
offset_x, offset_y REAL offset
return values
none
code sample
gh_imgui.implot_plottext(text, x, y, vertical, offset_x, offset_y)
syntax
gh_imgui.implot_pop_colormap (
count
)
parameters
count INTEGER undo multiple pushes at once by increasing count.
return values
none
code sample
ImPlotColormap_Deep = 0
ImPlotColormap_Dark = 1
ImPlotColormap_Pastel = 2
ImPlotColormap_Paired = 3
ImPlotColormap_Viridis = 4
gh_imgui.implot_push_colormap(ImPlotColormap_Dark)
...
gh_imgui.implot_pop_colormap(1)
implot_pop_style_color
Restores a color
syntax
gh_imgui.implot_pop_style_color (
count
)
parameters
count INTEGER number of colors to restore (default: 1).
return values
none
code sample
gh_imgui.implot_push_style_color(ImPlotCol_Line, r, g, b, a)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_color(1)
syntax
gh_imgui.implot_push_colormap (
colormap_index
)
parameters
colormap_index INTEGER colormap index/identifier.
return values
none
code sample
ImPlotColormap_Deep = 0
ImPlotColormap_Dark = 1
ImPlotColormap_Pastel = 2
ImPlotColormap_Paired = 3
ImPlotColormap_Viridis = 4
ImPlotColormap_Plasma = 5
ImPlotColormap_Hot = 6
ImPlotColormap_Cool = 7
ImPlotColormap_Pink = 8
ImPlotColormap_Jet = 9
ImPlotColormap_Twilight = 10
ImPlotColormap_RdBu = 11
ImPlotColormap_BrBG = 12
ImPlotColormap_PiYG = 13
ImPlotColormap_Spectral = 14
ImPlotColormap_Greys = 15
gh_imgui.implot_push_colormap(ImPlotColormap_Plasma)
...
gh_imgui.implot_pop_colormap(1)
syntax
gh_imgui.implot_push_style_color (
color_index,
r, g, b, a
)
parameters
color_index INTEGER index (identifier) of the color.
r, g, b, a REAL RGBA color.
return values
none
code sample
ImPlotCol_Line = 0
ImPlotCol_Fill = 1
ImPlotCol_MarkerOutline = 2
ImPlotCol_MarkerFill = 3
ImPlotCol_ErrorBar = 4
ImPlotCol_FrameBg = 5
ImPlotCol_PlotBg = 6
ImPlotCol_PlotBorder = 7
ImPlotCol_XAxis = 8
ImPlotCol_YAxis = 9
ImPlotCol_YAxis2 = 10
ImPlotCol_YAxis3 = 11
ImPlotCol_Selection = 12
ImPlotCol_Query = 13
gh_imgui.implot_push_style_color(ImPlotCol_Line, r, g, b, a)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_color(1)
syntax
gh_imgui.implot_push_style_var_1f (
var_id,
x
)
parameters
var_id INTEGER variable identifier.
x REAL value.
return values
none
code sample
ImPlotStyleVar_LineWeight = 0
ImPlotStyleVar_Marker = 1
ImPlotStyleVar_MarkerSize = 2
ImPlotStyleVar_MarkerWeight = 3
ImPlotStyleVar_FillAlpha = 4
ImPlotStyleVar_ErrorBarSize = 5
ImPlotStyleVar_ErrorBarWeight = 6
ImPlotStyleVar_DigitalBitHeight = 7
ImPlotStyleVar_DigitalBitGap = 8
gh_imgui.implot_push_style_var_1i(ImPlotStyleVar_FillAlpha, 0.5)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_var(1)
syntax
gh_imgui.implot_push_style_var_1i (
var_id,
x
)
parameters
var_id INTEGER variable identifier.
x INTEGER value.
return values
none
code sample
ImPlotStyleVar_LineWeight = 0
ImPlotStyleVar_Marker = 1
ImPlotStyleVar_MarkerSize = 2
ImPlotStyleVar_MarkerWeight = 3
ImPlotStyleVar_FillAlpha = 4
ImPlotStyleVar_ErrorBarSize = 5
ImPlotStyleVar_ErrorBarWeight = 6
ImPlotStyleVar_DigitalBitHeight = 7
ImPlotStyleVar_DigitalBitGap = 8
ImPlotMarker_None = 1
ImPlotMarker_Circle = 2
ImPlotMarker_Square = 4
ImPlotMarker_Diamond = 8
ImPlotMarker_Up = 16
ImPlotMarker_Down = 32
ImPlotMarker_Left = 64
ImPlotMarker_Right = 128
ImPlotMarker_Cross = 256
ImPlotMarker_Plus = 512
ImPlotMarker_Asterisk = 1024
gh_imgui.implot_push_style_var_1i(ImPlotStyleVar_Marker, ImPlotMarker_Circle)
gh_imgui.implot_draw_plotline(plotid1, "MouseX", max_size, offset)
gh_imgui.implot_pop_style_var(1)
syntax
gh_imgui.implot_set_next_plot_limits (
x_min,
x_max,
y_min,
y_max,
cond
)
parameters
x_min INTEGER min limit in a X axis.
x_max INTEGER max limit in a X axis.
y_min INTEGER min limit in a Y axis.
y_max INTEGER max limit in a Y axis.
cond INTEGER
return values
none
code sample
ImGuiCond_None = 0
ImGuiCond_Always = 1
ImGuiCond_Once = 2
ImGuiCond_FirstUseEver = 4
ImGuiCond_Appearing = 8
gh_imgui.implot_set_next_plot_limits(x-10, x, -10, 30, ImGuiCond_Always)
syntax
gh_imgui.implot_show_demo_window (
show_window
)
parameters
show_window INTEGER
return values
none
code sample
gh_imgui.implot_show_demo_window(show_window)
indent
Sets indent spacing.
syntax
gh_imgui.indent (
indent_w
)
parameters
indent_w REAL size
return values
none
code sample
indent_w = 10.0
gh_imgui.indent(indent_w)
syntax
error = gh_imgui.init()
parameters
none
return values
error BOOLEAN 1 (success) or 0 (error)
code sample
ret = gh_imgui.init()
input_text
Allows to type a text.
syntax
state, text = gh_imgui.input_text (
label,
max_text_len,
initial_text,
flags
)
parameters
label STRING name of the input field
max_text_len INTEGER max text lenght in bytes (4096 bytes is the default value if max_text_len is set to 0)
initial_text STRING initial text
flags ENUM( imgui_InputTextFlags ) ImGuiInputTextFlags_xxx options
return values
state BOOLEAN state (1 or 0). Useful with ImGuiInputTextFlags_EnterReturnsTrue
text STRING text
code sample
flags = ImGuiInputTextFlags_None
text, state = gh_imgui.input_text("User name", 128, "", flags)
syntax
gh_imgui.invisible_button (
label,
w, h,
flags
)
parameters
label STRING label
w, h REAL size of the button
flags INTEGER options
return values
none
code sample
ImGuiButtonFlags_None = 0
ImGuiButtonFlags_MouseButtonLeft = 1
ImGuiButtonFlags_MouseButtonRight = 2
ImGuiButtonFlags_MouseButtonMiddle = 4
gh_imgui.invisible_button("canvas", 320, 180, ImGuiButtonFlags_None)
syntax
hovered = gh_imgui.is_any_item_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_any_item_hovered()
syntax
hovered = gh_imgui.is_any_window_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_any_window_hovered()
syntax
clicked = gh_imgui.is_item_clicked (
mouse_button
)
parameters
mouse_button ENUM( imgui_Mouse ) left button (0) or right button (1)
return values
clicked BOOLEAN clicked: 1 (true) or 0 (false)
code sample
clicked = gh_imgui.is_item_clicked(0)
syntax
hovered = gh_imgui.is_item_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_item_hovered()
syntax
state = gh_imgui.is_mouse_clicked (
button
)
parameters
button ENUM( mouse_button ) mouse button: 0 (left), 1 (right) or 2 (middle)
return values
state BOOLEAN clicked: 1 (true) or 0 (false)
code sample
state = gh_imgui.is_mouse_clicked(button)
syntax
hovered = gh_imgui.is_window_hovered()
parameters
none
return values
hovered BOOLEAN hovered: 1 (true) or 0 (false)
code sample
hovered = gh_imgui.is_window_hovered()
syntax
out_value, ret = gh_imgui.knob (
label,
in_value,
v_min, v_max,
speed,
format,
knob_type,
size,
flags,
steps
)
parameters
label STRING label
in_value REAL initial value
v_min, v_max REAL min and max values
speed REAL animation speed
format STRING how the value is displayed.
knob_type INTEGER type of the knob: tick, dot, wiper, ...
size REAL size in pixels of the knob
flags INTEGER flags
steps INTEGER number of steps from start to end
return values
out_value REAL value of the knob between v_min and _vmax
ret INTEGER return code: 1 if OK, 0 if error
code sample
ImGuiKnobVariant_Tick = 1
ImGuiKnobVariant_Dot = 2
ImGuiKnobVariant_Wiper = 4
ImGuiKnobVariant_WiperOnly = 8
ImGuiKnobVariant_WiperDot = 16
ImGuiKnobVariant_Stepped = 32
ImGuiKnobVariant_Space = 64
ImGuiKnobFlags_NoTitle = 1
ImGuiKnobFlags_NoInput = 2
ImGuiKnobFlags_ValueTooltip = 4
ImGuiKnobFlags_DragHorizontal = 8
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_ReadOnlyInput = 16
-- this is special flag fopr GeeXLab only.
ImGuiKnobFlags_DisableMouse = 32
value, ret = gh_imgui.knob(label, init_value, v_min, v_max, speed, format, type, size, flags, steps)
syntax
ret = gh_imgui.list_box_begin (
cb_index,
w, h
)
parameters
cb_index INTEGER combo box index
w, h REAL size of the list box
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_imgui.list_box_begin(cb_index, 0)
syntax
selected_item = gh_imgui.list_box_draw (
cb_id,
initial_selected_item
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.list_box_draw(cb_id, 0)
syntax
selected_item = gh_imgui.list_box_draw_v2 (
cb_id,
initial_selected_item,
height_in_items
)
parameters
cb_id ID combo box identifier
initial_selected_item INTEGER index of the initial selected item
height_in_items INTEGER height of the list box in items
return values
selected_item INTEGER index of the current selected item
code sample
selected_item = gh_imgui.list_box_draw_v2(cb_id, 0, 20)
list_box_end
Ends a list box header.
syntax
gh_imgui.list_box_end()
parameters
none
return values
none
code sample
gh_imgui.list_box_end()
syntax
start_item, end_item = gh_imgui.list_clipping_begin (
num_items
)
parameters
num_items INTEGER number of items
return values
start_item, end_item INTEGER range coreved by the list clipper
code sample
start_item, end_item = gh_imgui.list_clipping_begin(num_items)
list_clipping_end
Ends the list clipping.
syntax
gh_imgui.list_clipping_end (
num_items,
start_item, end_item
)
parameters
num_items INTEGER number of items
start_item, end_item INTEGER range coreved by the list clipper
return values
none
code sample
gh_imgui.list_clipping_end(num_items, start_item, end_item)
syntax
meid = gh_imgui.memory_editor_create (
size
)
parameters
size INTEGER size of the window
return values
meid ID memory editor identifier
code sample
meid = gh_imgui.memory_editor_create(1024)
syntax
gh_imgui.memory_editor_draw_window_DUP1 (
meid,
title
)
parameters
meid ID memory editor identifier
title STRING title of the window
return values
none
code sample
gh_imgui.memory_editor_draw_window(meid, title)
syntax
gh_imgui.memory_editor_draw_window_DUP2 (
meid
)
parameters
meid ID memory editor identifier
return values
none
code sample
gh_imgui.memory_editor_draw_contents(meid)
syntax
gh_imgui.memory_editor_kill (
meid
)
parameters
meid ID memory editor identifier
return values
none
code sample
gh_imgui.memory_editor_kill(meid)
syntax
gh_imgui.memory_editor_read_data_from_buffer (
meid,
buffer,
buffer_size
)
parameters
meid ID memory editor identifier
buffer POINTER memory buffer. See memory buffer function of gh_utils.
buffer_size INTEGER size in bytes of memory buffer.
return values
none
code sample
gh_imgui.memory_editor_read_data_from_buffer(meid, buffer, buffer_size)
syntax
gh_imgui.memory_editor_read_data_from_file (
meid,
filename
)
parameters
meid ID memory editor identifier
filename STRING absolute path to the file
return values
none
code sample
gh_imgui.memory_editor_read_data_from_file(meid, filename)
syntax
gh_imgui.memory_editor_resize (
meid,
size
)
parameters
meid ID memory editor identifier
size INTEGER size of the window
return values
none
code sample
gh_imgui.memory_editor_resize(meid, 512)
syntax
gh_imgui.memory_editor_set_data_from_texture (
meid,
tid
)
parameters
meid ID memory editor identifier
tid ID texture identifier
return values
none
code sample
gh_imgui.memory_editor_set_data_from_texture(meid, tid)
memory_editor_set_value_1u8
Writes a byte.
syntax
gh_imgui.memory_editor_set_value_1u8 (
meid,
index,
x
)
parameters
meid ID memory editor identifier
index INTEGER index of the value
x INTEGER value
return values
none
code sample
gh_imgui.memory_editor_set_value_1u8(meid, 0, 128)
syntax
gh_imgui.memory_editor_write_data_to_buffer (
meid,
buffer,
buffer_size
)
parameters
meid ID memory editor identifier
buffer POINTER memory buffer. See memory buffer function of gh_utils.
buffer_size INTEGER size in bytes of memory buffer.
return values
none
code sample
gh_imgui.memory_editor_write_data_to_buffer(meid, buffer, buffer_size)
syntax
gh_imgui.memory_editor_write_data_to_file (
meid,
filename
)
parameters
meid ID memory editor identifier
filename STRING absolute path to the file
return values
none
code sample
gh_imgui.memory_editor_write_data_to_file(meid, filename)
syntax
state = gh_imgui.menu_begin_main_bar()
parameters
none
return values
state BOOLEAN 1 or 0 - only call menu_end_main_bar() if this returns 1
code sample
gh_imgui.menu_begin_main_bar()
menu_end_main_bar
Ends the main menu bar.
syntax
gh_imgui.menu_end_main_bar()
parameters
none
return values
none
code sample
gh_imgui.menu_end_main_bar()
syntax
item_index = gh_imgui.plot_add_item (
plot_id,
label,
type
)
parameters
plot_id ID plotline identifier
label STRING label
type INTEGER line: 0, scatter: 1, xbar: 2 or ybar: 3
return values
item_index INTEGER index of the new item
code sample
type_line = 0
type_scatter = 1
type_xbar = 2
type_ybar = 3
item_index = gh_imgui.plot_add_item(plot_id, "myNewItem", type_line)
syntax
gh_imgui.plot_axis_scroll (
plot_id,
axis,
current_time,
history
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0, Y axis: 1
current_time REAL current time
history REAL history seconds
return values
none
code sample
gh_imgui.plot_axis_scroll(plot_id, axis, current_time, history)
plot_draw
Draws a plotline.
syntax
gh_imgui.plot_draw (
plot_id,
label,
num_items,
size_x, size_y
)
parameters
plot_id ID plotline identifier
label STRING name of the plotline
num_items INTEGER number of lines to draw
size_x, size_y REAL plotline frame size
return values
none
code sample
gh_imgui.plot_draw(plot_id, label, num_items, size_x, size_y)
syntax
x, y = gh_imgui.plot_get_mouse_position()
parameters
none
return values
x, y REAL mouse position
code sample
x, y = gh_imgui.plot_get_mouse_position()
syntax
state = gh_imgui.plot_is_hovered()
parameters
none
return values
state INTEGER 1: hovered, 0: not hovered
code sample
state = gh_imgui.plot_is_hovered()
plot_item_add_data
Adds data to an item.
syntax
gh_imgui.plot_item_add_data (
plot_id,
item_index,
x, y
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
return values
none
code sample
gh_imgui.plot_item_add_data(plot_id, item_index, x, y)
syntax
gh_imgui.plot_item_buffer_point (
plot_id,
item_index,
x, y,
max_points
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
max_points INTEGER max number of points
return values
none
code sample
gh_imgui.plot_item_buffer_point(plot_id, item_index, x, y, max_points)
syntax
gh_imgui.plot_item_clear_data_DUP1 (
plot_id,
item_index
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
return values
none
code sample
gh_imgui.plot_item_clear_data(plot_id, item_index)
plot_item_clear_data_DUP2
Resize data of an item.
syntax
gh_imgui.plot_item_clear_data_DUP2 (
plot_id,
item_index,
n
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
n INTEGER data size
return values
none
code sample
gh_imgui.plot_item_resize_data(plot_id, item_index, n)
syntax
n = gh_imgui.plot_item_get_data_size (
plot_id,
item_index
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
return values
n INTEGER data size
code sample
n = gh_imgui.plot_item_get_data_size(plot_id, item_index)
syntax
gh_imgui.plot_item_roll_point (
plot_id,
item_index,
x, y,
span
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x, y REAL data - these are the line values in Y and Y
span REAL duration in seconds
return values
none
code sample
gh_imgui.plot_item_roll_point(plot_id, item_index, x, y, span)
syntax
gh_imgui.plot_item_set_color (
plot_id,
item_index,
r, g, b, a
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.plot_item_set_color(plot_id, item_index, r, g, b, a)
plot_item_set_data
Sets data of an item.
syntax
gh_imgui.plot_item_set_data (
plot_id,
item_index,
data_index,
x, y
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
data_index INTEGER index of the data
x, y REAL data - these are the line values in Y and Y
return values
none
code sample
gh_imgui.plot_item_set_data(plot_id, item_index, , data_index, x, y)
plot_item_set_data_begin
Sets the start offset.
syntax
gh_imgui.plot_item_set_data_begin (
plot_id,
item_index,
x
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
x INTEGER offset
return values
none
code sample
gh_imgui.plot_item_set_data_begin(plot_id, item_index, 0)
plot_item_set_label
Sets a label of an item.
syntax
gh_imgui.plot_item_set_label (
plot_id,
item_index,
label
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
label STRING label
return values
none
code sample
gh_imgui.plot_add_item(plot_id, item_index, "myItem")
syntax
gh_imgui.plot_item_set_size (
plot_id,
item_index,
size
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
size REAL size (or tickness)
return values
none
code sample
gh_imgui.plot_item_set_size(plot_id, item_index, 2.0)
syntax
gh_imgui.plot_item_set_type (
plot_id,
item_index,
type
)
parameters
plot_id ID plotline identifier
item_index INTEGER index of the item
type INTEGER line: 0, scatter: 1, xbar: 2 or ybar: 3
return values
none
code sample
gh_imgui.plot_item_set_type(plot_id, item_index, type)
plot_kill
Destroys a plotline.
syntax
gh_imgui.plot_kill (
plot_id
)
parameters
plot_id ID plotline identifier
return values
none
code sample
gh_imgui.plot_kill(plot_id)
syntax
gh_imgui.plot_set_axis_color (
plot_id,
axis,
r, g, b, a
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
r, g, b, a REAL RGBA color
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_color(plot_id, axis_y, r, g, b, a)
syntax
gh_imgui.plot_set_axis_label (
plot_id,
axis,
label
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
label STRING label
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_label(plot_id, axis_y, "Y axis")
syntax
gh_imgui.plot_set_axis_param_bool (
plot_id,
axis,
what,
state
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'show_grid', 'show_tick_marks', 'show_tick_labels', 'adaptive', 'lock_max', 'lock_min', 'flip'
state BOOLEAN 0 (disabled) or 1 (enabled)
return values
none
code sample
axis_x = 0
axis_y = 1
state = 1
gh_imgui.plot_set_axis_param_bool(plot_id, axis_x, "show_grid", state)
gh_imgui.plot_set_axis_param_bool(plot_id, axis_y, "show_grid", state)
syntax
gh_imgui.plot_set_axis_param_float (
plot_id,
axis,
what,
x
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'minimum', 'maximum', 'zoom_rate'
x REAL value
return values
none
code sample
axis_y = 1
gh_imgui.plot_set_axis_param_float(plot_id, axis_y, "minimum", -10.0)
gh_imgui.plot_set_axis_param_bool(plot_id, axis_y, "minimum", 10.0)
syntax
gh_imgui.plot_set_axis_param_int (
plot_id,
axis,
what,
x
)
parameters
plot_id ID plotline identifier
axis INTEGER X axis: 0 or Y axis: 1
what STRING element name: 'divisions', 'subdivisions'
x INTEGER value
return values
none
code sample
axis_x = 0
gh_imgui.plot_set_axis_param_int(plot_id, axis_x, "divisions", 10)
gh_imgui.plot_set_axis_param_int(plot_id, axis_x, "subdivisions", 4)
syntax
gh_imgui.plot_set_color (
plot_id,
what,
r, g, b, a
)
parameters
plot_id ID plotline identifier
what STRING element name: 'frame', 'background', 'border'
r, g, b, a REAL RGBA color
return values
none
code sample
gh_imgui.plot_set_color(plot_id, "background", 0.4, 0.4, 0.4, 0.85)
syntax
gh_imgui.plot_set_state (
plot_id,
what,
state
)
parameters
plot_id ID plotline identifier
what STRING element name: 'show_crosshairs', 'show_mouse_pos', 'show_legend'
state BOOLEAN 0 (disabled) or 1 (enabled)
return values
none
code sample
gh_imgui.plot_set_state(plot_id, "show_crosshairs", state)
syntax
gh_imgui.plot_set_title (
plot_id,
title
)
parameters
plot_id ID plotline identifier
title STRING title of the plotline
return values
none
code sample
gh_imgui.plot_set_title(plot_id, title)
plotline_create
Creates a plotline.
syntax
index = gh_imgui.plotline_create (
label,
num_points
)
parameters
label STRING label
num_points INTEGER number of points in the plotline
return values
index INTEGER index of the new plotline
code sample
plotline_index = gh_imgui.plotline_create("Curve", 1000)
plotline_draw
Draws a plotline.
syntax
gh_imgui.plotline_draw (
index,
type,
overlay,
values_offset,
scale_min, scale_max,
graph_size_x, graph_size_y
)
parameters
index INTEGER index of the plotline
type ENUM( draw_type ) type: 1 (histogram) or 0 (line)
overlay STRING overlay text
values_offset INTEGER offset
scale_min, scale_max REAL minimal / maximal value
graph_size_x, graph_size_y REAL size of the graph
return values
none
code sample
values_offset = 0
scale_min = 0
scale_max = 100
graph_size_x = 400
graph_size_y = 200
gh_imgui.plotline_draw(plotline_index, type, "overlay!", values_offset, scale_min, scale_max, graph_size_x, graph_size_y)
plotline_draw_v2
Draws a plotline.
syntax
gh_imgui.plotline_draw_v2 (
index,
type,
overlay,
num_values,
values_offset,
scale_min, scale_max,
graph_size_x, graph_size_y
)
parameters
index INTEGER index of the plotline
type ENUM( draw_type ) type: 1 (histogram) or 0 (line)
overlay STRING overlay text
num_values INTEGER number of values to draw
values_offset INTEGER offset
scale_min, scale_max REAL minimal / maximal value
graph_size_x, graph_size_y REAL size of the graph
return values
none
code sample
values_offset = 0
values_count = 1000
scale_min = 0
scale_max = 100
graph_size_x = 400
graph_size_y = 200
gh_imgui.plotline_draw_v2(plotline_index, type, "overlay!", values_count, values_offset, scale_min, scale_max, graph_size_x, graph_size_y)
syntax
x = gh_imgui.plotline_get_value1f (
index,
value_index
)
parameters
index INTEGER index of the plotline
value_index INTEGER index of value in the plotline
return values
x REAL value
code sample
x = gh_imgui.plotline_get_value1f(plotline_index, value_index)
syntax
gh_imgui.plotline_set_value1f (
index,
value_index,
x
)
parameters
index INTEGER index of the plotline
value_index INTEGER index of value in the plotline
x REAL value
return values
none
code sample
gh_imgui.plotline_set_value1f(plotline_index, value_index, x)
syntax
gh_imgui.pop_clip_rect()
parameters
none
return values
none
code sample
gh_imgui.pop_clip_rect()
syntax
gh_imgui.pop_font()
parameters
none
return values
none
code sample
gh_imgui.pop_font()
syntax
gh_imgui.pop_item_width()
parameters
none
return values
none
code sample
local width = gh_imgui.get_content_region_available_width()
gh_imgui.push_item_width(width * 0.8)
...
gh_imgui.pop_item_width()
syntax
gh_imgui.pop_style_color()
parameters
none
return values
none
code sample
gh_imgui.pop_style_color()
progress_bar
Displays a progress bar.
syntax
gh_imgui.progress_bar (
fraction,
width, height,
overlay
)
parameters
fraction REAL progression of the bar: from 0.0 to 1.0
width, height INTEGER size of the bar
overlay STRING overlay text
return values
none
code sample
gh_imgui.progress_bar(0.45, width, height, overlay_str)
syntax
gh_imgui.push_clip_rect (
x_min, y_min,
x_max, y_max
)
parameters
x_min, y_min REAL 2D coordinates or the upper-left bounding rectangle
x_max, y_max REAL 2D coordinates or the lower-right bounding rectangle
return values
none
code sample
x0, y0 = gh_imgui.get_item_rect_min()
x1, y1 = gh_imgui.get_item_rect_max()
gh_imgui.push_clip_rect(x0, y0, x1, y1)
syntax
gh_imgui.push_font (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_imgui.push_font(font_id)
syntax
gh_imgui.push_item_width (
width
)
parameters
width REAL width in pixels of next items
return values
none
code sample
local width = gh_imgui.get_content_region_available_width()
gh_imgui.push_item_width(width * 0.8)
...
gh_imgui.pop_item_width()
syntax
gh_imgui.push_style_color (
item_type,
r, g, b, a
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see complete list in set_color() function)
r, g, b, a REAL new color
return values
none
code sample
element_type = IMGUI_WINDOW_BG_COLOR
gh_imgui.push_style_color(element_type, r, g, b, a)
radio_button
Display a radio button.
syntax
gh_imgui.radio_button (
name,
active
)
parameters
name STRING name
active BOOLEAN active state: 1 (true) or 0 (false)
return values
none
code sample
gh_imgui.radio_button("radio button 1", 0)
gh_imgui.radio_button("radio button 2", 1)
gh_imgui.radio_button("radio button 3", 0)
syntax
gh_imgui.rebuild_all_fonts()
parameters
none
return values
none
code sample
gh_imgui.rebuild_all_fonts()
syntax
gh_imgui.reset_default_font()
parameters
none
return values
none
code sample
gh_imgui.reset_default_font()
syntax
gh_imgui.same_line (
local_pos_x,
spacing_w
)
parameters
local_pos_x REAL default value: 0.0
spacing_w REAL default value: -1.0
return values
none
code sample
gh_imgui.same_line(local_pos_x, spacing_w)
syntax
gh_imgui.select_draw_list (
draw_list
)
parameters
draw_list ENUM( imgui_DrawList ) draw list type
return values
none
code sample
IMGUI_DRAWLIST_WINDOW = 0
IMGUI_DRAWLIST_BACKGROUND = 1
IMGUI_DRAWLIST_FOREGROUND = 2
draw_list = IMGUI_DRAWLIST_WINDOW
gh_imgui.select_draw_list(draw_list)
syntax
ret = gh_imgui.selectable (
text,
selected,
flags
)
parameters
text STRING label
selected BOOLEAN selected state: 1 (yes) or 0 (no)
flags ENUM( imgui_SelectableFlags ) ImGuiSelectableFlags_xxx options
return values
ret INTEGER state
code sample
-- Possible flags
ImGuiSelectableFlags_None = 0
ImGuiSelectableFlags_DontClosePopups = 1 -- // Clicking this don't close parent popup window
ImGuiSelectableFlags_SpanAllColumns = 2 -- Selectable frame can span all columns (text will still fit in current column)
ImGuiSelectableFlags_AllowDoubleClick = 4 -- Generate press events on double clicks too
ImGuiSelectableFlags_Disabled = 8 -- Cannot be selected, display greyed out text
selected = 0
flags = ImGuiSelectableFlags_SpanAllColumns
ret = gh_imgui.selectable(text, selected, flags)
syntax
gh_imgui.separator()
parameters
none
return values
none
code sample
gh_imgui.separator()
syntax
gh_imgui.set_color (
item_type,
r, g, b, a
)
parameters
item_type ENUM( imgui_ColoredItems ) type of the widget (see values in the code sample)
r, g, b, a REAL RGBA color of the widget
return values
none
code sample
IMGUI_WINDOW_BG_COLOR = 1
IMGUI_TITLE_BG_COLOR = 2
IMGUI_PLOTLINES_COLOR = 3
IMGUI_FRAME_BG_COLOR = 4
IMGUI_TITLE_BG_ACTIVE_COLOR = 5
IMGUI_TITLE_BG_COLLAPSED_COLOR = 6
IMGUI_PLOTHISTOGRAM_COLOR = 7
IMGUI_COMBO_BG_COLOR = 8
IMGUI_BUTTON_COLOR = 9
IMGUI_SEPARATOR_COLOR = 10
IMGUI_RESIZE_GRIP_COLOR = 11
IMGUI_PLOTLINE_HOVERED_COLOR = 12
IMGUI_PLOTHISTOGRAM_HOVERED_COLOR = 13
IMGUI_BUTTON_HOVERED_COLOR = 14
IMGUI_SEPARATOR_HOVERED_COLOR = 15
IMGUI_RESIZE_GRIP_HOVERED_COLOR = 16
IMGUI_HEADER_COLOR = 17
IMGUI_HEADER_HOVERED_COLOR = 18
IMGUI_SLIDER_GRAB_COLOR = 19
IMGUI_CHECK_MARK_COLOR = 20
IMGUI_SCROLLBAR_BG_COLOR = 21
IMGUI_SCROLLBAR_GRAB_COLOR = 22
IMGUI_SCROLLBAR_GRAB_HOVERED_COLOR = 23
IMGUI_TEXT_COLOR = 24
IMGUI_POPUP_BG_COLOR = 25
IMGUI_TEXT_DISABLED_COLOR = 26
IMGUI_CHILD_BG_COLOR = 27
IMGUI_BORDER_COLOR = 28
IMGUI_BORDER_SHADOW_COLOR = 29
IMGUI_FRAME_BG_HOVERED_COLOR = 30
IMGUI_FRAME_BG_ACTIVE_COLOR = 31
IMGUI_MENU_BAR_BG_COLOR = 32
IMGUI_SCROLLBAR_GRAB_ACTIVE_COLOR = 33
IMGUI_SLIDER_GRAB_ACTIVE_COLOR = 34
IMGUI_BUTTON_ACTIVE_COLOR = 35
IMGUI_HEADER_ACTIVE_COLOR = 36
IMGUI_SEPARATOR_ACTIVE_COLOR = 37
IMGUI_RESIZE_GRIP_ACTIVE_COLOR = 38
IMGUI_CLOSE_BUTTON_COLOR = 39
IMGUI_CLOSE_BUTTON_HOVERED_COLOR = 40
IMGUI_CLOSE_BUTTON_ACTIVE_COLOR = 41
IMGUI_PLOTLINES_HOVERED_COLOR = 42
IMGUI_TEXT_SELECTED_BG_COLOR = 43
IMGUI_MODAL_WINDOW_DARKENING_COLOR = 44
IMGUI_DRAG_DROP_TARGET_COLOR = 45
IMGUI_NAV_HIGHLIGHT_COLOR = 46
IMGUI_NAV_WINDOW_IN_HIGHLIGHT_COLOR = 47
IMGUI_MODAL_WINDOW_DIM_BG_COLOR = 48
IMGUI_TAB_COLOR = 49
IMGUI_TAB_HOVERED_COLOR = 50
IMGUI_TAB_ACTIVE_COLOR = 51
IMGUI_TAB_UNFOCUSED_COLOR = 52
IMGUI_TAB_UNFOCUSED_ACTIVE_COLOR = 53
widget_type = IMGUI_BUTTON_COLOR
gh_imgui.set_color(widget_type, r, g, b, a)
syntax
gh_imgui.set_cur_font_display_offset (
x, y
)
parameters
x, y REAL offsets
return values
none
code sample
gh_imgui.set_cur_font_display_offset(x, y)
set_default_font
Sets the default font.
syntax
gh_imgui.set_default_font (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_imgui.set_default_font(font_id)
syntax
gh_imgui.set_font_glyph_offset (
font_id,
x, y
)
parameters
font_id ID font identifier
x, y INTEGER font offset
return values
none
code sample
gh_imgui.set_font_glyph_offset(font_id, 0, -2)
gh_imgui.rebuild_all_fonts()
syntax
gh_imgui.set_frame_border_size (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_frame_border_size(x)
set_indent_spacing
Sets the indent size.
syntax
gh_imgui.set_indent_spacing (
spacing
)
parameters
spacing REAL indent spacing
return values
none
code sample
gh_imgui.set_indent_spacing(spacing)
syntax
gh_imgui.set_item_default_focus()
parameters
none
return values
none
code sample
gh_imgui.set_item_default_focus()
syntax
gh_imgui.set_item_spacing (
x, y
)
parameters
x, y REAL spacing
return values
none
code sample
gh_imgui.set_item_spacing(x, y)
syntax
gh_imgui.set_keyboard_focus_here (
offset
)
parameters
offset INTEGER offset
return values
none
code sample
gh_imgui.set_keyboard_focus_here(offset)
syntax
gh_imgui.set_next_item_width (
width
)
parameters
width REAL item width
return values
none
code sample
gh_imgui.set_next_item_width(width)
syntax
gh_imgui.set_next_window_content_size (
width, height
)
parameters
width, height REAL size
return values
none
code sample
gh_imgui.set_next_window_content_size(width, height)
syntax
gh_imgui.set_next_window_size (
width, height
)
parameters
width, height INTEGER size of the window
return values
none
code sample
gh_imgui.set_next_window_size(width, height)
syntax
gh_imgui.set_next_window_size_constraints (
min_x, min_y,
max_x, max_y
)
parameters
min_x, min_y INTEGER bottom left corner
max_x, max_y INTEGER top right corner
return values
none
code sample
gh_imgui.set_next_window_size_constraints(min_x, min_y, max_x, max_y)
syntax
gh_imgui.set_rounding (
what,
x
)
parameters
what STRING name of the element: window, child, popup, frame, scrollbar, grab, tab
x REAL size
return values
none
code sample
gh_imgui.set_rounding("frame", x)
syntax
gh_imgui.set_scroll (
scroll_x, scroll_y
)
parameters
scroll_x, scroll_y REAL scrolling values in X and Y
return values
none
code sample
gh_imgui.set_scroll(scroll_x, scroll_y)
syntax
gh_imgui.set_scroll_from_pos_y (
local_y,
center_y_ratio
)
parameters
local_y REAL local y
center_y_ratio REAL y ratio
return values
none
code sample
gh_imgui.set_scroll_from_pos_y(local_y, center_y_ratio)
set_scroll_here_y
Adjusts scrolling amount to make current cursor position visible.
center_y_ratio=0.0: top, 0.5: center, 1.0: bottom.
When using to make a default/current item visible, consider using set_item_default_focus() instead.
syntax
gh_imgui.set_scroll_here_y (
center_y_ratio
)
parameters
center_y_ratio REAL y ratio
return values
none
code sample
gh_imgui.set_scroll_here_y(center_y_ratio)
syntax
gh_imgui.set_style_colors (
style
)
parameters
style ENUM( imgui_Style ) name of the style
return values
none
code sample
-- Available sytles:
"classic"
"dark"
"light"
"krosoft"
"maya"
"rayteak"
"fromhue"
"cherry"
"dark2"
"corporate_grey"
style_name = "classic"
gh_imgui.set_style_colors(style_name)
set_tooltip
Sets a tooltip.
syntax
gh_imgui.set_tooltip (
caption
)
parameters
caption STRING tooltip text
return values
none
code sample
gh_imgui.set_tooltip("This is a tooltip!")
syntax
gh_imgui.set_window_border_size (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_window_border_size(x)
syntax
gh_imgui.set_window_focus (
name
)
parameters
name STRING name of the window
return values
none
code sample
gh_imgui.set_window_focus(name)
syntax
gh_imgui.set_window_rounding (
x
)
parameters
x REAL size
return values
none
code sample
gh_imgui.set_window_rounding(x)
syntax
gh_imgui.set_window_size (
name,
width, height
)
parameters
name STRING window name
width, height INTEGER size of the window
return values
none
code sample
gh_imgui.set_window_size("Control Panel", width, height)
syntax
gh_imgui.show_demo_window()
parameters
none
return values
none
code sample
gh_imgui.show_demo_window()
syntax
gh_imgui.show_metrics_window()
parameters
none
return values
none
code sample
gh_imgui.show_metrics_window()
syntax
gh_imgui.show_stack_tool_window()
parameters
none
return values
none
code sample
gh_imgui.show_stack_tool_window()
show_test_window
Shows ImGui test window.
syntax
gh_imgui.show_test_window()
parameters
none
return values
none
code sample
gh_imgui.frame_begin(winW, winH, mouse_x, mouse_y, mouse_left_button, mouse_right_button)
gh_imgui.show_test_window()
gh_imgui.frame_end()
slider_1f
Displays a 1D slider.
syntax
value = gh_imgui.slider_1f (
label,
initial_value,
v_min, v_max,
power
)
parameters
label STRING name of the slider
initial_value REAL initial value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
value REAL current value
code sample
v = gh_imgui.slider_1f("slider01", initial_value, v_min, v_max, 1.0)
syntax
value = gh_imgui.slider_1i (
label,
initial_value,
v_min, v_max
)
parameters
label STRING name of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
return values
value INTEGER current value
code sample
v = gh_imgui.slider_1i("slider01", initial_value, v_min, v_max)
syntax
value = gh_imgui.slider_1i_v2 (
label,
initial_value,
v_min, v_max,
flags
)
parameters
label STRING name of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
flags INTEGER ImGuiSliderFlags_xxxx flags
return values
value INTEGER current value
code sample
ImGuiSliderFlags_None = 0
ImGuiSliderFlags_ClampOnInput = 16
ImGuiSliderFlags_Logarithmic = 32
ImGuiSliderFlags_NoRoundToFormat = 64
ImGuiSliderFlags_NoInput = 12
v = gh_imgui.slider_1i_v2("slider01", initial_value, v_min, v_max, ImGuiSliderFlags_None)
slider_2f
Displays a 2D slider.
syntax
x, y = gh_imgui.slider_2f (
label,
x0, y0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0 REAL initial 2D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y REAL current 2D value
code sample
x, y = gh_imgui.slider_2f("slider04", x0, y0, v_min, v_max, 1.0)
slider_3f
Displays a 3D slider.
syntax
x, y, z = gh_imgui.slider_3f (
label,
x0, y0, z0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0, z0 REAL initial 3D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y, z REAL current 3D value
code sample
x, y, z = gh_imgui.slider_3f("slider03", x0, y0, z0, v_min, v_max, 1.0)
slider_4f
Displays a 4D slider.
syntax
x, y, z, w = gh_imgui.slider_4f (
label,
x0, y0, z0, w0,
v_min, v_max,
power
)
parameters
label STRING name of the slider
x0, y0, z0, w0 REAL initial 4D value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
x, y, z, w REAL current 4D value
code sample
x, y, z, w = gh_imgui.slider_4f("slider02", x0, y0, z0, w0, v_min, v_max, 1.0)
spacing
Adds a vertical space.
syntax
gh_imgui.spacing()
parameters
none
return values
none
code sample
gh_imgui.spacing()
tab_bar_begin
Begins a tab bar.
syntax
is_opened = gh_imgui.tab_bar_begin (
label
)
parameters
label STRING label
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
ret = gh_imgui.tab_bar_begin("tabbar01")
tab_bar_begin_v2
Begins a tab bar.
syntax
is_opened = gh_imgui.tab_bar_begin_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TabBarFlags ) ImGuiTabBarFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
ImGuiTabBarFlags_None = 0,
ImGuiTabBarFlags_Reorderable = 1
ImGuiTabBarFlags_AutoSelectNewTabs = 2
ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 4
ImGuiTabBarFlags_NoTabListPopupButton = 8
ImGuiTabBarFlags_NoTabListScrollingButtons = 16
ImGuiTabBarFlags_NoTooltip = 32
ImGuiTabBarFlags_FittingPolicyResizeDown = 64
ImGuiTabBarFlags_FittingPolicyScroll = 128
ret = gh_imgui.tab_bar_begin_v2("tabbar01", ImGuiTabBarFlags_Reorderable)
tab_bar_end
Ends a tab bar.
syntax
gh_imgui.tab_bar_end()
parameters
none
return values
none
code sample
ImGuiTabBarFlags_Reorderable = 1
if (gh_imgui.tab_bar_begin_v2("tabbar01", ImGuiTabBarFlags_Reorderable) == 1) then
...
gh_imgui.tab_bar_end()
end
tab_item_begin
Begins a tab bar item.
syntax
is_opened = gh_imgui.tab_item_begin (
label,
show_tab,
flags
)
parameters
label STRING label
show_tab BOOLEAN 1 (show) or 0 (hide)
flags ENUM( imgui_TabItemFlags ) ImGuiTabItemFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
flags = ImGuiTabItemFlags_None -- 0
show_tab = 1
if (gh_imgui.tab_bar_begin("tabbar01", show_tab, flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 0, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
tab_item_begin_v2
Begins a tab bar item.
syntax
is_opened = gh_imgui.tab_item_begin_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TabItemFlags ) ImGuiTabItemFlags_xxx options
return values
is_opened BOOLEAN 1 (true) or 0 (false)
code sample
if (gh_imgui.tab_bar_begin_v2("tabbar01", flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 1, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
tab_item_end
Ends a tab bar item.
syntax
gh_imgui.tab_item_end()
parameters
none
return values
none
code sample
flags = 0
if (gh_imgui.tab_bar_begin_v2("tabbar01", flags) == 1) then
flags = 0
if (gh_imgui.tab_item_begin("TAB1", 1, flags) == 1) then
gh_imgui.text("This is the TAB1")
gh_imgui.tab_item_end()
end
if (gh_imgui.tab_item_begin("TAB2", 1, flags) == 1) then
gh_imgui.text("This is the TAB2")
gh_imgui.tab_item_end()
end
gh_imgui.tab_bar_end()
end
table_begin
Begins a table.
syntax
ret = gh_imgui.table_begin (
label,
num_columns,
flags,
outer_size_x, outer_size_y,
inner_width
)
parameters
label STRING label
num_columns INTEGER number of columns
flags INTEGER options. See all ImGuiTableFlags_xxxx constants in imgui.lua
outer_size_x, outer_size_y REAL outer size
inner_width REAL inner width
return values
ret INTEGER 1 if success or 0 if error
code sample
flags = ImGuiTableFlags_Resizable + ImGuiTableFlags_Borders
num_columns = 2
if (gh_imgui.table_begin("Table1", num_columns, flags, 0,0, 0) == 1) then
...
...
gh_imgui.table_end()
end
syntax
gh_imgui.table_end()
parameters
none
return values
none
code sample
flags = ImGuiTableFlags_Resizable + ImGuiTableFlags_Borders
num_columns = 2
if (gh_imgui.table_begin("Table1", num_columns, flags, 0,0, 0) == 1) then
...
...
gh_imgui.table_end()
end
syntax
count = gh_imgui.table_get_column_count()
parameters
none
return values
count INTEGER
code sample
count = gh_imgui.table_get_column_count()
syntax
flags = gh_imgui.table_get_column_flags (
column_n
)
parameters
column_n INTEGER column index
return values
flags INTEGER See the ImGuiTableColumnFlags_xxxxx constants in imgui.lua
code sample
flags = gh_imgui.table_get_column_flags(column_n)
syntax
index = gh_imgui.table_get_column_index()
parameters
none
return values
index INTEGER
code sample
index = gh_imgui.table_get_column_index()
syntax
name = gh_imgui.table_get_column_name (
column_n
)
parameters
column_n INTEGER column index
return values
name STRING
code sample
name = gh_imgui.table_get_column_name(column_n)
syntax
index = gh_imgui.table_get_row_index()
parameters
none
return values
index INTEGER
code sample
index = gh_imgui.table_get_row_index()
syntax
ret = gh_imgui.table_next_column()
parameters
none
return values
ret INTEGER 1 if visible or 0 if not
code sample
ret = gh_imgui.table_next_column()
syntax
gh_imgui.table_next_row_DUP1 (
row_flags,
min_row_height
)
parameters
row_flags INTEGER See ImGuiTableRowFlags_xxxx in imgui.lua
min_row_height INTEGER
return values
none
code sample
gh_imgui.table_next_row(row_flags, min_row_height)
syntax
gh_imgui.table_next_row_DUP2 (
row_flags,
min_row_height
)
parameters
row_flags INTEGER See ImGuiTableRowFlags_xxxx in imgui.lua
min_row_height INTEGER
return values
none
code sample
gh_imgui.table_next_row(row_flags, min_row_height)
syntax
gh_imgui.table_set_bg_color (
target,
r, g, b, a,
column_n
)
parameters
target INTEGER
r, g, b, a REAL RGBA color
column_n INTEGER column index
return values
none
code sample
gh_imgui.table_set_bg_color(target, r, g, b, a, column_n)
syntax
gh_imgui.table_set_column_enabled (
column_n,
state
)
parameters
column_n INTEGER
state BOOLEAN 0 or 1
return values
none
code sample
gh_imgui.table_set_column_enabled(column_n, state)
syntax
ret = gh_imgui.table_set_column_index (
column_n
)
parameters
column_n INTEGER column index
return values
ret INTEGER 1 if success or 0 if error
code sample
ret = gh_imgui.table_set_column_index(column_n)
table_setup_column
Allows to to specify label, resizing policy, default width/weight, id, various other flags etc.
syntax
gh_imgui.table_setup_column (
label,
flags,
init_width_or_weight,
user_id
)
parameters
label STRING
flags INTEGER
init_width_or_weight REAL
user_id INTEGER
return values
none
code sample
gh_imgui.table_setup_column(label, flags, init_width_or_weight, user_id)
syntax
gh_imgui.table_setup_scroll_freeze (
cols,
rows
)
parameters
cols INTEGER
rows INTEGER
return values
none
code sample
gh_imgui.table_setup_scroll_freeze(cols, rows)
syntax
gh_imgui.terminate()
parameters
none
return values
none
code sample
gh_imgui.terminate()
text
Displays a simple text.
syntax
gh_imgui.text (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text("GeeXLab is powerful!")
text_rgba
Displays a colored text.
syntax
gh_imgui.text_rgba (
text,
r, g, b, a
)
parameters
text STRING text to display
r, g, b, a REAL color of the text
return values
none
code sample
gh_imgui.text_rgba("GeeXLab is powerful!", 1.0, 1.0, 0.0, 1.0)
syntax
gh_imgui.text_unformatted_v1 (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text_unformatted_v1("GeeXLab is powerful!")
syntax
gh_imgui.text_unformatted_v2 (
text,
text_end
)
parameters
text STRING text to display
text_end STRING XX euh...
return values
none
code sample
gh_imgui.text_unformatted_v2("GeeXLab is powerful!")
text_wrapped
Displays a wrapped text.
syntax
gh_imgui.text_wrapped (
text
)
parameters
text STRING text to display
return values
none
code sample
gh_imgui.text_wrapped("GeeXLab is powerful!")
syntax
out_value = gh_imgui.toggle (
label,
in_value,
size_x, size_y,
flags,
animation_duration,
frame_rounding,
knob_rounding
)
parameters
label STRING label
in_value BOOLEAN initial value
size_x, size_y REAL size in pixels of the toggle
flags INTEGER flags
animation_duration REAL animation duration
frame_rounding REAL frame rounding - from 0.0 to 1.0
knob_rounding REAL knob rounding - from 0.0 to 1.0
return values
out_value REAL value of the toggle: 0 or 1
code sample
ImGuiToggleFlags_None = 0
ImGuiToggleFlags_Animated = 1
ImGuiToggleFlags_BorderedFrame = 8
ImGuiToggleFlags_BorderedKnob = 16
ImGuiToggleFlags_ShadowedFrame = 32
ImGuiToggleFlags_ShadowedKnob = 64
ImGuiToggleFlags_A11y = 256
size_x = 40
size_y = 20
flags = ImGuiToggleFlags_Animated
animation_duration = 0.1
frame_rounding = 1.0
knob_rounding = 1.0
label = "Horizontal drag"
out_value = gh_imgui.toggle(label, in_value, size_x, size_y, flags, animation_duration, frame_rounding, knob_rounding)
syntax
state = gh_imgui.tree_node (
label
)
parameters
label STRING label
return values
state BOOLEAN tree opened: 1 (true) or 0 (false)
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_ex
Starts a tree.
syntax
state = gh_imgui.tree_node_ex (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TreeNodeFlags ) ImGuiTreeNodeFlags_xxx options
return values
state BOOLEAN tree opened: 1 (true) or 0 (false)
code sample
flags = ImGuiTreeNodeFlags_Selected
node_open = gh_imgui.tree_node_ex("Root", flags)
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_leaf
Display a tree leaf.
syntax
gh_imgui.tree_node_leaf (
label
)
parameters
label STRING label
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
tree_node_leaf_v2
Display a tree leaf.
syntax
gh_imgui.tree_node_leaf_v2 (
label,
flags
)
parameters
label STRING label
flags ENUM( imgui_TreeNodeFlags ) tree options - see ImGuiTreeNodeFlags_xxx constants in libs/lua/imgui.lua
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
local ImGuiTreeNodeFlags_Bullet = 512
gh_imgui.tree_node_leaf_v2("Child 1", ImGuiTreeNodeFlags_Bullet)
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
syntax
gh_imgui.tree_pop()
parameters
none
return values
none
code sample
node_open = gh_imgui.tree_node("Root")
if (node_open == 1) then
gh_imgui.tree_node_leaf("Child 1")
if (gh_imgui.is_item_clicked(mouse_button_left) == 1) then
tree_selected_node_name = "Child 1"
end
gh_imgui.tree_pop()
end
syntax
gh_imgui.underline (
r, g, b, a
)
parameters
r, g, b, a REAL color
return values
none
code sample
gh_imgui.underline(r, g, b, a)
unindent
Sets unindent spacing.
syntax
gh_imgui.unindent (
indent_w
)
parameters
indent_w REAL size
return values
none
code sample
gh_imgui.unindent(indent_w)
url
Draw a clickable url.
syntax
clicked = gh_imgui.url (
link_caption,
link_url,
tooltip_text
)
parameters
link_caption STRING caption
link_url STRING url (https://....) - Link can be empty to work like a button
tooltip_text STRING tool tip (can be empty)
return values
clicked INTEGER 1 if clicked, 0 otherwise.
code sample
clicked = gh_imgui.url(link_caption, link_url, tooltip_text)
syntax
value = gh_imgui.vslider_1f (
label,
width, height,
initial_value,
v_min, v_max,
power
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value REAL initial value
v_min, v_max REAL min / max value of the slider
power REAL use power != 1.0 for logarithmic sliders
return values
value REAL current value
code sample
v = gh_imgui.vslider_1f("vslider01", 20, 100, initial_value, v_min, v_max, 1.0)
syntax
value = gh_imgui.vslider_1i (
label,
width, height,
initial_value,
v_min, v_max
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
return values
value INTEGER current value
code sample
v = gh_imgui.vslider_1i("slider01", 20, 100, initial_value, v_min, v_max)
syntax
value = gh_imgui.vslider_1i_v2 (
label,
width, height,
initial_value,
v_min, v_max,
flags
)
parameters
label STRING name of the slider
width, height REAL size of the slider
initial_value INTEGER initial value
v_min, v_max INTEGER min / max value of the slider
flags INTEGER ImGuiSliderFlags_xxxx flags
return values
value INTEGER current value
code sample
ImGuiSliderFlags_None = 0
ImGuiSliderFlags_ClampOnInput = 16
ImGuiSliderFlags_Logarithmic = 32
ImGuiSliderFlags_NoRoundToFormat = 64
ImGuiSliderFlags_NoInput = 128
v = gh_imgui.vslider_1i_v2("slider01", 20, 100, initial_value, v_min, v_max, ImGuiSliderFlags_None)
syntax
gh_imgui.widget (
widget_type
)
parameters
widget_type ENUM( imgui_Widget ) type of the widget
return values
none
code sample
IMGUI_WIDGET_SEPARATOR = 1
IMGUI_WIDGET_SAME_LINE = 2
IMGUI_WIDGET_BULLET = 3
IMGUI_WIDGET_VERTICAL_SPACING = 4
IMGUI_WIDGET_NEW_LINE = 5
gh_imgui.widget(IMGUI_WIDGET_SEPARATOR)
syntax
is_open = gh_imgui.window_begin (
name,
width, height,
pos_x, pos_y,
win_flags,
pos_flags,
size_flags
)
parameters
name STRING name of the window
width, height REAL size of the window
pos_x, pos_y REAL position of the window
win_flags ENUM( imgui_WindowFlags ) window options: set to 0 for default options. Options can be OR-ed.
pos_flags ENUM( imgui_PosSizeFlags ) window position options: set to 4 for default options
size_flags ENUM( imgui_PosSizeFlags ) window size options: set to 4 for default options
return values
is_open BOOLEAN window: 1 (opened) or 0 (collapsed)
code sample
-- Window options
local window_default = 0
local window_no_resize = 2
local window_no_move = 4
local window_no_collapse = 32
local window_show_border = 128
local window_no_save_settings = 256
-- Position or size options
local pos_size_flag_always = 1 -- Always set the pos and/or size
local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed)
local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file)
local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time)
-- window_flags = window_no_move | window_no_save_settings
window_flags = 0
pos_flags = pos_size_flag_first_use_ever
size_flags = pos_size_flag_first_use_ever
is_open = gh_imgui.window_begin("GeeXLab ImGui demo", 300, 200, 20, 20, window_flags, pos_flags, size_flags)
if (is_open == 1) then
gh_imgui.text("GeeXLab is powerful!")
end
gh_imgui.window_end()
syntax
is_open, show_window = gh_imgui.window_begin_v2 (
name,
width, height,
pos_x, pos_y,
win_flags,
pos_flags,
size_flags,
show_window
)
parameters
name STRING name of the window
width, height REAL size of the window
pos_x, pos_y REAL position of the window
win_flags ENUM( imgui_WindowFlags ) window options: set to 0 for default options. Options can be OR-ed.
pos_flags ENUM( imgui_PosSizeFlags ) window position options: set to 4 for default options
size_flags ENUM( imgui_PosSizeFlags ) window size options: set to 4 for default options
show_window BOOLEAN initial open state of the window: 1 (show) or 0 (hide)
return values
is_open, show_window BOOLEAN is_open: 1 (window opened) or 0 (window collapsed) - show_window: 0 (the user has clicked on the close button)
code sample
-- Window options
local window_default = 0
local window_no_resize = 2
local window_no_move = 4
local window_no_collapse = 32
local window_show_border = 128
local window_no_save_settings = 256
-- Position or size options
local pos_size_flag_always = 1 -- Always set the pos and/or size
local pos_size_flag_once = 2 -- Set the pos and/or size once per runtime session (only the first call with succeed)
local pos_size_flag_first_use_ever = 4 -- Set the pos and/or size if the window has no saved data (if doesn't exist in the .ini file)
local pos_size_flag_appearing = 8 -- Set the pos and/or size if the window is appearing after being hidden/inactive (or the first time)
-- window_flags = window_no_move | window_no_save_settings
window_flags = 0
pos_flags = pos_size_flag_first_use_ever
size_flags = pos_size_flag_first_use_ever
if (show_window == 1) then
window_flags = 0
show = show_window
is_open, show_window = gh_imgui.window_begin_v2("GeeXLab information", 300, 200, 20, 20, window_flags, pos_flags, size_flags, show)
if (is_open == 1) then
gh_imgui.text("GeeXLab is powerful!")
end
gh_imgui.window_end()
end
syntax
gh_imgui.window_end()
parameters
none
return values
none
code sample
window_flags = 0
gh_imgui.window_begin("GeeXLab information", 300, 200, 20, 20, window_flags)
gh_imgui.text("GeeXLab is powerful!")
gh_imgui.window_end()
gh_mesh
Mesh module
gh_mesh is the module that manages the meshes.
A mesh is a set of triangular faces that can be used to represent any type of 3D shape: starting from the basic built-in shapes (plane, torus, sphere) to complex shapes created with modeling softwares such as 3D Studio Max or Blender.
syntax
gh_mesh.alloc_mesh_data (
mesh_id,
num_vertices,
num_faces
)
parameters
mesh_id ID mesh identifier
num_vertices INTEGER number of vertices
num_faces INTEGER number of faces
return values
none
code sample
mesh_triangle = gh_mesh.create()
gh_mesh.alloc_mesh_data(mesh_triangle, 3, 1)
create_box
Creates a mesh box.
syntax
mesh_id = gh_mesh.create_box (
width, height, depth,
wsegs, hsegs, dsegs
)
parameters
width, height, depth REAL size of the box
wsegs, hsegs, dsegs INTEGER number of subdivisions along X, Y and Z axis
return values
mesh_id ID mesh identifier
code sample
mesh_box = gh_mesh.create_box(10.0, 10.0, 10.0, 4, 4, 4)
syntax
mesh_id = gh_mesh.create_box_8v (
width, height, depth
)
parameters
width, height, depth REAL size of the box
return values
mesh_id ID mesh identifier
code sample
mesh_box = gh_mesh.create_box_8v(10.0, 10.0, 10.0)
create_cylinder
Creates a mesh cylinder.
syntax
mesh_id = gh_mesh.create_cylinder (
radius,
height,
stacks,
slices
)
parameters
radius REAL radius of the cylinder
height REAL height of the cylinder
stacks INTEGER number of subdivisions along the height
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
mesh_cyl = gh_mesh.create_cylinder(radius, height, stacks, slices)
create_cylinder_xyz
Creates a mesh cylinder.
syntax
mesh_id = gh_mesh.create_cylinder_xyz (
central_axis,
radius,
height,
stacks,
slices
)
parameters
central_axis ENUM( along_axis ) direction of the central axis: 0 (along X axis), 1 (along Y axis) or 2 (along Z axis)
radius REAL radius of the cylinder
height REAL height of the cylinder
stacks INTEGER number of subdivisions along the height
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
central_axis = 1 -- a Y-axis oriented cylinder
mesh_cyl = gh_mesh.create_cylinder_xyz(central_axis, radius, height, stacks, slices)
create_disc
Creates a mesh disc.
syntax
mesh_id = gh_mesh.create_disc (
radius,
thickness,
slices
)
parameters
radius REAL radius of the disc
thickness REAL thickness of the disc
slices INTEGER number of subdivisions along the perimeter
return values
mesh_id ID mesh identifier
code sample
mesh_disc = gh_mesh.create_disc(radius, thickness, slices)
create_ellipse
Creates a mesh ellipse.
syntax
mesh_id = gh_mesh.create_ellipse (
major_radius,
minor_radius,
slices,
radius_segments,
opening_angle
)
parameters
major_radius REAL major radius of the ellipse
minor_radius REAL minor radius of the ellipse
slices INTEGER number of subdivisions along the perimeter
radius_segments INTEGER number of subdivisions along the radius
opening_angle REAL opening angle. If 0, the ellipse is close
return values
mesh_id ID mesh identifier
code sample
mesh_ellipse = gh_mesh.create_ellipse(major_radius, minor_radius, slices, radius_segments, opening_angle)
mesh_disc = gh_mesh.create_ellipse(radius, radius, 20, 20, 0)
create_gear
Creates a mesh gear.
syntax
mesh_id = gh_mesh.create_gear (
inner_radius,
outer_radius,
tooth_depth,
num_teeth,
width
)
parameters
inner_radius REAL inner radius
outer_radius REAL outer radius
tooth_depth REAL depth of a tooth
num_teeth INTEGER number of teeth of the gear
width REAL width of the gear
return values
mesh_id ID mesh identifier
code sample
mesh_gear = gh_mesh.create_gear(1.0, 4.0, 1.0, 10, 2.0)
syntax
mesh_id = gh_mesh.create_icosphere (
radius,
recursion_level
)
parameters
radius REAL sphere radius
recursion_level INTEGER level of detail
return values
mesh_id ID mesh identifier
code sample
mesh_icosphere = gh_mesh.create_icosphere(10.0, 2)
create_plane
Creates a mesh plane.
syntax
mesh_id = gh_mesh.create_plane (
width, height,
wsegs, hsegs
)
parameters
width, height REAL size of the plane in the XZ plane
wsegs, hsegs INTEGER number of subdivisions along the X and Z axis
return values
mesh_id ID mesh identifier
code sample
mesh_plane = gh_mesh.create_plane(20.0, 10.0, 4, 4)
syntax
mesh_id = gh_mesh.create_plane_v3 (
width, height,
wsegs, hsegs,
pitch, yaw, roll
)
parameters
width, height REAL size of the plane in the XZ plane
wsegs, hsegs INTEGER number of subdivisions along the X and Z axis
pitch, yaw, roll REAL initial orientation of the vertices using Euler's angles
return values
mesh_id ID mesh identifier
code sample
mesh_plane = gh_mesh.create_plane_v3(20.0, 10.0, 4, 4, 45.0, 0, 0)
syntax
mesh_id = gh_mesh.create_quad (
width, height
)
parameters
width, height REAL size of the quad in the XY plane
return values
mesh_id ID mesh identifier
code sample
mesh_quad = gh_mesh.create_quad(20.0, 10.0)
create_sphere
Creates a mesh sphere.
syntax
mesh_id = gh_mesh.create_sphere (
radius,
stacks, slices
)
parameters
radius REAL radius of the sphere
stacks, slices INTEGER number of subdivisions along the X and Y axis.
return values
mesh_id ID mesh identifier
code sample
mesh_sphere = gh_mesh.create_sphere(10.0, 20, 20)
syntax
mesh_id = gh_mesh.create_terrain (
tex_id,
num_subdivisions,
vertical_scale,
terrain_size,
height_threshold
)
parameters
tex_id ID terrain texture identifier (height map)
num_subdivisions INTEGER number of subdivisions
vertical_scale REAL vertical scale factor
terrain_size REAL size of the terrain (the terrain is a square patch)
height_threshold REAL height threshold
return values
mesh_id ID mesh identifier
code sample
mesh_terrain = gh_mesh.create_terrain(tex_id, num_subdivisions, vertical_scale, terrain_size, height_threshold)
create_torus
Creates a mesh torus.
syntax
mesh_id = gh_mesh.create_torus (
outer_radius,
inner_radius,
slices
)
parameters
outer_radius REAL outer radius of the torus
inner_radius REAL inner radius of the torus
slices INTEGER number of subdivisions or sections
return values
mesh_id ID mesh identifier
code sample
mesh_torus = gh_mesh.create_torus(10.0, 4.0, 20)
syntax
mesh_id = gh_mesh.create_triangle()
parameters
none
return values
mesh_id ID mesh identifier
code sample
mesh_triangle = gh_mesh.create_triangle()
create_v2
Creates a mesh.
syntax
mesh_id = gh_mesh.create_v2()
parameters
none
return values
mesh_id ID mesh identifier
code sample
mesh_id = gh_mesh.create_v2()
syntax
x, y, z = gh_mesh.get_face_normal (
mesh_id,
face_index
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face between 0 and gh_object.get_num_faces()-1
return values
x, y, z REAL normal vector
code sample
x, y, z = gh_mesh.get_face_normal(mesh_id, face_index)
syntax
a, b, c = gh_mesh.get_face_vertex_indices (
mesh_id,
face_index
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face between 0 and gh_object.get_num_faces()-1
return values
a, b, c INTEGER vertex indices
code sample
a, b, c = gh_mesh.get_face_vertex_indices(mesh_id, face_index)
syntax
x, y, z = gh_mesh.get_vertex_absolute_position (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z REAL 3D position
code sample
vertex_index = 0
x, y, z = gh_mesh.get_vertex_absolute_position(mesh_id, vertex_index)
syntax
r, g, b, a = gh_mesh.get_vertex_color (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
r, g, b, a REAL RGBA color of the vertex
code sample
vertex_index = 0
r, g, b, a = gh_mesh.get_vertex_color(mesh_id, vertex_index)
syntax
x, y, z = gh_mesh.get_vertex_normal (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z REAL normal vector
code sample
vertex_index = 0
x, y, z = gh_mesh.get_vertex_normal(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_position (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z, w REAL 4D position
code sample
vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_position(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_tangent (
mesh_id,
vertex_index
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
return values
x, y, z, w REAL tangent vector
code sample
vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_tangent(mesh_id, vertex_index)
syntax
x, y, z, w = gh_mesh.get_vertex_uv (
mesh_id,
vertex_index,
tex_unit
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
tex_unit INTEGER texture unit of the texcoord set. Only two sets are supported
return values
x, y, z, w REAL tangent vector
code sample
vertex_index = 0
tex_unit = 0
x, y, z, w = gh_mesh.get_vertex_uv(mesh_id, vertex_index, tex_unit)
syntax
buff_ptr, buff_size = gh_mesh.instancing_attrib_buffer_get (
mesh_id,
va_index
)
parameters
mesh_id ID mesh identifier
va_index INTEGER vertex attrib index
return values
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
code sample
va_index = 0
position_ptr, size = gh_mesh.instancing_attrib_buffer_get(mesh_id, va_index)
syntax
gh_mesh.instancing_attrib_buffer_update_needed (
mesh_id,
va_index
)
parameters
mesh_id ID mesh identifier
va_index INTEGER vertex attrib index
return values
none
code sample
va_index = 0
gh_mesh.instancing_attrib_buffer_update_needed(mesh_id, va_index)
syntax
r, g, b, a = gh_mesh.instancing_get_color (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
r, g, b, a REAL RGBA color of the instance
code sample
r, g, b, a = gh_mesh.instancing_get_color(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_orientation (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL orientation of the instance (quaternion)
code sample
x, y, z, w = gh_mesh.instancing_get_orientation(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_position (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL position of the instance
code sample
x, y, z, w = gh_mesh.instancing_get_position(mesh_id, instance)
syntax
x, y, z, w = gh_mesh.instancing_get_scale (
mesh_id,
index
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
return values
x, y, z, w REAL scale of the instance
code sample
x, y, z, w = gh_mesh.instancing_get_scale(mesh_id, instance)
syntax
gh_mesh.instancing_init (
mesh_id,
num_instances
)
parameters
mesh_id ID mesh identifier
num_instances INTEGER number of instances
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
separate_vertex_arrays = 1
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances-1 do
x = math.random(-100, 100)
y = math.random(-50, 50)
z = 0.0
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_axis_angle (
mesh_id,
index,
x, y, z,
angle
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL rotation axis
angle REAL rotation angle
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_axis_angle(mesh_id, i, 0.0, 0.0, 1.0, 60.0)
gh_mesh.instancing_set_color(mesh_id, i, 1.0, 1.0, 1.0, 1.0)
end
syntax
gh_mesh.instancing_set_color (
mesh_id,
index,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
r, g, b, a REAL RGBA color of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_color(mesh_id, i, 1.0, 1.0, 1.0, 1.0)
end
syntax
gh_mesh.instancing_set_orientation (
mesh_id,
index,
pitch, yaw, roll
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
pitch, yaw, roll REAL angles of rotation around X, Y and Z axis
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_orientation_v2 (
mesh_id,
index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z, w REAL rotation quaternion
return values
none
code sample
local num_instances = 1000
gh_mesh.instancing_init(mesh, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
qx = ...
qy = ...
qz = ...
qw = ...
gh_mesh.instancing_set_orientation_v2(mesh_id, i, qx, qy, qz, qw)
end
syntax
gh_mesh.instancing_set_position (
mesh_id,
index,
x, y, z
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL position of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
x = math.random(-60, 60)
y = math.random(-60, 60)
z = math.random(-60, 60)
gh_mesh.instancing_set_orientation(mesh_id, i, x, y, z)
end
syntax
gh_mesh.instancing_set_position_v2 (
mesh_id,
index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z, w REAL position of the instance
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position_v2(mesh_id, i, x, y, z, 1.0)
end
syntax
gh_mesh.instancing_set_scale (
mesh_id,
index,
x, y, z
)
parameters
mesh_id ID mesh identifier
index INTEGER index of the instance from 0 to num_instances-1
x, y, z REAL scaling factors along the 3 axis
return values
none
code sample
-- mesh instancing requires separate vertex arrays.
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(separate_vertex_arrays)
local num_instances = 1000
gh_mesh.instancing_init(mesh_id, num_instances)
local i
for i=0, num_instances do
x = math.random(-10, 10)
y = math.random(-10, 10)
z = math.random(-10, 10)
gh_mesh.instancing_set_position(mesh_id, i, x, y, z)
gh_mesh.instancing_set_scale(mesh_id, i, 1.0, 1.0, 1.0)
end
syntax
ret = gh_mesh.meshlet_generate (
mesh_id,
max_vertices,
max_indices
)
parameters
mesh_id ID mesh identifier
max_vertices INTEGER max vertices of a meshlet
max_indices INTEGER max indices of a meshlet. 3 indices make a triangular face.
return values
ret INTEGER 1 if ok, 0 if error.
code sample
ret = gh_mesh.meshlet_generate(mesh_id, 64, 126)
syntax
n = gh_mesh.meshlet_get_count (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
n INTEGER number of meshlets
code sample
n = gh_mesh.meshlet_get_count(mesh_id)
syntax
mesh_face_index = gh_mesh.meshlet_get_index (
mesh_id,
meshlet_index,
meshlet_primitive_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
meshlet_primitive_index INTEGER index in the meshlet indices list (0 to num_meshlet_indices-1)
return values
mesh_face_index INTEGER index relative to the meshlet indices list
code sample
mesh_face_index = gh_mesh.meshlet_get_index(mesh_id, meshlet_index, meshlet_primitive_index)
syntax
num_meshlet_indices = gh_mesh.meshlet_get_index_count (
mesh_id,
meshlet_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
return values
num_meshlet_indices INTEGER number of indices
code sample
num_meshlet_indices = gh_mesh.meshlet_get_index_count(mesh_id)
syntax
mesh_vertex_index = gh_mesh.meshlet_get_vertex (
mesh_id,
meshlet_index,
meshlet_vertex_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
meshlet_vertex_index INTEGER vertex in the meshlet vertices list (0 to num_meshlet_vertices-1)
return values
mesh_vertex_index INTEGER index relative to the mesh vertices list
code sample
mesh_vertex_index = gh_mesh.meshlet_get_vertex(mesh_id, meshlet_index, meshlet_vertex_index)
syntax
num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count (
mesh_id,
meshlet_index
)
parameters
mesh_id ID mesh identifier
meshlet_index INTEGER meshlet index (0 to num_meshlets-1)
return values
num_meshlet_vertices INTEGER number of vertices
code sample
num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count(mesh_id)
syntax
gh_mesh.resize_box (
width, height, depth,
mesh_id
)
parameters
width, height, depth REAL size of the box
mesh_id ID mesh identifier
return values
none
code sample
gh_mesh.resize_box(mesh_id, 10.0, 10.0, 10.0)
syntax
gh_mesh.resize_plane (
mesh_id,
width, height
)
parameters
mesh_id ID mesh identifier
width, height REAL size of the quad in the XY plane
return values
none
code sample
gh_mesh.resize_plane(mesh_id, 20.0, 15.0)
syntax
gh_mesh.resize_quad (
mesh_id,
width, height
)
parameters
mesh_id ID mesh identifier
width, height REAL size of the quad in the XY plane
return values
none
code sample
gh_mesh.resize_quad(mesh_id, 20.0, 15.0)
syntax
gh_mesh.ribbon_add_point (
mesh_id,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
x, y, z, w REAL position of the new point
return values
none
code sample
gh_mesh.ribbon_add_point(mesh_id, x, y, z, 1.0)
syntax
mesh_id = gh_mesh.ribbon_create (
thickness
)
parameters
thickness REAL thickness of ribbon
return values
mesh_id ID mesh identifier
code sample
mesh_id = gh_mesh.ribbon_create(2.0)
syntax
gh_mesh.ribbon_set_cross_vector (
mesh_id,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
x, y, z, w REAL vector coordinates
return values
none
code sample
gh_mesh.ribbon_set_cross_vector(mesh_id, x, y, z)
syntax
gh_mesh.set_face_vertex_indices (
mesh_id,
face_index,
a, b, c
)
parameters
mesh_id ID mesh identifier
face_index INTEGER index of the face
a, b, c INTEGER vertex indices
return values
none
code sample
gh_mesh.set_face_vertex_indices(mesh_id, face_index, a, b, c)
syntax
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays (
state
)
parameters
state INTEGER 1 (separate vertex arrays) or 0 (interleaved vertex array) - Default is separate vertex arrays.
return values
none
code sample
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(0)
...
mesh = gh_mesh.create_plane(128, 128, 10, 10)
...
gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(1)
syntax
gh_mesh.set_vertex_color (
mesh_id,
vertex_index,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
r, g, b, a REAL RGBA color of the vertex
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_color(mesh_id, vertex_index, r, g, b, a)
syntax
gh_mesh.set_vertex_normal (
mesh_id,
vertex_index,
x, y, z
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z REAL normal vector
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_normal(mesh_id, vertex_index, x, y, z)
syntax
gh_mesh.set_vertex_position (
mesh_id,
vertex_index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL 3D position
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_position(mesh_id, vertex_index, x, y, z, 1.0)
syntax
gh_mesh.set_vertex_source (
mesh_id,
gpu_buffer_id
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
return values
none
code sample
gh_mesh.set_vertex_source(mesh_id, gpu_buffer_id)
syntax
gh_mesh.set_vertex_tangent (
mesh_id,
vertex_index,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL tangent vector
return values
none
code sample
vertex_index = 0
gh_mesh.set_vertex_tangent(mesh_id, vertex_index, x, y, z, w)
syntax
gh_mesh.set_vertex_uv (
mesh_id,
vertex_index,
x, y, z, w,
tex_unit
)
parameters
mesh_id ID mesh identifier
vertex_index INTEGER index of the vertex between 0 and gh_object.get_num_vertices()-1
x, y, z, w REAL texcoord
tex_unit INTEGER texture unit of the texcoord set. Only two sets are supported
return values
none
code sample
vertex_index = 0
tex_unit = 0
gh_mesh.set_vertex_uv(mesh_id, vertex_index, x, y, z, w, tex_unit)
syntax
gh_mesh.set_vertices_color (
mesh_id,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
r, g, b, a REAL RGBA color of the vertex
return values
none
code sample
gh_mesh.set_vertices_color(mesh_id, r, g, b, a)
syntax
gh_mesh.vertices_from_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
size,
update_cpu,
update_gpu
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
size INTEGER size of the copy in bytes
update_cpu BOOLEAN update the mesh vertex array in CPU memory: 1 (YES) or 0 (NO)
update_gpu BOOLEAN update the mesh vertex array in GPU memory: 1 (YES) or 0 (NO)
return values
none
code sample
gh_mesh.vertices_from_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, size, update_cpu, update_gpu)
syntax
gh_mesh.vertices_position_from_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
gpu_buffer_stride,
size,
update_cpu,
update_gpu
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
gpu_buffer_stride INTEGER stride value: size in bytes between to consecutive positions in the gpu buffer
size INTEGER size of the copy in bytes
update_cpu BOOLEAN update the mesh vertex array in CPU memory: 1 (YES) or 0 (NO)
update_gpu BOOLEAN update the mesh vertex array in GPU memory: 1 (YES) or 0 (NO)
return values
none
code sample
gpu_buffer_stride = 16 # 16 bytes = size of a vec4.
gpu_buffer_offset = 0
gh_mesh.vertices_position_from_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, gpu_buffer_stride, size, update_cpu, update_gpu)
syntax
gh_mesh.vertices_position_to_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset,
gpu_buffer_stride
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
gpu_buffer_stride INTEGER stride value: size in bytes between to consecutive positions in the gpu buffer
return values
none
code sample
gpu_buffer_stride = 16 # 16 bytes = size of a vec4.
gpu_buffer_offset = 0
gh_mesh.vertices_position_to_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, gpu_buffer_stride)
syntax
gh_mesh.vertices_to_gpu_buffer (
mesh_id,
gpu_buffer_id,
gpu_buffer_offset
)
parameters
mesh_id ID mesh identifier
gpu_buffer_id ID gpu buffer identifier
gpu_buffer_offset INTEGER offset in the gpu buffer in bytes
return values
none
code sample
gh_mesh.vertices_to_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset)
voxelize
Voxelizes a mesh.
syntax
gh_mesh.voxelize (
mesh_id,
voxelsizex,
voxelsizey,
voxelsizez
)
parameters
mesh_id ID mesh identifier
voxelsizex REAL width of a voxel
voxelsizey REAL height of a voxel
voxelsizez REAL depth of a voxel
return values
none
code sample
gh_mesh.voxelize(mesh_id, 4, 4, 4)
gh_physx3 windowslinuxmacos
NVIDIA PhysX 3 module
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.
syntax
gh_physx3.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_physx3.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx3.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_physx3.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx3.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_physx3.actor_apply_transform(actor_id, object)
syntax
gh_physx3.actor_clear_forces (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_clear_forces(actor_id)
syntax
s = gh_physx3.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
s REAL squared speed
code sample
s = gh_physx3.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx3.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_physx3.actor_get_angular_velocity(actor_id)
syntax
s = gh_physx3.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
s REAL squared speed
code sample
s = gh_physx3.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx3.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = ggh_physx3.actor_get_linear_velocity(actor_id)
syntax
x, y, z, w = gh_physx3.actor_get_orientation (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z, w REAL orientation
code sample
x, y, z, w = gh_physx3.actor_get_orientation(actor_id)
syntax
x, y, z = gh_physx3.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_physx3.actor_get_position(actor_id)
syntax
thres = gh_physx3.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
t = gh_physx3.actor_get_sleep_threshold(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx3.actor_get_transform_mat16 (
actor_id
)
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_physx3.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx3.actor_get_transform_pos_qrot (
actor_id
)
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_physx3.actor_get_transform_pos_qrot(actor_id)
syntax
state = gh_physx3.actor_is_sleeping (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
is_sleeping = gh_physx3.actor_is_sleeping(actor_id)
actor_kill
Destroys an actor.
syntax
gh_physx3.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_kill(actor_id)
syntax
gh_physx3.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx3.actor_put_to_sleep(actor_id)
syntax
gh_physx3.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID PhysX actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_physx3.actor_set_3d_object(actor_id, oid)
syntax
gh_physx3.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx3.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx3.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx3.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx3.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_physx3.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx3.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx3.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx3.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_physx3.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx3.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx3.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx3.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx3.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx3.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID PhysX actor identifier
mat_id ID material identifier
return values
none
code sample
gh_physx3.actor_set_material(actor_id, mat_id)
syntax
gh_physx3.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_physx3.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx3.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_physx3.actor_set_position(actor_id, x, y, z)
syntax
gh_physx3.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_physx3.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx3.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx3.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx3.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID PhysX actor identifier
density REAL density
return values
none
code sample
gh_physx3.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx3.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_physx3.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx3.check_results (
scene_id
)
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_physx3.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_physx3.check_results(scene_id) == 1) then
gh_physx3.fetch_results(scene_id)
can_run_sim = true
end
syntax
actor_id = gh_physx3.cloth_create_from_mesh (
scene_id,
mesh_id,
gpu_cloth,
x, y, z,
pitch, yaw, roll,
gx, gy, gz
)
parameters
scene_id ID PhysX scene identifier
mesh_id ID mesh identifier
gpu_cloth BOOLEAN run on GPU: 1 (true) or 0 (false)
x, y, z REAL position
pitch, yaw, roll REAL Euler's angles
gx, gy, gz REAL gravity vector
return values
actor_id ID identifier of the cloth actor
code sample
actor_id = gh_physx3.cloth_create_from_mesh(scene_id, mesh_id, gpu_cloth, x, y, z, pitch. yaw, roll, gravity_x, gravity_y, gravity_z)
syntax
state = gh_physx3.cloth_is_running_on_gpu (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
state = gh_physx3.cloth_is_running_on_gpu(actor_id)
syntax
gh_physx3.cloth_set_external_acceleration (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL acceleration vector
return values
none
code sample
gh_physx3.cloth_set_external_acceleration(actor_id, x, y, z)
syntax
gh_physx3.cloth_set_gpu_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx3.cloth_set_gpu_state(actor_id, state)
syntax
gh_physx3.cloth_set_stiffness (
actor_id,
stiffness
)
parameters
actor_id ID PhysX actor identifier
stiffness REAL stiffness
return values
none
code sample
gh_physx3.cloth_set_stiffness(actor_id, stiffness)
syntax
gh_physx3.cloth_update_mesh_vertex_data (
actor_id,
mesh_id,
update_position,
update_normals
)
parameters
actor_id ID PhysX actor identifier
mesh_id ID mesh identifier
update_position BOOLEAN updates positions: 1 (true) or 0 (false)
update_normals BOOLEAN updates normals: 1 (true) or 0 (false)
return values
none
code sample
gh_physx3.cloth_update_mesh_vertex_data(actor_id, mesh_id, 1, 0)
syntax
gh_physx3.cloth_update_particles_from_mesh_particles (
actor_id,
mesh_id
)
parameters
actor_id ID PhysX actor identifier
mesh_id ID mesh identifier
return values
none
code sample
gh_physx3.cloth_update_particles_from_mesh_particles(actor_id, mesh_id)
create_actor_box
Creates a box actor.
syntax
actor_id = gh_physx3.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
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_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Creates a capsule actor.
syntax
actor_id = gh_physx3.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
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_id_capsule = gh_physx3.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx3.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
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_id_mesh = gh_physx3.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx3.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
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_id_mesh = gh_physx3.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Creates a plane actor.
syntax
actor_id = gh_physx3.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
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_id_plane = gh_physx3.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Creates a sphere actor.
syntax
actor_id = gh_physx3.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
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_id_plane = gh_physx3.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
syntax
mat_id = gh_physx3.create_material (
static_friction,
dynamic_friction,
resilience
)
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_physx3.create_material(0.5, 0.5, 0.5)
syntax
scene_id = gh_physx3.create_scene (
gpu_physx,
bounce_threshold_velocity
)
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_physx3.create_scene(1, bounce_threshold_velocity)
syntax
scene_id = gh_physx3.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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_physx3.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx3.create_scene_broadphase_mbp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
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_physx3.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
syntax
scene_id = gh_physx3.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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_physx3.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
ret = gh_physx3.fetch_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.run_simulation_step(scene_id, time_step)
gh_physx3.fetch_results(scene_id)
syntax
clock = gh_physx3.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_physx3.gpu_get_clock_frequency_khz()
syntax
name = gh_physx3.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_physx3.gpu_get_name()
syntax
num_sm = gh_physx3.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_physx3.gpu_get_num_multiprocessors()
syntax
size = gh_physx3.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_physx3.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx3.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_physx3.gpu_is_supported()
syntax
joint_id = gh_physx3.joint_create (
scene_id,
joint_type,
actor_id1,
x1, y1, z1,
pitch1, yaw1, roll1,
actor_id2,
x2, y2, z2,
pitch2, yaw2, roll2
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) type of joint: SPHERICAL (0), REVOLUTE (1), FIXED (2), DISTANCE (3), PRISMATIC (4), D6 (5 not implemented)
actor_id1 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
actor_id2 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_physx3.joint_create(scene_id, joint_type, actor_id1, x1, y1, z1, pitch1, yaw1, roll1, actor_id2, x2, y2, z2, pitch2, yaw2, roll2)
syntax
gh_physx3.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_physx3.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx3.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_physx3.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx3.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_physx3.joint_kill(joint_id)
syntax
gh_physx3.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_physx3.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx3.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
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
none
code sample
gh_physx3.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx3.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_physx3.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx3.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_physx3.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx3.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
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
none
code sample
gh_physx3.joint_set_motor_params(px_joint, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx3.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_physx3.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx3.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_physx3.kill_material(mat_id)
syntax
px_ps_id = gh_physx3.particle_system_create (
scene_id,
max_particles,
run_on_gpu,
init_particles
)
parameters
scene_id ID PhysX scene identifier
max_particles INTEGER max number of particles
run_on_gpu BOOLEAN 1 (GPU) or 0 (CPU)
init_particles BOOLEAN initializes particles positions: 1 (true) or 0 (false)
return values
px_ps_id ID PhysX particle system actor identifier
code sample
px_ps_id = gh_physx3.particle_system_create(scene_id, max_particles, run_on_gpu, 0)
syntax
px_ps_id = gh_physx3.particle_system_create_fluid (
scene_id,
max_particles,
particle_size,
viscosity,
stiffness,
run_on_gpu,
init_particles
)
parameters
scene_id ID PhysX scene identifier
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 BOOLEAN 1 (GPU) or 0 (CPU)
init_particles BOOLEAN initializes particles positions: 1 (true) or 0 (false)
return values
px_ps_id ID PhysX particle system actor identifier
code sample
px_ps_id = gh_physx3.particle_system_create_fluid(scene_id, max_particles, particle_size, viscosity, stiffness, run_on_gpu, 0)
syntax
gh_physx3.particle_system_from_gxc_ps (
px_ps_id,
gxc_ps_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
gxc_ps_id ID gxc particle system identifier
return values
none
code sample
gh_physx3.particle_system_from_gxc_ps(px_ps_id, gxc_ps_id)
syntax
gh_physx3.particle_system_position_from_vertex_pool (
px_ps_id,
vp_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
vp_id ID vertex pool identifier
return values
none
code sample
gh_physx3.particle_system_position_from_vertex_pool(px_ps_id, vp_id)
syntax
gh_physx3.particle_system_position_to_vertex_pool (
px_ps_id,
vp_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
vp_id ID vertex pool identifier
return values
none
code sample
gh_physx3.particle_system_position_to_vertex_pool(px_ps_id, vp_id)
syntax
gh_physx3.particle_system_to_gxc_ps (
px_ps_id,
gxc_ps_id
)
parameters
px_ps_id ID PhysX particle system actor identifier
gxc_ps_id ID gxc particle system identifier
return values
none
code sample
gh_physx3.particle_system_to_gxc_ps(px_ps_id, gxc_ps_id)
run_simulation
Runs a simulation.
syntax
ret = gh_physx3.run_simulation (
scene_id,
dt,
time_step
)
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_physx3.run_simulation(scene_id, dt, time_step)
run_simulation_step
Runs a simulation step.
syntax
ret = gh_physx3.run_simulation_step (
scene_id,
time_step
)
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_physx3.run_simulation_step(scene_id, time_step)
syntax
gh_physx3.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx3.scene_sync_3d_objects(sid)
syntax
gh_physx3.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
code sample
velocity = 3.0
gh_physx3.set_max_depenetration_velocity(velocity)
...
actor_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
syntax
gh_physx3.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_physx3.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx3.set_simulation_scales (
size,
mass,
speed
)
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
none
code sample
gh_physx3.set_simulation_scales(1, 1000, 10)
syntax
gh_physx3.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx3.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_id_box = gh_physx3.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Starts the PhysX engine.
syntax
ret = gh_physx3.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx3.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx3.stop()
syntax
gh_physx3.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_physx3.update_material(mat_id, static_friction, dynamic_friction, resilience)
gh_physx4 windowslinuxmacos
NVIDIA PhysX 4 module
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.
syntax
gh_physx4.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_physx4.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx4.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_physx4.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx4.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_physx4.actor_apply_transform(actor_id, obj_id)
syntax
gh_physx4.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_physx4.actor_clear_forces(actor_id)
syntax
s = gh_physx4.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_physx4.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx4.actor_get_angular_velocity (
actor_id
)
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)
syntax
speed = gh_physx4.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
speed REAL squared speed
code sample
speed = gh_physx4.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx4.actor_get_linear_velocity (
actor_id
)
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)
syntax
x, y, z, w = gh_physx4.actor_get_orientation (
actor_id
)
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)
syntax
x, y, z = gh_physx4.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_physx4.actor_get_position(actor_id)
syntax
thres = gh_physx4.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
thres = gh_physx4.actor_get_sleep_threshold(actor_id)
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
)
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)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx4.actor_get_transform_pos_qrot (
actor_id
)
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)
syntax
state = gh_physx4.actor_is_sleeping (
actor_id
)
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
Destroys an actor.
syntax
gh_physx4.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx4.actor_kill(actor_id)
syntax
gh_physx4.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_physx4.actor_put_to_sleep(actor_id)
syntax
gh_physx4.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_physx4.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_physx4.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx4.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx4.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx4.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx4.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_physx4.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx4.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx4.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx4.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_physx4.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx4.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_physx4.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx4.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_physx4.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx4.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_physx4.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx4.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_physx4.actor_set_material(actor_id, mat_id)
syntax
gh_physx4.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_physx4.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx4.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_physx4.actor_set_position(actor_id, x, y, z)
syntax
gh_physx4.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_physx4.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx4.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_physx4.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx4.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID actor identifier
density REAL density
return values
none
code sample
gh_physx4.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx4.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_physx4.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx4.check_results (
scene_id
)
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
Creates a box actor.
syntax
actor_id = gh_physx4.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
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
Creates a capsule actor.
syntax
actor_id = gh_physx4.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
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)
syntax
actor_id = gh_physx4.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
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)
syntax
actor_id = gh_physx4.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
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
Creates a plane actor.
syntax
actor_id = gh_physx4.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
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
Creates a sphere actor.
syntax
actor_id = gh_physx4.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
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)
syntax
mat_id = gh_physx4.create_material (
static_friction,
dynamic_friction,
resilience
)
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)
syntax
scene_id = gh_physx4.create_scene (
gpu_physx,
bounce_threshold_velocity
)
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)
syntax
scene_id = gh_physx4.create_scene_broadphase_abp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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)
syntax
scene_id = gh_physx4.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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)
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
)
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)
syntax
scene_id = gh_physx4.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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)
create_scene_set_solver_type
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
)
parameters
solver_type ENUM( physx_solver_type ) solver type
return values
none
code sample
gh_physx4.create_scene_set_solver_type(solver_type)
syntax
ret = gh_physx4.fetch_results (
scene_id
)
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)
syntax
clock = gh_physx4.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_physx4.gpu_get_clock_frequency_khz()
syntax
name = gh_physx4.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_physx4.gpu_get_name()
syntax
num_sm = gh_physx4.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_physx4.gpu_get_num_multiprocessors()
syntax
size = gh_physx4.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_physx4.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx4.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_physx4.gpu_is_supported()
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
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) 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)
syntax
gh_physx4.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_physx4.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx4.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_physx4.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx4.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_physx4.joint_kill(joint_id)
syntax
gh_physx4.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_physx4.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx4.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
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
none
code sample
gh_physx4.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx4.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_physx4.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx4.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_physx4.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx4.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
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
none
code sample
gh_physx4.joint_set_motor_params(joint_id, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx4.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_physx4.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx4.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_physx4.kill_material(mat_id)
syntax
ret = gh_physx4.run_simulation (
scene_id,
dt,
time_step
)
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
Runs a simulation step.
syntax
ret = gh_physx4.run_simulation_step (
scene_id,
time_step
)
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)
syntax
n = gh_physx4.scene_get_num_active_actors (
scene_id
)
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)
syntax
gh_physx4.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx4.scene_sync_3d_objects(scene_id)
scene_sync_3d_objects_v2
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
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_physx4.scene_sync_3d_objects_v2(scene_id)
syntax
gh_physx4.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
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)
syntax
gh_physx4.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_physx4.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx4.set_simulation_scales (
size,
mass,
speed
)
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
none
code sample
gh_physx4.set_simulation_scales(1, 1000, 10)
syntax
gh_physx4.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
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
Starts the PhysX engine.
syntax
ret = gh_physx4.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx4.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx4.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_physx4.stop()
syntax
gh_physx4.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_physx4.update_material(mat_id, static_friction, dynamic_friction, resilience)
gh_physx5 windowslinuxmacos
NVIDIA PhysX 5 module
gh_physx5 is the module that manages NVIDIA PhysX 5 engine.
Thanks to gh_physx5, you will be able to play with rigid body collisions, joints and particles.
syntax
gh_physx5.actor_add_force (
actor_id,
fx, fy, fz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
return values
none
code sample
gh_phys5.actor_add_force(actor_id, fx, fy, fz)
syntax
gh_physx5.actor_add_force_at_position (
actor_id,
fx, fy, fz,
px, py, pz
)
parameters
actor_id ID PhysX actor identifier
fx, fy, fz REAL force
px, py, pz REAL position
return values
none
code sample
gh_phys5.actor_add_force_at_position(actor_id, fx, fy, fz, px, py, pz)
syntax
gh_physx5.actor_apply_transform (
actor_id,
obj_id
)
parameters
actor_id ID PhysX actor identifier
obj_id ID object identifier
return values
none
code sample
gh_phys5.actor_apply_transform(actor_id, obj_id)
syntax
gh_physx5.actor_clear_forces (
actor_id
)
parameters
actor_id ID actor identifier
return values
none
code sample
gh_phys5.actor_clear_forces(actor_id)
syntax
s = gh_physx5.actor_get_angular_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
s REAL squared speed
code sample
s = gh_phys5.actor_get_angular_speed2(actor_id)
syntax
x, y, z = gh_physx5.actor_get_angular_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_phys5.actor_get_angular_velocity(actor_id)
syntax
speed = gh_physx5.actor_get_linear_speed2 (
actor_id
)
parameters
actor_id ID actor identifier
return values
speed REAL squared speed
code sample
speed = gh_phys5.actor_get_linear_speed2(actor_id)
syntax
x, y, z = gh_physx5.actor_get_linear_velocity (
actor_id
)
parameters
actor_id ID actor identifier
return values
x, y, z REAL velocity vector
code sample
x, y, z = ggh_phys5.actor_get_linear_velocity(actor_id)
syntax
x, y, z, w = gh_physx5.actor_get_orientation (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z, w REAL orientation
code sample
x, y, z, w = gh_phys5.actor_get_orientation(actor_id)
syntax
x, y, z = gh_physx5.actor_get_position (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
x, y, z REAL position
code sample
x, y, z = gh_phys5.actor_get_position(actor_id)
syntax
thres = gh_physx5.actor_get_sleep_threshold (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
thres REAL threshold
code sample
thres = gh_phys5.actor_get_sleep_threshold(actor_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_physx5.actor_get_transform_mat16 (
actor_id
)
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_phys5.actor_get_transform_mat16(actor_id)
syntax
px, py, pz, qx, qy, qz, qw = gh_physx5.actor_get_transform_pos_qrot (
actor_id
)
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_phys5.actor_get_transform_pos_qrot(actor_id)
syntax
state = gh_physx5.actor_is_sleeping (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
state BOOLEAN state (0 or 1)
code sample
is_sleeping = gh_phys5.actor_is_sleeping(actor_id)
actor_kill
Destroys an actor.
syntax
gh_physx5.actor_kill (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_phys5.actor_kill(actor_id)
syntax
gh_physx5.actor_put_to_sleep (
actor_id
)
parameters
actor_id ID PhysX actor identifier
return values
none
code sample
gh_phys5.actor_put_to_sleep(actor_id)
syntax
gh_physx5.actor_set_3d_object (
actor_id,
o3d_id
)
parameters
actor_id ID actor identifier
o3d_id ID 3d object identifier
return values
none
code sample
gh_phys5.actor_set_3d_object(actor_id, o3d_id)
syntax
gh_physx5.actor_set_angular_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_phys5.actor_set_angular_damping(actor_id, 0.2)
syntax
gh_physx5.actor_set_angular_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_phys5.actor_set_angular_velocity(actor_id, 0.8, 12, 1.6)
syntax
gh_physx5.actor_set_euler_angles (
actor_id,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
pitch, yaw, roll REAL Eurler's angles in degrees
return values
none
code sample
gh_phys5.actor_set_euler_angles(actor_id, 90, 0, 0)
syntax
gh_physx5.actor_set_gravity_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_phys5.actor_set_gravity_state(actor_id, 1)
syntax
gh_physx5.actor_set_kinematic_state (
actor_id,
state
)
parameters
actor_id ID PhysX actor identifier
state BOOLEAN state (0 or 1)
return values
none
code sample
gh_phys5.actor_set_kinematic_state(actor_id, 1)
syntax
gh_physx5.actor_set_kinematic_target (
actor_id,
px, py, pz,
pitch, yaw, roll
)
parameters
actor_id ID PhysX actor identifier
px, py, pz REAL destination position
pitch, yaw, roll REAL destination orientation
return values
none
code sample
gh_phys5.actor_set_kinematic_target(actor_id, px, py, pz, pitch, yaw, roll)
syntax
gh_physx5.actor_set_linear_damping (
actor_id,
damping
)
parameters
actor_id ID PhysX actor identifier
damping REAL damping
return values
none
code sample
gh_phys5.actor_set_linear_damping(actor_id, 0.2)
syntax
gh_physx5.actor_set_linear_velocity (
actor_id,
vx, vy, vz
)
parameters
actor_id ID PhysX actor identifier
vx, vy, vz REAL 3D velocity vector
return values
none
code sample
gh_phys5.actor_set_linear_velocity(actor_id, 10, 10, 10)
syntax
gh_physx5.actor_set_material (
actor_id,
mat_id
)
parameters
actor_id ID actor identifier
mat_id ID material identifier
return values
none
code sample
gh_phys5.actor_set_material(actor_id, mat_id)
syntax
gh_physx5.actor_set_orientation (
actor_id,
x, y, z, w
)
parameters
actor_id ID PhysX actor identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
gh_phys5.actor_set_orientation(actor_id, x, y, z, w)
syntax
gh_physx5.actor_set_position (
actor_id,
x, y, z
)
parameters
actor_id ID PhysX actor identifier
x, y, z REAL position
return values
none
code sample
gh_phys5.actor_set_position(actor_id, x, y, z)
syntax
gh_physx5.actor_set_sleep_threshold (
actor_id,
thres
)
parameters
actor_id ID PhysX actor identifier
thres REAL threshold
return values
none
code sample
gh_phys5.actor_set_sleep_threshold(actor_id, 0.2)
syntax
gh_physx5.actor_set_solver_iterations (
actor_id,
position_iterations,
velocity_iterations
)
parameters
actor_id ID PhysX actor identifier
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_phys5.actor_set_solver_iterations(actor_id, position_iterations, velocity_iterations)
syntax
gh_physx5.actor_update_mass (
actor_id,
density
)
parameters
actor_id ID actor identifier
density REAL density
return values
none
code sample
gh_phys5.actor_update_mass(actor_id, density)
actor_wake_up
Wakes up an actor.
syntax
gh_physx5.actor_wake_up (
actor_id,
sleep_counter
)
parameters
actor_id ID PhysX actor identifier
sleep_counter REAL sleep counter
return values
none
code sample
gh_phys5.actor_wake_up(actor_id, 1)
syntax
ret = gh_physx5.check_results (
scene_id
)
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_phys5.run_simulation_step(scene_id, time_step)
can_run_sim = false
end
if (gh_phys5.check_results(scene_id) == 1) then
gh_phys5.fetch_results(scene_id)
can_run_sim = true
end
create_actor_box
Creates a box actor.
syntax
actor_id = gh_physx5.create_actor_box (
scene_id,
w, h, d,
px, py, pz,
density,
mat_id
)
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_phys5.create_actor_box(scene_id, 4, 4, 4, 0, 0, 0, density, mat_id)
create_actor_capsule
Creates a capsule actor.
syntax
actor_id = gh_physx5.create_actor_capsule (
scene_id,
radius,
half_height,
px, py, pz,
density,
mat_id
)
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_phys5.create_actor_capsule(scene_id, radius, half_height, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx5.create_actor_mesh (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id
)
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_phys5.create_actor_mesh(scene_id, mesh_id, 0, 0, 0, density, mat_id)
syntax
actor_id = gh_physx5.create_actor_mesh_v2 (
scene_id,
mesh_id,
px, py, pz,
density,
mat_id,
convex
)
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_phys5.create_actor_mesh_v2(scene_id, mesh_id, 0, 0, 0, density, mat_id, convex)
create_actor_plane
Creates a plane actor.
syntax
actor_id = gh_physx5.create_actor_plane (
scene_id,
nx, ny, nz, d,
mat_id
)
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_phys5.create_actor_plane(scene_id, 0, 1, 0, 0, mat_id)
create_actor_sphere
Creates a sphere actor.
syntax
actor_id = gh_physx5.create_actor_sphere (
scene_id,
radius,
px, py, pz,
density,
mat_id
)
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_phys5.create_actor_sphere(scene_id, 10, 0, 0, 0, density, mat_id)
syntax
mat_id = gh_physx5.create_material (
static_friction,
dynamic_friction,
resilience
)
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_phys5.create_material(0.5, 0.5, 0.5)
syntax
scene_id = gh_physx5.create_scene (
gpu_physx,
bounce_threshold_velocity
)
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_phys5.create_scene(1, bounce_threshold_velocity)
syntax
scene_id = gh_physx5.create_scene_broadphase_abp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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_phys5.create_scene_broadphase_abp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx5.create_scene_broadphase_gpu (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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_phys5.create_scene_broadphase_gpu(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
syntax
scene_id = gh_physx5.create_scene_broadphase_mbp (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization,
minX, minY, minZ,
maxX, maxY, maxZ
)
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_phys5.create_scene_broadphase_mbp(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization, minX, minY, minZ, maxX, maxY, maxZ)
syntax
scene_id = gh_physx5.create_scene_broadphase_sap (
bounce_threshold_velocity,
enable_ccd,
enable_contact_reporting,
enable_stabilization
)
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_phys5.create_scene_broadphase_sap(bounce_threshold_velocity, enable_ccd, enable_contact_reporting, enable_stabilization)
create_scene_set_solver_type
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_physx5.create_scene_set_solver_type (
solver_type
)
parameters
solver_type ENUM( physx_solver_type ) solver type
return values
none
code sample
gh_phys5.create_scene_set_solver_type(solver_type)
syntax
ret = gh_physx5.fetch_results (
scene_id
)
parameters
scene_id ID PhysX scene identifier
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.run_simulation_step(scene_id, time_step)
ret = gh_phys5.fetch_results(scene_id)
syntax
clock = gh_physx5.gpu_get_clock_frequency_khz()
parameters
none
return values
clock INTEGER clock speed in kHz
code sample
clock = gh_phys5.gpu_get_clock_frequency_khz()
syntax
name = gh_physx5.gpu_get_name()
parameters
none
return values
name STRING name of the GPU
code sample
gpu_name = gh_phys5.gpu_get_name()
syntax
num_sm = gh_physx5.gpu_get_num_multiprocessors()
parameters
none
return values
num_sm INTEGER number of SMs
code sample
gpu_sm = gh_phys5.gpu_get_num_multiprocessors()
syntax
size = gh_physx5.gpu_get_total_memory_size_mb()
parameters
none
return values
size INTEGER size of the memory in MB
code sample
size = gh_phys5.gpu_get_total_memory_size_mb()
syntax
ret = gh_physx5.gpu_is_supported()
parameters
none
return values
ret BOOLEAN supported: 1 (true) or 0 (false)
code sample
gpu_physx = gh_phys5.gpu_is_supported()
syntax
joint_id = gh_physx5.joint_create (
scene_id,
joint_type,
actor1_id,
x1, y1, z1,
pitch1, yaw1, roll1,
actor2_id,
x2, y2, z2,
pitch2, yaw2, roll2
)
parameters
scene_id ID PhysX scene identifier
joint_type ENUM( physx_joint_type ) 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_phys5.joint_create(scene_id, joint_type, actor1, x1, y1, z1, pitch1, yaw1, roll1, actor2, x2, y2, z2, pitch2, yaw2, roll2)
syntax
gh_physx5.joint_distance_set_distances (
joint_id,
min_distance, max_distance
)
parameters
joint_id ID PhysX joint identifier
min_distance, max_distance REAL min / max distance of the joint
return values
none
code sample
gh_phys5.joint_distance_set_distances(joint_id, min_distance, max_distance)
syntax
gh_physx5.joint_distance_set_spring (
joint_id,
spring_coef, damping_coef
)
parameters
joint_id ID PhysX joint identifier
spring_coef, damping_coef REAL spring parameters
return values
none
code sample
gh_phys5.joint_distance_set_spring(joint_id, spring_coef, damping_coef)
joint_kill
Kills a PhysX joint.
syntax
gh_physx5.joint_kill (
joint_id
)
parameters
joint_id ID PhysX joint identifier
return values
none
code sample
gh_phys5.joint_kill(joint_id)
syntax
gh_physx5.joint_prismatic_set_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_phys5.joint_prismatic_set_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx5.joint_revolute_set_angular_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance,
damping,
stiffness,
restitution,
bounce_threshold
)
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
none
code sample
gh_phys5.joint_revolute_set_angular_limits(joint_id, lower_limit, upper_limit, limit_contact_distance, damping, stiffness, restitution, bounce_threshold)
syntax
gh_physx5.joint_revolute_set_rotational_limits (
joint_id,
lower_limit, upper_limit,
limit_contact_distance
)
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
none
code sample
gh_phys5.joint_revolute_set_rotational_limits(joint_id, lower_limit, upper_limit, limit_contact_distance)
syntax
gh_physx5.joint_set_break_force (
joint_id,
force, torque
)
parameters
joint_id ID PhysX joint identifier
force, torque REAL force and torque
return values
none
code sample
gh_phys5.joint_set_break_force(joint_id, force, torque)
syntax
gh_physx5.joint_set_motor_params (
joint_id,
velocity, max_force,
drive_enabled, free_spin_enabled
)
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
none
code sample
gh_phys5.joint_set_motor_params(joint_id, velocity, max_force, drive_enabled, free_spin_enabled)
syntax
gh_physx5.joint_spherical_set_limit_cone (
joint_id,
y_limit_angle, z_limit_angle, limit_contact_distance
)
parameters
joint_id ID PhysX joint identifier
y_limit_angle, z_limit_angle, limit_contact_distance REAL parameters
return values
none
code sample
gh_phys5.joint_spherical_set_limit_cone(joint_id, y_limit_angle, z_limit_angle, limit_contact_distance)
kill_material
Destroys a material.
syntax
gh_physx5.kill_material (
mat_id
)
parameters
mat_id ID material identifier
return values
none
code sample
gh_phys5.kill_material(mat_id)
syntax
ret = gh_physx5.run_simulation (
scene_id,
dt,
time_step
)
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_phys5.run_simulation(scene_id, dt, time_step)
run_simulation_step
Runs a simulation step.
syntax
ret = gh_physx5.run_simulation_step (
scene_id,
time_step
)
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_phys5.run_simulation_step(scene_id, time_step)
syntax
n = gh_physx5.scene_get_num_active_actors (
scene_id
)
parameters
scene_id ID scene identifier
return values
n INTEGER number of active actors
code sample
n = gh_phys5.scene_get_num_active_actors(scene_id)
syntax
gh_physx5.scene_sync_3d_objects (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_phys5.scene_sync_3d_objects(scene_id)
scene_sync_3d_objects_v2
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_physx5.scene_sync_3d_objects_v2 (
scene_id
)
parameters
scene_id ID scene identifier
return values
none
code sample
gh_phys5.scene_sync_3d_objects_v2(scene_id)
syntax
gh_physx5.set_max_depenetration_velocity (
velocity
)
parameters
velocity REAL depenetration velocity
return values
none
code sample
velocity = 3.0
gh_phys5.set_max_depenetration_velocity(velocity)
...
actor_box = gh_phys5.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
syntax
gh_physx5.set_scene_gravity (
scene_id,
x, y, z
)
parameters
scene_id ID PhysX scene identifier
x, y, z REAL gravity vector
return values
none
code sample
gh_phys5.set_scene_gravity(scene_id, 0, -9.81, 0)
syntax
gh_physx5.set_simulation_scales (
size,
mass,
speed
)
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
none
code sample
gh_phys5.set_simulation_scales(1, 1000, 10)
syntax
gh_physx5.set_solver_iteration_counts (
position_iterations,
velocity_iterations
)
parameters
position_iterations INTEGER number of position iterations
velocity_iterations INTEGER number of velocity iterations
return values
none
code sample
position_iterations = 4
velocity_iterations = 1
gh_phys5.set_solver_iteration_counts(position_iterations, velocity_iterations)
...
actor_box = gh_phys5.create_actor_box(scene, 4, 4, 4, 0, 0, 0, density, mat_id)
start
Starts the PhysX engine.
syntax
ret = gh_physx5.start()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.start()
stop
Stops the PhysX engine.
syntax
ret = gh_physx5.stop()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
ret = gh_phys5.stop()
syntax
gh_physx5.update_material (
mat_id,
static_friction,
dynamic_friction,
resilience
)
parameters
mat_id ID material identifier
static_friction REAL static friction
dynamic_friction REAL dynamic friction
resilience REAL resilience / restitution
return values
none
code sample
static_friction = 0.5
dynamic_friction = 0.5
resilience = 0.9
gh_phys5.update_material(mat_id, static_friction, dynamic_friction, resilience)