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_flex windowsnvidia
NVIDIA FleX module
gh_flex is the module that manages NVIDIA FleX engine.
Flex is a GPU-based particle simulation library designed for real-time applications.
It provides a unified interface that is capable of simulating fluids, clothing, solids, ropes, and more.
The FleX module requires a CUDA-capable GPU and is currently available on Windows only (the FleX plugin is also available on Linux but the plugin is not stable and then is not shipped yet with GeeXLab).
syntax
dev_name = gh_flex.get_compute_device_name()
parameters
none
return values
dev_name STRING device name
code sample
gpu = gh_flex.get_compute_device_name()
syntax
v = gh_flex.get_version()
parameters
none
return values
v INTEGER version
code sample
v = gh_flex.get_version()
syntax
gh_flex.make_phase (
group,
particle_flags,
shape_channels
)
parameters
group INTEGER particle group
particle_flags ENUM( flex_particle_flags ) flags
shape_channels ENUM( flex_particle_flags ) channels for collisions
return values
none
code sample
-- Flags / options
--
eNvFlexPhaseSelfCollide = 1048576 -- If set this particle will interact with particles of the same group
eNvFlexPhaseSelfCollideFilter = 2097152 -- If set this particle will ignore collisions with particles closer than the radius in the rest pose, this flag should not be specified unless valid rest positions have been specified using NvFlexSetRestParticles()
eNvFlexPhaseFluid = 4194304 -- If set this particle will generate fluid density constraints for its overlapping neighbors
eNvFlexPhaseGroupMask = 1048575 -- Bits [ 0, 19] represent the particle group for controlling collisions
eNvFlexPhaseFlagsMask = 15728640 -- Bits [20, 23] hold flags about how the particle behave
eNvFlexPhaseShapeChannelMask = 2130706432 -- Bits [24, 30] hold flags representing what shape collision channels particles will collide with, see NvFlexMakeShapeFlags() (highest bit reserved for now)
eNvFlexPhaseShapeChannel0 = 16777216 -- Particle will collide with shapes
with channel 0 set (see NvFlexMakeShapeFlags())
eNvFlexPhaseShapeChannel1 = 33554432
group = 0
particle_flags = eNvFlexPhaseSelfCollide
shape_channels = eNvFlexPhaseShapeChannelMask
phase = gh_flex.make_phase(group, particle_flags, shape_channels)
syntax
gh_flex.particles_copy_position_to_vb_fast (
particles_id,
vb_id,
num_particles
)
parameters
particles_id ID particle set identifier
vb_id ID rendering vertex buffer identifier
num_particles INTEGER number of particles
return values
none
code sample
gh_flex.particles_copy_position_to_vb_fast(particles_id, vb_id, num_vertices)
syntax
gh_flex.particles_copy_to_vb (
particles_id,
particle_attrib,
vb_id,
num_particles,
vb_start_offset_bytes,
vb_position_stride_bytes,
update_color_alpha,
dt
)
parameters
particles_id ID particle set identifier
particle_attrib ENUM( flex_particle_attrib_name ) particle attribute
vb_id ID rendering vertex buffer identifier
num_particles INTEGER number of particles
vb_start_offset_bytes INTEGER start offset in bytes in the vertex buffer
vb_position_stride_bytes INTEGER size of a vertex in bytes in the vertex buffer. In code samples, the vertex is {vec4 position + vec4 color}. The size is then 32 bytes.
update_color_alpha BOOLEAN updates the alpha value of the color by decreasing it with time step (alpha = alpha - dt): 1 (true) or 0 (false)
dt REAL time step for updating the alpha value
return values
none
code sample
local vb_start_offset_bytes = 0
local vb_position_stride_bytes = 32
local update_color_alpha = 0
local dt = 0.016
gh_flex.particles_copy_to_vb(particles_id, "position", vb_id, num_vertices, vb_start_offset_bytes, vb_position_stride_bytes, update_color_alpha, dt)
-- particles_copy_to_vb() replaces the following code:
--
--[[
function point(buffer_ptr, index, x, y, z, r, g, b, a)
-- Position
local buffer_offset_bytes = index * vertex_size
gh_utils.buffer_write_4f(buffer_ptr, buffer_offset_bytes, x, y, z, 1.0)
-- Color
buffer_offset_bytes = buffer_offset_bytes + attrib_size
gh_utils.buffer_write_4f(buffer_ptr, buffer_offset_bytes, r, g, b, a)
end
gh_flex.particles_map_position(particles_id)
vb_buffer_ptr, bufsize = gh_vb.map(vb_id, "GL_WRITE_ONLY")
for i = 0, num_vertices - 1 do
x, y, z, w = gh_flex.particles_get_position(particles_id, i)
local alpha = particles[i+1].a
if (update_color_alpha == 1) then
alpha = alpha - dt
if (alpha < 0) then
alpha = 0
end
end
particles[i+1].a = alpha
point(vb_buffer_ptr, i, x, y, z, 1, 1, 1, alpha)
end
gh_vb.unmap(vb_id)
gh_flex.particles_unmap_position(particles_id)
--]]
syntax
particles_id = gh_flex.particles_create (
num_particles
)
parameters
num_particles INTEGER number of particles in the set
return values
particles_id ID particle set identifier
code sample
num_particles = 1000
particles_id = gh_flex.particles_create(num_particles)
syntax
phase = gh_flex.particles_get_phase (
particles_id,
particle_index
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
return values
phase INTEGER value of the phase
code sample
phase = gh_flex.particles_get_phase(particles_id, particle_index)
syntax
x, y, z, w = gh_flex.particles_get_position (
particles_id,
particle_index
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
return values
x, y, z, w REAL 3D position
code sample
x, y, z, w = gh_flex.particles_get_position(particles_id, particle_index)
syntax
x, y, z = gh_flex.particles_get_velocity (
particles_id,
particle_index
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
return values
x, y, z REAL velocity vector
code sample
x, y, z = gh_flex.particles_get_velocity(particles_id, index)
syntax
gh_flex.particles_kill (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_kill(particles_id)
syntax
gh_flex.particles_map_active_indices (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_map_active_indices(particles_id)
syntax
gh_flex.particles_map_phase (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_map_phase(particles_id)
syntax
gh_flex.particles_map_position (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_map_position(particles_id)
syntax
gh_flex.particles_map_velocity (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_map_velocity(particles_id)
syntax
gh_flex.particles_set_active_index (
particles_id,
index,
particle_index
)
parameters
particles_id ID particle set identifier
index INTEGER index in the active buffer
particle_index INTEGER particle index
return values
none
code sample
-- All the following code can be replaced by one call to particles_update_active()
-- Usually particles_set_active_index() is used as follows:
--
gh_flex.particles_map_active_indices(particles_id)
for i = 0, num_particles - 1 do
gh_flex.particles_set_active_index(particles_id, i, i)
end
gh_flex.particles_unmap_active_indices(particles_id)
gh_flex.particles_set_num_active_indices(particles_id, num_particles)
-- Upload to GPU
gh_flex.solver_write_particles(solver_id, particles_id)
syntax
gh_flex.particles_set_num_active_indices (
particles_id,
num_active
)
parameters
particles_id ID particle set identifier
num_active INTEGER number of active particles
return values
none
code sample
gh_flex.particles_set_num_active_indices(particles_id, num_active)
syntax
gh_flex.particles_set_phase (
particles_id,
particle_index,
phase
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
phase INTEGER particle phase
return values
none
code sample
gh_flex.particles_map_position(particles_id)
gh_flex.particles_map_velocity(particles_id)
gh_flex.particles_map_phase(particles_id)
phase = gh_flex.make_phase(...)
for i = 0, num_particles - 1 do
x = random(...)
y = random(...)
z = random(...)
-- Mass = 1.0
w = 1.0
gh_flex.particles_set_position(particles_id, i, x, y, z, w)
-- Initial velocity is zero
gh_flex.particles_set_velocity(particles_id, i, 0.0, 0.0, 0.0)
gh_flex.particles_set_phase(particles_id, i, phase)
end
gh_flex.particles_unmap_phase(particles_id)
gh_flex.particles_unmap_velocity(particles_id)
gh_flex.particles_unmap_position(particles_id)
-- Upload to GPU
gh_flex.solver_write_particles(solver_id, particles_id)
syntax
gh_flex.particles_set_position (
particles_id,
particle_index,
x, y, z, w
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
x, y, z, w REAL particle position - w holds the inverse of the mass: w=1.0/mass.
return values
none
code sample
gh_flex.particles_map_position(particles_id)
for i = 0, num_particles - 1 do
x = random(...)
y = random(...)
z = random(...)
-- Mass = 1.0
w = 1.0
gh_flex.particles_set_position(particles_id, i, x, y, z, w)
end
gh_flex.particles_unmap_position(particles_id)
-- Upload to GPU
gh_flex.solver_write_particles(solver_id, particles_id)
syntax
gh_flex.particles_set_velocity (
particles_id,
particle_index,
x, y, z
)
parameters
particles_id ID particle set identifier
particle_index INTEGER particle index
x, y, z REAL particle velocity
return values
none
code sample
gh_flex.particles_map_position(particles_id)
gh_flex.particles_map_velocity(particles_id)
for i = 0, num_particles - 1 do
x = random(...)
y = random(...)
z = random(...)
-- Mass = 1.0
w = 1.0
gh_flex.particles_set_position(particles_id, i, x, y, z, w)
-- Initial velocity is zero.
gh_flex.particles_set_velocity(particles_id, i, 0.0, 0.0, 0.0)
end
gh_flex.particles_unmap_velocity(particles_id)
gh_flex.particles_unmap_position(particles_id)
-- Upload to GPU
gh_flex.solver_write_particles(solver_id, particles_id)
syntax
gh_flex.particles_unmap_active_indices (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_unmap_active_indices(particles_id)
syntax
gh_flex.particles_unmap_phase (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_unmap_phase(particles_id)
syntax
gh_flex.particles_unmap_position (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_unmap_position(particles_id)
syntax
gh_flex.particles_unmap_velocity (
particles_id
)
parameters
particles_id ID particle set identifier
return values
none
code sample
gh_flex.particles_unmap_velocity(particles_id)
syntax
gh_flex.particles_update_active (
particles_id,
num_active_particles
)
parameters
particles_id ID particle set identifier
num_active_particles INTEGER number of active particles
return values
none
code sample
gh_flex.particles_update_active(particles_id, num_active_particles)
-- particles_update_active() replaces the following code:
--
--[[
gh_flex.particles_set_num_active_indices(particles_id, num_vertices)
gh_flex.particles_map_active_indices(particles_id)
for i = 0, num_vertices - 1 do
gh_flex.particles_set_active_index(particles_id, i, i)
end
gh_flex.particles_unmap_active_indices(particles_id)
--]]
syntax
gh_flex.set_device_index (
i
)
parameters
i INTEGER device index
return values
none
code sample
gh_flex.set_device_index(-1)
syntax
shapes_id = gh_flex.shapes_create (
num_shapes
)
parameters
num_shapes INTEGER number of shapes in the set
return values
shapes_id ID shapes set identifier
code sample
num_shapes = 2
shapes_id = gh_flex.shapes_create(num_shapes)
syntax
gh_flex.shapes_kill (
shapes_id
)
parameters
shapes_id ID shapes set identifier
return values
none
code sample
gh_flex.shapes_kill(shapes_id)
syntax
gh_flex.shapes_map (
shapes_id
)
parameters
shapes_id ID shapes set identifier
return values
none
code sample
gh_flex.shapes_map(shapes_id)
syntax
gh_flex.shapes_set_box (
shapes_id,
shape_index,
shape_channels,
width, height, depth,
x, y, z,
qx, qy, qz, qw
)
parameters
shapes_id ID shapes set identifier
shape_index INTEGER index of the shape between 0 ; num_shapes-1
shape_channels ENUM( flex_particle_flags ) channels for collisions
width, height, depth REAL box size
x, y, z REAL box position
qx, qy, qz, qw REAL box orientation (quaternion)
return values
none
code sample
gh_flex.shapes_map(shapes_id)
shape_index = 0
shape_channels = eNvFlexPhaseShapeChannel0
width = 2.0
height = 2.0
depth = 2.0
gh_flex.shapes_set_box(shapes_id, shape_index, shape_channels, width, height, depth, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0)
gh_flex.shapes_unmap(shapes_id)
syntax
gh_flex.shapes_set_box_v2 (
shapes_id,
shape_index,
shape_channels,
width, height, depth,
x, y, z,
pitch, yaw, roll
)
parameters
shapes_id ID shapes set identifier
shape_index INTEGER index of the shape between 0 ; num_shapes-1
shape_channels ENUM( flex_particle_flags ) channels for collisions
width, height, depth REAL box size
x, y, z REAL box position
pitch, yaw, roll REAL box orientation (Euler's angles)
return values
none
code sample
gh_flex.shapes_map(shapes_id)
shape_index = 0
shape_channels = eNvFlexPhaseShapeChannel0
width = 2.0
height = 2.0
depth = 2.0
gh_flex.shapes_set_box_v2(shapes_id, shape_index, shape_channels, width, height, depth, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0)
gh_flex.shapes_unmap(shapes_id)
syntax
gh_flex.shapes_set_mesh (
shapes_id,
shape_index,
shape_channels,
mesh_id,
x, y, z,
qx, qy, qz, qw
)
parameters
shapes_id ID shapes set identifier
shape_index INTEGER index of the shape between 0 ; num_shapes-1
shape_channels ENUM( flex_particle_flags ) channels for collisions
mesh_id ID mesh identifier
x, y, z REAL mesh position
qx, qy, qz, qw REAL mesh orientation (quaternion)
return values
none
code sample
gh_flex.shapes_map(shapes_id)
shape_index = 0
shape_channels = eNvFlexPhaseShapeChannel0
mesh_id = gh_mesh.create_torus(2.0, 0.4, 20)
gh_flex.shapes_set_mesh(shapes_id, shape_index, shape_channels, mesh_id, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0)
gh_flex.shapes_unmap(shapes_id)
syntax
gh_flex.shapes_set_mesh_v2 (
shapes_id,
shape_index,
shape_channels,
mesh_id,
x, y, z,
pitch, yaw, roll
)
parameters
shapes_id ID shapes set identifier
shape_index INTEGER index of the shape between 0 ; num_shapes-1
shape_channels ENUM( flex_particle_flags ) channels for collisions
mesh_id ID mesh identifier
x, y, z REAL mesh position
pitch, yaw, roll REAL box orientation (Euler's angles)
return values
none
code sample
gh_flex.shapes_map(shapes_id)
shape_index = 0
shape_channels = eNvFlexPhaseShapeChannel0
mesh_id = gh_mesh.create_torus(2.0, 0.4, 20)
gh_flex.shapes_set_mesh_v2(shapes_id, shape_index, shape_channels, mesh_id, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0)
gh_flex.shapes_unmap(shapes_id)
syntax
gh_flex.shapes_set_sphere (
shapes_id,
shape_index,
shape_channels,
radius,
x, y, z
)
parameters
shapes_id ID shapes set identifier
shape_index INTEGER index of the shape between 0 ; num_shapes-1
shape_channels ENUM( flex_particle_flags ) channels for collisions
radius REAL sphere radius
x, y, z REAL sphere position
return values
none
code sample
gh_flex.shapes_map(shapes_id)
shape_index = 0
shape_channels = eNvFlexPhaseShapeChannel0
radius = 2.0
gh_flex.shapes_set_sphere(shapes_id, shape_index, shape_channels, radius, 0.0, 3.0, 0.0)
gh_flex.shapes_unmap(shapes_id)
syntax
gh_flex.shapes_unmap (
shapes_id
)
parameters
shapes_id ID shapes set identifier
return values
none
code sample
gh_flex.shapes_unmap(shapes_id)
solver_create
Creates a FleX solver.
syntax
solver_id = gh_flex.solver_create (
max_particles
)
parameters
max_particles INTEGER max number of particles managed by the solver
return values
solver_id ID solver identifier
code sample
max_particles = 1000
solver_id = gh_flex.solver_create(max_particles)
solver_kill
Destroys a FleX solver.
syntax
gh_flex.solver_kill (
solver_id
)
parameters
solver_id ID solver identifier
return values
none
code sample
gh_flex.solver_kill(solver_id)
syntax
gh_flex.solver_set_num_active_particles (
solver_id,
num_active_particles
)
parameters
solver_id ID solver identifier
num_active_particles INTEGER shapes identifier
return values
none
code sample
gh_flex.solver_set_num_active_particles(solver_id, num_active_particles)
solver_set_param_1f
Set a solver parameter.
syntax
gh_flex.solver_set_param_1f (
solver_id,
param_name,
x
)
parameters
solver_id ID solver identifier
param_name ENUM( flex_solver_param_1f ) param name
x REAL value
return values
none
code sample
params = [[
float radius; //!< The maximum interaction radius for particles
float solidRestDistance; //!< The distance non-fluid particles attempt to maintain from each other, must be in the range (0, radius]
float fluidRestDistance; //!< The distance fluid particles are spaced at the rest density, must be in the range (0, radius], for fluids this should generally be 50-70% of mRadius, for rigids this can simply be the same as the particle radius
// common params
float dynamicFriction; //!< Coefficient of friction used when colliding against shapes
float staticFriction; //!< Coefficient of static friction used when colliding against shapes
float particleFriction; //!< Coefficient of friction used when colliding particles
float restitution; //!< Coefficient of restitution used when colliding against shapes, particle collisions are always inelastic
float adhesion; //!< Controls how strongly particles stick to surfaces they hit, default 0.0, range [0.0, +inf]
float sleepThreshold; //!< Particles with a velocity magnitude < this threshold will be considered fixed
float maxSpeed; //!< The magnitude of particle velocity will be clamped to this value at the end of each step
float maxAcceleration; //!< The magnitude of particle acceleration will be clamped to this value at the end of each step (limits max velocity change per-second), useful to avoid popping due to large interpenetrations
float shockPropagation; //!< Artificially decrease the mass of particles based on height from a fixed reference point, this makes stacks and piles converge faster
float dissipation; //!< Damps particle velocity based on how many particle contacts it has
float damping; //!< Viscous drag force, applies a force proportional, and opposite to the particle velocity
// cloth params
float drag; //!< Drag force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in the negative velocity direction
float lift; //!< Lift force applied to particles belonging to dynamic triangles, proportional to velocity^2*area in the direction perpendicular to velocity and (if possible), parallel to the plane normal
// fluid params
float cohesion; //!< Control how strongly particles hold each other together, default: 0.025, range [0.0, +inf]
float surfaceTension; //!< Controls how strongly particles attempt to minimize surface area, default: 0.0, range: [0.0, +inf]
float viscosity; //!< Smoothes particle velocities using XSPH viscosity
float vorticityConfinement; //!< Increases vorticity by applying rotational forces to particles
float anisotropyScale; //!< Control how much anisotropy is present in resulting ellipsoids for rendering, if zero then anisotropy will not be calculated, see NvFlexGetAnisotropy()
float anisotropyMin; //!< Clamp the anisotropy scale to this fraction of the radius
float anisotropyMax; //!< Clamp the anisotropy scale to this fraction of the radius
float smoothing; //!< Control the strength of Laplacian smoothing in particles for rendering, if zero then smoothed positions will not be calculated, see NvFlexGetSmoothParticles()
float solidPressure; //!< Add pressure from solid surfaces to particles
float freeSurfaceDrag; //!< Drag force applied to boundary fluid particles
float buoyancy; //!< Gravity is scaled by this value for fluid particles
// diffuse params
float diffuseThreshold; //!< Particles with kinetic energy + divergence above this threshold will spawn new diffuse particles
float diffuseBuoyancy; //!< Scales force opposing gravity that diffuse particles receive
float diffuseDrag; //!< Scales force diffuse particles receive in direction of neighbor fluid particles
float diffuseLifetime; //!< Time in seconds that a diffuse particle will live for after being spawned, particles will be spawned with a random lifetime in the range [0, diffuseLifetime]
// collision params
float collisionDistance; //!< Distance particles maintain against shapes, note that for robust collision against triangle meshes this distance should be greater than zero
float particleCollisionMargin; //!< Increases the radius used during neighbor finding, this is useful if particles are expected to move significantly during a single step to ensure contacts aren't missed on subsequent iterations
float shapeCollisionMargin; //!< Increases the radius used during contact finding against kinematic shapes
float relaxationFactor; //!< Control the convergence rate of the parallel solver, default: 1, values greater than 1 may lead to instability
]]
gh_flex.solver_set_param_1f(solver_id, "radius", 0.1)
gh_flex.solver_set_param_1f(solver_id, "dynamicFriction", 0.15)
solver_set_param_1i
Set a solver parameter.
syntax
gh_flex.solver_set_param_1i (
solver_id,
param_name,
x
)
parameters
solver_id ID solver identifier
param_name ENUM( flex_solver_param_1i ) param name
x INTEGER value
return values
none
code sample
params = [[
int numIterations; //!< Number of solver iterations to perform per-substep
int diffuseBallistic; //!< The number of neighbors below which a diffuse particle is considered ballistic
int numPlanes; //!< Num collision planes
]]
gh_flex.solver_set_param_1i(solver_id, "numIterations", 2)
solver_set_param_3f
Set a solver parameter.
syntax
gh_flex.solver_set_param_3f (
solver_id,
param_name,
x, y, z
)
parameters
solver_id ID solver identifier
param_name ENUM( flex_solver_param_3f ) param name
x, y, z REAL value
return values
none
code sample
params = [[
float gravity[3]; //!< Constant acceleration applied to all particles
// cloth params
float wind[3]; //!< Constant acceleration applied to particles that belong to dynamic triangles, drag needs to be > 0 for wind to affect triangles
]]
gh_flex.solver_set_param_1f(solver_id, "gravity", 0.0, -10.0, 0.0)
syntax
gh_flex.solver_set_param_collision_plane (
solver_id,
plane_index,
a, b, c, d
)
parameters
solver_id ID solver identifier
plane_index INTEGER index of the plane: 0 to 7 (8 planes)
a, b, c, d REAL plane equation: ax + by + cz + d = 0
return values
none
code sample
gh_flex.solver_set_param_1i(solver_id, "numPlanes", 1)
plane_index = 0
gh_flex.solver_set_param_collision_plane(solver_id, plane_index, 0.0, 1.0, 0.0, 0.0)
syntax
gh_flex.solver_update (
solver_id,
dt,
substeps
)
parameters
solver_id ID solver identifier
dt REAL time step
substeps INTEGER number of simulation substeps
return values
none
code sample
substeps = 2
gh_flex.solver_update(solver_id, dt, substeps)
syntax
gh_flex.solver_update_params (
solver_id
)
parameters
solver_id ID solver identifier
return values
none
code sample
gh_flex.solver_update_params(solver_id)
syntax
gh_flex.solver_write_particles (
solver_id,
particles_id
)
parameters
solver_id ID solver identifier
particles_id ID particles identifier
return values
none
code sample
num_particles = 1000
particles_id = gh_flex.particles_create(num_particles)
...
gh_flex.solver_write_particles(solver_id, particles_id)
syntax
gh_flex.solver_write_shapes (
solver_id,
shapes_id
)
parameters
solver_id ID solver identifier
shapes_id ID shapes identifier
return values
none
code sample
num_shapes = 2
shapes_id = gh_flex.shapes_create(num_shapes)
...
gh_flex.solver_write_shapes(solver_id, shapes_id)
syntax
state = gh_flex.start()
parameters
none
return values
state BOOLEAN 1 (success) or 0 (error)
code sample
flex_ok = gh_flex.start()
if (flex_ok == 0) then
-- error
end
syntax
state = gh_flex.stop()
parameters
none
return values
state BOOLEAN 1 (success) or 0 (error)
code sample
state = gh_flex.stop()
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.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()
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()
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)
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)
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_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)
implot_set_built_in_colormap
Sets a built-in colormap
syntax
gh_imgui.implot_set_built_in_colormap (
colormap_index,
samples
)
parameters
colormap_index INTEGER colormap index/identifier.
samples INTEGER number of samples.
return values
none
code sample
ImPlotColormap_Default = 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
gh_imgui.implot_set_built_in_colormap(ImPlotColormap_Hot, 5)
...
gh_imgui.implot_set_built_in_colormap(ImPlotColormap_Default, 0)
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
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()
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 (
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
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
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)
syntax
gh_object.add_material (
mesh_id,
mat_id
)
parameters
mesh_id ID mesh identifier
mat_id ID material identifier
return values
none
code sample
gh_object.add_material(mesh_id, mat_id)
syntax
gh_object.average_vertices_normal (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.average_vertices_normal(mesh_id)
syntax
gh_object.compute_faces_normal (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.compute_faces_normal(mesh_id)
syntax
gh_object.compute_vertices_normal (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.compute_vertices_normal(mesh_id)
syntax
gh_object.copy_transform (
dst_obj_id,
src_obj_id
)
parameters
dst_obj_id ID destination object identifier
src_obj_id ID source object identifier
return values
none
code sample
gh_object.copy_transform(dst, src)
syntax
object_id = gh_object.create()
parameters
none
return values
object_id ID object identifier
code sample
gizmo = gh_object.create()
syntax
gh_object.flip_faces (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.flip_faces(mesh_id)
syntax
gh_object.flip_vertex_normals (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.flip_vertex_normals(mesh_id)
syntax
x, y, z, w = gh_object.get_absolute_orientation (
obj_id
)
parameters
obj_id ID object identifier
return values
x, y, z, w REAL absolute orientation quaternion
code sample
x, y, z, w = gh_object.get_absolute_orientation(obj_id)
syntax
pitch, yaw, roll = gh_object.get_absolute_orientation_euler_angles (
obj_id
)
parameters
obj_id ID object identifier
return values
pitch, yaw, roll REAL Euler's angles
code sample
pitch, yaw, roll = gh_object.get_absolute_orientation_euler_angles(obj_id)
syntax
x,y,z = gh_object.get_absolute_orientation_vector_z (
obj_id
)
parameters
obj_id ID object identifier
return values
x,y,z REAL Z axis of the absolute orientation
code sample
x,y,z = gh_object.get_absolute_orientation_vector_z(obj_id)
syntax
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_absolute_orientation_vectors (
obj_id
)
parameters
obj_id ID object identifier
return values
x0,y0,z0, x1,y1,z1, x2,y2,z2 REAL Axis of the absolute orientation
code sample
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_absolute_orientation_vectors(obj_id)
syntax
x, y, z = gh_object.get_absolute_position (
obj_id
)
parameters
obj_id ID object identifier
return values
x, y, z REAL 3D position
code sample
x, y, z = gh_object.get_absolute_position(obj_id)
syntax
dist = gh_object.get_distance (
obj1_id,
obj2_id
)
parameters
obj1_id ID object 1 identifier
obj2_id ID object 2 identifier
return values
dist REAL distance
code sample
dist = gh_object.get_distance(object1_id, object2_id)
syntax
mat_id = gh_object.get_material (
mesh_id,
material_index
)
parameters
mesh_id ID mesh identifier
material_index INTEGER material index
return values
mat_id ID material identifier
code sample
mat_id = gh_object.get_material(mesh_id, 0)
syntax
num_faces = gh_object.get_num_faces (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
num_faces INTEGER number of faces
code sample
num_faces = gh_object.get_num_faces(mesh_id)
syntax
num_faces = gh_object.get_num_faces_v2 (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
num_faces INTEGER number of faces
code sample
num_faces = gh_object.get_num_faces_v2(mesh_id)
syntax
num_materials = gh_object.get_num_materials (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
num_materials INTEGER number of materials
code sample
num_materials = gh_object.get_num_materials(mesh_id)
syntax
num_vertices = gh_object.get_num_vertices (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
num_vertices INTEGER number of vertices
code sample
num_vertices = gh_object.get_num_vertices(mesh_id)
syntax
num_vertices = gh_object.get_num_vertices_v2 (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
num_vertices INTEGER number of vertices
code sample
num_vertices = gh_object.get_num_vertices_v2(mesh_id)
syntax
x, y, z, w = gh_object.get_orientation (
obj_id
)
parameters
obj_id ID object identifier
return values
x, y, z, w REAL absolute orientation quaternion
code sample
x, y, z, w = gh_object.get_orientation(obj_id)
syntax
pitch, yaw, roll = gh_object.get_orientation_euler_angles (
obj_id
)
parameters
obj_id ID object identifier
return values
pitch, yaw, roll REAL Euler's angles
code sample
pitch, yaw, roll = gh_object.get_orientation_euler_angles(obj_id)
syntax
x,y,z = gh_object.get_orientation_vector_z (
obj_id
)
parameters
obj_id ID object identifier
return values
x,y,z REAL Z axis of the relative orientation
code sample
x,y,z = gh_object.get_orientation_vector_z(obj_id)
syntax
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_orientation_vectors (
obj_id
)
parameters
obj_id ID object identifier
return values
x0,y0,z0, x1,y1,z1, x2,y2,z2 REAL Axis of the relative orientation
code sample
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_orientation_vectors(obj_id)
syntax
a, b, c, d = gh_object.get_plane_equation (
obj_id
)
parameters
obj_id ID object identifier
return values
a, b, c, d REAL plane equation
code sample
a, b, c, d = gh_object.get_plane_equation(obj_id)
syntax
x, y, z = gh_object.get_position (
obj_id
)
parameters
obj_id ID object identifier
return values
x, y, z REAL 3D position
code sample
x, y, z = gh_object.get_position(obj_id)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_object.get_transform (
obj_id
)
parameters
obj_id ID object identifier
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the transformation matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_object.get_transform(obj_id)
syntax
gh_object.remove_all_materials (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.remove_all_materials(mesh_id)
syntax
gh_object.remove_material (
mesh_id,
mat_id
)
parameters
mesh_id ID mesh identifier
mat_id ID material identifier
return values
none
code sample
gh_object.remove_material(mesh_id, mat_id)
render
Renders an object.
syntax
gh_object.render (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_camera.bind(cam_id)
gh_gpu_program.bind(gpuprog_id)
gh_object.render(mesh_id)
syntax
gh_object.render_geometry (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_texture.bind(tex_id, 0)
gh_object.update_automatic_uniforms(mesh_plane)
gh_object.render_geometry(mesh_plane)
render_geometry_draw
Draws the geometry.
syntax
gh_object.render_geometry_draw (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_texture.bind(tex_id, 0)
gh_object.update_automatic_uniforms(mesh_plane)
gh_object.render_geometry_prepare(mesh_plane)
gh_object.render_geometry_draw(mesh_plane)
gh_object.render_geometry_finish(mesh_plane)
syntax
gh_object.render_geometry_finish (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_texture.bind(tex_id, 0)
gh_object.update_automatic_uniforms(mesh_plane)
gh_object.render_geometry_prepare(mesh_plane)
gh_object.render_geometry_draw(mesh_plane)
gh_object.render_geometry_finish(mesh_plane)
syntax
gh_object.render_geometry_prepare (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_texture.bind(tex_id, 0)
gh_object.update_automatic_uniforms(mesh_plane)
gh_object.render_geometry_prepare(mesh_plane)
gh_object.render_geometry_draw(mesh_plane)
gh_object.render_geometry_finish(mesh_plane)
syntax
gh_object.rotate_vertices_position (
mesh_id,
x, y, z, w
)
parameters
mesh_id ID mesh identifier
x, y, z, w REAL quaternion
return values
none
code sample
gh_object.rotate_vertices_position(mesh_id, x, y, z, w)
syntax
gh_object.rotate_vertices_position_euler_xyz (
mesh_id,
pitch, yaw, roll
)
parameters
mesh_id ID mesh identifier
pitch, yaw, roll REAL Euler's angles
return values
none
code sample
gh_object.rotate_vertices_position_euler_xyz(mesh_id, pitch, yaw, roll)
syntax
gh_object.scale_vertices_position (
mesh_id,
x, y, z
)
parameters
mesh_id ID mesh identifier
x, y, z REAL scaling vector
return values
none
code sample
gh_object.scale_vertices_position(mesh_id, x, y, z)
syntax
gh_object.set_absolute_transform_update_mode (
obj_id,
transform_mode
)
parameters
obj_id ID object identifier
transform_mode ENUM( transform_mode ) order of internal transformation: default 0 (parent * object) or 1 (object * parent)
return values
none
code sample
-- transform_mode
parent_object = 0 -- default: parent * object
object_parent = 1 -- object * parent
mode = object_parent
gh_object.set_absolute_transform_update_mode(obj_id, mode)
syntax
gh_object.set_automatic_uniform_state (
obj_id,
state,
uniform_type
)
parameters
obj_id ID object identifier
state BOOLEAN 1 (enabled) or 0 (disabled)
uniform_type STRING currently only 'camera'
return values
none
code sample
gh_object.set_automatic_uniform_state(obj_id, state, "camera")
syntax
gh_object.set_euler_angles (
obj_id,
pitch, yaw, roll
)
parameters
obj_id ID object identifier
pitch, yaw, roll REAL Euler's angles
return values
none
code sample
gh_object.set_euler_angles(obj_id, pitch, yaw, roll)
syntax
gh_object.set_materials_texture_unit_offset (
mesh_id,
offset
)
parameters
mesh_id ID mesh identifier
offset INTEGER texture unit offset
return values
none
code sample
offset = 1
gh_object.set_materials_texture_unit_offset(mesh_id, offset)
syntax
gh_object.set_orientation (
obj_id,
x, y, z, w
)
parameters
obj_id ID object identifier
x, y, z, w REAL orientation quaternion
return values
none
code sample
q = {x=0, y=0, z=0, w=1}
gh_object.set_orientation(obj_id, q.x, q.y, q.z, q.w)
syntax
gh_object.set_position (
obj_id,
x, y, z
)
parameters
obj_id ID object identifier
x, y, z REAL 3D position
return values
none
code sample
gh_object.set_position(obj_id, x, y, z)
syntax
gh_object.set_scale (
obj_id,
x, y, z
)
parameters
obj_id ID object identifier
x, y, z REAL 3D scaling factors
return values
none
code sample
gh_object.set_scale(obj_id, x, y, z)
syntax
gh_object.set_tessellation_state (
mesh_id,
tessellation
)
parameters
mesh_id ID mesh identifier
tessellation BOOLEAN tessellation enabled: 1 (true) or 0 (false)
return values
none
code sample
gh_object.set_tessellation_state(mesh_id, 1)
syntax
gh_object.set_transform (
obj_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
parameters
obj_id ID object identifier
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 REAL the transformation matrix
return values
none
code sample
gh_object.set_transform(obj_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
syntax
gh_object.set_transform_order (
obj_id,
transform_order
)
parameters
obj_id ID object identifier
transform_order ENUM( transform_order ) order of internal transformation: default 0 (translation, rotation, scale), 1 (rotation, translation, scale), 2 and 3
return values
none
code sample
gh_object.set_transform_order(obj_id, 1)
syntax
gh_object.set_vertices_color (
mesh_id,
r, g, b, a
)
parameters
mesh_id ID mesh identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_object.set_vertices_color(mesh_id, r, g, b, a)
syntax
gh_object.smooth_vertices_normal (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_object.smooth_vertices_normal(mesh_id)
syntax
gh_object.transform_update_scale (
obj_id,
x, y, z
)
parameters
obj_id ID object identifier
x, y, z REAL 3D scaling factors.
return values
none
code sample
gh_object.transform_update_scale(obj_id, x, y, z)
syntax
gh_object.translate_vertices_position (
mesh_id,
x, y, z
)
parameters
mesh_id ID mesh identifier
x, y, z REAL translation vector
return values
none
code sample
gh_object.translate_vertices_position(mesh_id, x, y, z)
update_automatic_uniforms
Updates automatic uniforms that are sent to any GLSL program.
These uniforms include: gxl3d_ProjectionMatrix, gxl3d_ViewMatrix, gxl3d_ViewProjectionMatrix, gxl3d_ModelProjectionMatrix and gxl3d_Viewport.
This function can be used with render_geometry() and render_geometry_xxx() functions.
syntax
gh_object.update_automatic_uniforms (
mesh_id
)
parameters
mesh_id ID mesh identifier
return values
none
code sample
gh_gpu_program.bind(gpuprog_id)
gh_texture.bind(tex_id, 0)
gh_object.update_automatic_uniforms(mesh_id)
gh_object.render_geometry(mesh_id)
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 bodiy 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_texture
Texture module
gh_texture is the module that manages textures: creation, destruction, parameters setting.
syntax
gh_texture.bind (
tex_id,
tex_unit
)
parameters
tex_id ID texture identifier
tex_unit INTEGER texture unit on which the texture is bound
return values
none
code sample
gh_texture.bind(tex_id, 0)
syntax
new_dst_tex_id = gh_texture.copy_sub_texture (
src_tex_id,
dst_tex_id,
x, y, width, height
)
parameters
src_tex_id ID source texture identifier
dst_tex_id ID destination texture identifier
x, y, width, height INTEGER start offset (x, y) and size of the sub texture
return values
new_dst_tex_id ID new texture identifier
code sample
new_dst_tex_id = gh_texture.copy_sub_texture(tex_src, tex_dst, 10, 10, 200, 200)
syntax
tex_id = gh_texture.create_1d (
width,
pf
)
parameters
width INTEGER texture size
pf ENUM( pixel_format ) pixel format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
tex_id = gh_texture.create_1d(256, PF_U8_RGBA)
syntax
tex_id = gh_texture.create_2d (
width, height,
pf
)
parameters
width, height INTEGER texture size
pf ENUM( pixel_format ) pixel format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
tex_id = gh_texture.create_2d(256, 256, PF_U8_RGBA)
syntax
tex_id = gh_texture.create_cube_from_file (
posx_img_filename,
negx_img_filename,
posy_img_filename,
negy_img_filename,
posz_img_filename,
negz_img_filename,
pf,
absolute_path,
gen_mipmaps
)
parameters
posx_img_filename STRING POS X image filename
negx_img_filename STRING NEG X image filename
posy_img_filename STRING POS Y image filename
negy_img_filename STRING NEG Y image filename
posz_img_filename STRING POS Z image filename
negz_img_filename STRING NEG Z image filename
pf ENUM( pixel_format ) pixel format
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local abs_path = 0
local gen_mipmaps = 1
tex_id = gh_texture.create_cube_from_file("posx.jpg", "negx.jpg", "posy.jpg", "negy.jpg", "posz.jpg", "negz.jpg", abs_path, PF_U8_RGBA, gen_mipmaps)
syntax
tex_id = gh_texture.create_from_buffer (
buff_ptr,
buff_size,
upload_to_gpu,
pf,
tex_unit,
gen_mipmaps,
compressed_format
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
upload_to_gpu BOOLEAN uploads the pixmap into GPU memory: 1 (true) or 0 (false)
pf ENUM( pixel_format ) pixel format
tex_unit INTEGER texture unit (for Direct3D 12 or Vulkan)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local upload_to_gpu = 1
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
filename = demo_dir .. "assets/image.jpg"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
tex_id = gh_texture.create_from_buffer(buffer, buffer_size, upload_to_gpu, PF_U8_RGBA, tex_unit, gen_mipmaps, compression_format)
gh_utils.file_buffer_kill(buffer)
syntax
tex_id = gh_texture.create_from_file (
filename,
pf,
absolute_path
)
parameters
filename STRING image filename
pf ENUM( pixel_format ) pixel format
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local abs_path = 0
tex_id = gh_texture.create_from_file("data/tex.jpg", PF_U8_RGBA, abs_path)
syntax
tex_id = gh_texture.create_from_file_v10 (
filename,
pf,
gen_mipmaps,
compressed_format,
free_cpu_memory
)
parameters
filename STRING absolute path of the image file
pf ENUM( pixel_format ) pixel format
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
free_cpu_memory BOOLEAN free CPU memory after uploading to GPU: 1 (true) or 0 (false)
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local free_gpu_memory = 0
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_file_v10(demo_dir .. "./data/tex.jpg", PF_U8_RGBA, gen_mipmaps, compression_format, free_gpu_memory)
syntax
tex_id = gh_texture.create_from_file_v2 (
filename,
pf,
absolute_path,
gen_mipmaps
)
parameters
filename STRING image filename
pf ENUM( pixel_format ) pixel format
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local abs_path = 0
local gen_mipmaps = 1
tex_id = gh_texture.create_from_file_v2("data/tex.jpg", PF_U8_RGBA, abs_path, gen_mipmaps)
syntax
tex_id = gh_texture.create_from_file_v3 (
filename,
pf,
absolute_path,
gen_mipmaps,
compression,
free_cpu_memory
)
parameters
filename STRING image filename
pf ENUM( pixel_format ) pixel format
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compression BOOLEAN hardware compression: 1 (enabled) or 0 (disabled)
free_cpu_memory BOOLEAN frees the pixamp in CPU memory: 1 (true) or 0 (false)
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local abs_path = 0
local gen_mipmaps = 1
local compression = 1
local free_cpu_memory = 1
tex_id = gh_texture.create_from_file_v3("data/tex.jpg", PF_U8_RGBA, abs_path, gen_mipmaps, compression, free_cpu_memory)
syntax
tex_id = gh_texture.create_from_file_v5 (
filename,
pf
)
parameters
filename STRING absolute path of the image file
pf ENUM( pixel_format ) pixel format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_file_v5(demo_dir .. "./data/tex.jpg", PF_U8_RGBA)
syntax
tex_id = gh_texture.create_from_file_v6 (
filename,
pf,
gen_mipmaps,
compressed_format
)
parameters
filename STRING absolute path of the image file
pf ENUM( pixel_format ) pixel format
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_file_v6(demo_dir .. "./data/tex.jpg", PF_U8_RGBA, gen_mipmaps, compression_format)
syntax
tex_id = gh_texture.create_from_file_v8 (
filename,
pf,
tex_unit,
gen_mipmaps,
compressed_format
)
parameters
filename STRING absolute path of the image file
pf ENUM( pixel_format ) pixel format
tex_unit INTEGER texture unit (for Direct3D 12 or Vulkan)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_file_v8(demo_dir .. "./data/tex.jpg", PF_U8_RGBA, tex_unit, gen_mipmaps, compression_format)
syntax
tex_id = gh_texture.create_from_file_v9 (
filename,
upload_to_gpu,
pf,
tex_unit,
gen_mipmaps,
compressed_format
)
parameters
filename STRING absolute path of the image file
upload_to_gpu BOOLEAN uploads the pixmap into GPU memory: 1 (true) or 0 (false)
pf ENUM( pixel_format ) pixel format
tex_unit INTEGER texture unit (for Direct3D 12 or Vulkan)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local upload_to_gpu = 1
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_file_v9(demo_dir .. "./data/tex.jpg", upload_to_gpu, PF_U8_RGBA, tex_unit, gen_mipmaps, compression_format)
syntax
tex_id = gh_texture.create_from_sqlite3_blob (
db_id,
column,
upload_to_gpu,
pf,
tex_unit,
gen_mipmaps,
compressed_format
)
parameters
db_id ID database identifier
column INTEGER index of the column
upload_to_gpu BOOLEAN uploads the pixmap into GPU memory: 1 (true) or 0 (false)
pf ENUM( pixel_format ) pixel format
tex_unit INTEGER texture unit (for Direct3D 12 or Vulkan)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local upload_to_gpu = 1
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
tex_id = gh_texture.create_from_sqlite3_blob_v1(db_id, column, upload_to_gpu, PF_U8_RGBA, tex_unit, gen_mipmaps, compression_format)
syntax
new_dst_tex_id = gh_texture.create_from_sub_texture (
src_tex_id,
x, y, width, height
)
parameters
src_tex_id ID source texture identifier
x, y, width, height INTEGER start offset (x, y) and size of the sub texture
return values
new_dst_tex_id ID new texture identifier
code sample
tex_dst = gh_texture.create_from_sub_texture(tex_src, 10, 10, 200, 200)
syntax
tex_id = gh_texture.create_from_zip_file (
zip_filename,
filename,
upload_to_gpu,
pf,
tex_unit,
gen_mipmaps,
compressed_format
)
parameters
zip_filename STRING absolute path of the zip file
filename STRING image file in the zip archive
upload_to_gpu BOOLEAN uploads the pixmap into GPU memory: 1 (true) or 0 (false)
pf ENUM( pixel_format ) pixel format
tex_unit INTEGER texture unit (for Direct3D 12 or Vulkan)
gen_mipmaps BOOLEAN generates the mipmaps: 1 (true) or 0 (false)
compressed_format STRING compression format
return values
tex_id ID texture identifier
code sample
# Pixel formats:
PF_U8_RGB = 1
PF_U8_BGR = 2
PF_U8_RGBA = 3
PF_U8_BGRA = 4
PF_F32_RGB = 5
PF_F32_RGBA = 6
PF_F32_R = 7
PF_U8_R = 11
PF_U8_RG = 12
local upload_to_gpu = 1
local tex_unit = 0
local gen_mipmaps = 1
local compression_format = ""
local demo_dir = gh_utils.get_demo_dir()
zip_filename = demo_dir .. "demo.zip"
filename = "assets/image.jpg"
tex_id = gh_texture.create_from_zip_file(zip_filename, filename, upload_to_gpu, PF_U8_RGBA, tex_unit, gen_mipmaps, compression_format)
syntax
gh_texture.flip_horizontal (
tex_id
)
parameters
tex_id ID texture identifier
return values
none
code sample
gh_texture.flip_horizontal(tex_id)
syntax
mem_size, compressed_mem_size = gh_texture.get_gpu_memory_size (
tex_id
)
parameters
tex_id ID texture identifier
return values
mem_size, compressed_mem_size INTEGER texture size
code sample
local gpu_mem_size, gpu_compressed_mem_size = gh_texture.get_gpu_memory_size(tex_id)
syntax
n = gh_texture.get_num_mipmaps (
tex_id
)
parameters
tex_id ID texture identifier
return values
n INTEGER number of mipmap levels
code sample
n = gh_texture.get_num_mipmaps(tex_id)
get_size
Gets the texture size.
syntax
width, height, depth = gh_texture.get_size (
tex_id
)
parameters
tex_id ID texture identifier
return values
width, height, depth INTEGER texture size
code sample
width, height, depth = gh_texture.get_size(tex_id)
syntax
r, g, b, a = gh_texture.get_texel_1d (
tex_id,
x_offset
)
parameters
tex_id ID texture identifier
x_offset INTEGER offset inside the texture pixmap
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_texture.get_texel_1d(tex_id, 0)
syntax
r, g, b, a = gh_texture.get_texel_2d (
tex_id,
x_offset, y_offset
)
parameters
tex_id ID texture identifier
x_offset, y_offset INTEGER offsets inside the texture pixmap
return values
r, g, b, a REAL RGBA color value
code sample
r, g, b, a = gh_texture.get_texel_2d(tex_id, 0, 0)
syntax
gh_texture.gpu_mem_to_cpu_mem (
tex_id
)
parameters
tex_id ID texture identifier
return values
none
code sample
gh_texture.gpu_mem_to_cpu_mem(tex_id)
syntax
ret = gh_texture.gpu_memory_unload (
tex_id
)
parameters
tex_id ID texture identifier
return values
ret BOOLEAN 1 (success) or 0 (error)
code sample
gh_texture.gpu_memory_unload(tex_id)
syntax
ret = gh_texture.gpu_memory_upload (
tex_id,
tex_unit,
create_srv,
free_cpu_memory
)
parameters
tex_id ID texture identifier
tex_unit INTEGER texture unit
create_srv INTEGER creates resource view (Direct3D 12)
free_cpu_memory BOOLEAN frees the CPU memory after upload: 1 (true) or 0 (false)
return values
ret BOOLEAN 1 (success) or 0 (error)
code sample
ret = gh_texture.gpu_memory_upload(tex_id, 0, 0, 1)
syntax
gh_texture.image_bind (
tex_id,
tex_unit,
access_type
)
parameters
tex_id ID texture identifier
tex_unit INTEGER texture unit on which the image is bound
access_type ENUM( tex_data_access ) specifies the red/write mode of the image
return values
none
code sample
DATA_ACCESS_READ_WRITE = 0
DATA_ACCESS_WRITE_ONLY = 1
DATA_ACCESS_READ_ONLY = 2
local tex_unit = 1
gh_texture.image_bind(tex_id, tex_unit, DATA_ACCESS_WRITE_ONLY)
syntax
gh_texture.inject_opacity_map (
dst_tex_id,
opa_tex_id
)
parameters
dst_tex_id ID destination texture identifier
opa_tex_id ID opacity texture identifier
return values
none
code sample
gh_texture.inject_opacity_map(dst_tex_id, opa_tex_id)
renderer_update
Uploads the entire pixmap to the renderer.
Useful after a modification of the pixmap (flip_horizontal() for example).
Works with any kind of texture (1D, 2D, CUBE, etc.).
syntax
gh_texture.renderer_update (
tex_id
)
parameters
tex_id ID texture identifier
return values
none
code sample
gh_texture.flip_horizontal(tex_id)
gh_texture.renderer_update(tex_id)
syntax
gh_texture.renderer_update2d (
tex_id,
x_offset, y_offset,
width, height
)
parameters
tex_id ID texture identifier
x_offset, y_offset INTEGER offsets inside the texture pixmap
width, height INTEGER size of the texture pixmap that will be uploaded
return values
none
code sample
gh_texture.flip_horizontal(tex_id)
width, height, depth = gh_texture.get_size(tex_id)
gh_texture.renderer_update2d(tex_id, 0, 0, width/2, height/2)
syntax
gh_texture.reset_texture_unit (
tex_unit
)
parameters
tex_unit INTEGER texture unit on which a texture is bound
return values
none
code sample
tex_unit = 1
gh_texture.reset_texture_unit(tex_unit)
syntax
gh_texture.rt_color_bind_v2 (
rt_id,
color_target_index,
tex_unit
)
parameters
rt_id ID render target identifier
color_target_index INTEGER index of the color target
tex_unit INTEGER texture unit on which the texture is bound
return values
none
code sample
tex_unit = 0
color_target_index = 0
gh_texture.rt_color_bind_v2(rt_id, color_target_index, tex_unit)
syntax
gh_texture.rt_color_cubemap_bind (
rt_id,
tex_unit
)
parameters
rt_id ID render target identifier
tex_unit INTEGER texture unit on which the texture is bound
return values
none
code sample
tex_unit = 0
gh_texture.rt_color_cubemap_bind(rt_id, tex_unit)
syntax
gh_texture.rt_depth_bind (
rt_id,
tex_unit
)
parameters
rt_id ID render target identifier
tex_unit INTEGER texture unit on which the texture is bound
return values
none
code sample
tex_unit = 1
gh_texture.rt_depth_bind(rt_id, tex_unit)
syntax
gh_texture.rt_depth_cubemap_bind (
rt_id,
tex_unit
)
parameters
rt_id ID render target identifier
tex_unit INTEGER texture unit on which the texture is bound
return values
none
code sample
tex_unit = 0
gh_texture.rt_depth_cubemap_bind(rt_id, tex_unit)
syntax
gh_texture.set_current_image_codec (
codec_name
)
parameters
codec_name ENUM( tex_codec_name ) code name: 'FreeImage' or 'stb'
return values
none
code sample
gh_texture.set_current_image_codec("FreeImage")
syntax
gh_texture.set_texel_1d (
tex_id,
x_offset,
r, g, b, a
)
parameters
tex_id ID texture identifier
x_offset INTEGER offset inside the texture pixmap
r, g, b, a REAL RGBA value
return values
none
code sample
gh_texture.set_texel_1d(tex_id, 0, r, g, b, a)
syntax
gh_texture.set_texel_2d (
tex_id,
x_offset, y_offset,
r, g, b, a
)
parameters
tex_id ID texture identifier
x_offset, y_offset INTEGER offsets inside the texture pixmap
r, g, b, a REAL RGBA value
return values
none
code sample
gh_texture.set_texel_2d(tex_id, 0, 0, r, g, b, a)
syntax
gh_texture.share_texture_data (
tex_id,
shared_tex_id
)
parameters
tex_id ID texture identifier
shared_tex_id ID shared texture identifier
return values
none
code sample
gh_texture.share_texture_data(tex_id, shared_tex_id)
syntax
gh_texture.update_gpu_memory_from_buffer (
tex_id,
buff_ptr,
buff_size
)
parameters
tex_id ID texture identifier
buff_ptr POINTER pointer to the image buffer
buff_size INTEGER size in bytes of the buffer
return values
none
code sample
gh_texture.update_gpu_memory_from_buffer(tex_id, buffer, buffer_size)
syntax
gh_texture.update_gpu_memory_from_file (
tex_id,
filename,
absolute_path
)
parameters
tex_id ID texture identifier
filename STRING image filename
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
none
code sample
local abs_path = 0
gh_texture.update_gpu_memory_from_file(tex_id, "data/tex.jpg", abs_path)
syntax
gh_texture.update_gpu_memory_from_numpy_img (
tex_id,
np_array
)
parameters
tex_id ID texture identifier
np_array POINTER NumPy array
return values
none
code sample
gh_texture.update_gpu_memory_from_numpy_img(tex_id, np_array)
syntax
gh_texture.write_to_file_v4 (
tex_id,
filename,
flip_image,
image_format,
saving_options
)
parameters
tex_id ID texture identifier
filename STRING absolute path of the saved image
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
image_format STRING format/type of the image: jpg, bmp, png, tif, gif, tga
saving_options ENUM( saving_options ) saving options: quality_100, quality_90, quality_80, ..., quality_10
return values
none
code sample
gh_texture.set_current_image_codec("FreeImage")
gh_texture.write_to_file_v4(tex_id, filename, vertical_flip, format)
syntax
aligned = gh_utils.align_down (
x,
a
)
parameters
x INTEGER input value.
a INTEGER alignment value.
return values
aligned INTEGER aligned value.
code sample
aligned_size = gh_utils.align_down(25, 4)
syntax
aligned = gh_utils.align_up (
x,
a
)
parameters
x INTEGER input value.
a INTEGER alignment value.
return values
aligned INTEGER aligned value.
code sample
aligned_size = gh_utils.align_up(25, 4)
box_create
Creates a simple box.
syntax
box_id = gh_utils.box_create (
w, h, d,
r, g, b, a
)
parameters
w, h, d REAL width, height and depth of the box
r, g, b, a REAL RGBA color
return values
box_id ID box identifier
code sample
box_id = gh_utils.box_create(10.0, 10.0, 10.0, 1.0, 1.0, 0.0, 1.0)
syntax
gh_utils.box_update_size (
box_id,
w, h, d
)
parameters
box_id ID box identifier
w, h, d REAL width, height and depth of the box
return values
none
code sample
gh_utils.box_update_size(box_id, 12.0, 12.0, 12.0)
syntax
gh_utils.buffer_copy (
src_buff_ptr,
src_offset,
dst_buff_ptr,
dst_offset,
num_bytes
)
parameters
src_buff_ptr POINTER pointer to the source buffer
src_offset INTEGER offset in the source buffer in bytes
dst_buff_ptr POINTER pointer to the destination buffer
dst_offset INTEGER offset in the destination buffer in bytes
num_bytes INTEGER number of bytes that will be copied
return values
none
code sample
src_ptr, size = gh_utils.buffer_create(1024)
dst_ptr, size = gh_utils.buffer_create(1024)
...
gh_utils.buffer_create(src_ptr, 0, dst_ptr, 0, 1024)
...
syntax
hashcode = gh_utils.buffer_crc32 (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the line to read in bytes
return values
hashcode STRING hashcode of the buffer
code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_crc32(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
syntax
buff_ptr, buff_size = gh_utils.buffer_create (
size
)
parameters
size INTEGER size in bytes.
return values
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
...
gh_utils.buffer_kill(buffer_ptr)
syntax
gh_utils.buffer_kill (
buff_ptr
)
parameters
buff_ptr POINTER pointer to the buffer
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
...
gh_utils.buffer_kill(buffer_ptr)
syntax
hashcode = gh_utils.buffer_md5 (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the line to read in bytes
return values
hashcode STRING hashcode of the buffer
code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_md5(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
syntax
x, y = gh_utils.buffer_read_1f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y REAL value
code sample
filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
offset = 0
x = gh_utils.buffer_read_1f(buffer_ptr, offset)
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
x, y = gh_utils.buffer_read_2f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y REAL value
code sample
filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
offset = 0
x, y = gh_utils.buffer_read_2f(buffer_ptr, offset)
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
x, y, z = gh_utils.buffer_read_3f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y, z REAL value
code sample
filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
offset = 0
x, y, z = gh_utils.buffer_read_3f(buffer_ptr, offset)
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
x, y, z, w = gh_utils.buffer_read_4f (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x, y, z, w REAL value
code sample
filename = gh_utils.get_demo_dir() .. "data.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
offset = 0
x, y, z, w = gh_utils.buffer_read_4f(buffer_ptr, offset)
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
x = gh_utils.buffer_read_byte (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
return values
x INTEGER value of the byte
code sample
filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
-- read the first byte:
x = gh_utils.buffer_read_byte(buffer_ptr, 0)
-- read the second byte:
x = gh_utils.buffer_read_byte(buffer_ptr, 1)
...
...
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
line, line_size = gh_utils.buffer_read_line (
buff_ptr,
buff_size,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
offset INTEGER offset of the line to read in bytes
return values
line STRING content of a line
line_size INTEGER size of the line in bytes. If line_size==0, the end of the buffer is reached.
code sample
filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
line_offset = 0
-- read the first line:
line, line_size = gh_utils.buffer_read_line(buffer_ptr, buffer_size, line_offset)
line_offset = line_offset + line_size
-- read the second line:
line, line_size = gh_utils.buffer_read_line(buffer_ptr, buffer_size, line_offset)
...
...
...
gh_utils.file_buffer_kill(buffer_ptr)
syntax
hashcode = gh_utils.buffer_sha1 (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the line to read in bytes
return values
hashcode STRING hashcode of the buffer
code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_sha1(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
syntax
hashcode = gh_utils.buffer_sha256 (
buff_ptr,
offset
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the line to read in bytes
return values
hashcode STRING hashcode of the buffer
code sample
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
hashcode = gh_utils.buffer_sha256(buffer_ptr, buffer_size)
gh_utils.file_buffer_kill(buffer_ptr)
syntax
ret = gh_utils.buffer_to_file (
buff_ptr,
buff_size,
dst_filename
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
dst_filename STRING absolute path of the file on the file system
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
dst_filename = gh_utils.get_demo_dir() .. "image01.jpg"
if (gh_utils.buffer_to_file(buffer, buffer_size, dst_filename) == 1) then
-- OK!
end
syntax
gh_utils.buffer_write_1f (
buff_ptr,
offset,
x
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x REAL value
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
x = 3.14
gh_utils.buffer_write_1f(buffer_ptr, 0, x)
...
gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
syntax
gh_utils.buffer_write_2f (
buff_ptr,
offset,
x, y
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x, y REAL value
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
x = 3.14
y = 1.22
gh_utils.buffer_write_2f(buffer_ptr, 0, x, y)
...
gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
syntax
gh_utils.buffer_write_3f (
buff_ptr,
offset,
x, y, z
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x, y, z REAL value
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
x = 3.14
y = 1.22
z = -0.57
gh_utils.buffer_write_3f(buffer_ptr, 0, x, y, z)
...
gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
syntax
gh_utils.buffer_write_4f (
buff_ptr,
offset,
x, y, z, w
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x, y, z, w REAL value
return values
none
code sample
buffer_ptr, buffer_size = gh_utils.buffer_create(1024)
x = 3.14
y = 1.22
z = -0.57
w = 1.0
gh_utils.buffer_write_4f(buffer_ptr, 0, x, y, z, w)
...
gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.buffer_kill(buffer_ptr)
syntax
gh_utils.buffer_write_byte (
buff_ptr,
offset,
x
)
parameters
buff_ptr POINTER pointer to the buffer
offset INTEGER offset of the byte to read in bytes
x INTEGER value of the byte
return values
none
code sample
filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
-- write the first byte:
x = 100
gh_utils.buffer_write_byte(buffer_ptr, 0, x)
-- write the second byte:
x = 112
gh_utils.buffer_write_byte(buffer_ptr, 1, x)
...
...
...
gh_utils.buffer_to_file(buffer_ptr, buffer_size, dst_filename)
gh_utils.file_buffer_kill(buffer_ptr)
syntax
circle_id = gh_utils.circle_create (
radius,
subdivisions,
r, g, b, a
)
parameters
radius REAL radius
subdivisions INTEGER subdivisions
r, g, b, a REAL RGBA color
return values
circle_id ID circle identifier
code sample
circle_id = gh_utils.circle_create(10.0, 20, 1.0, 1.0, 0.0, 1.0)
circle_create_v2
Creates a simple circle.
syntax
circle_id = gh_utils.circle_create_v2 (
plane_type,
radius,
subdivisions,
r, g, b, a
)
parameters
plane_type ENUM( plane_type ) 0 (XZ), 1 (XY) or 2 (YZ)
radius REAL radius
subdivisions INTEGER subdivisions
r, g, b, a REAL RGBA color
return values
circle_id ID circle identifier
code sample
plane_type = 1
circle_id = gh_utils.circle_create_v2(plane_type, 10.0, 20, 1.0, 1.0, 0.0, 1.0)
syntax
gh_utils.circle_update_radius (
circle_id,
radius
)
parameters
circle_id ID circle identifier
radius REAL radius
return values
none
code sample
gh_utils.circle_update_radius(circle_id, 12.0)
syntax
text, text_len = gh_utils.clipboard_get_text()
parameters
none
return values
text STRING text from the clipboard
text_len INTEGER length of the text
code sample
text, text_len = gh_utils.clipboard_get_text()
syntax
gh_utils.clipboard_set_text (
text
)
parameters
text STRING text to be copied in the clipboard
return values
none
code sample
gh_utils.clipboard_set_text("Hello!")
syntax
size = gh_utils.cpu_get_mem_available_size_mb()
parameters
none
return values
size INTEGER size in MB
code sample
mem_size_mb = gh_utils.cpu_get_mem_available_size_mb()
syntax
size = gh_utils.cpu_get_mem_size_mb()
parameters
none
return values
size INTEGER size in MB
code sample
mem_size_mb = gh_utils.cpu_get_mem_size_mb()
syntax
str = gh_utils.cpu_get_name()
parameters
none
return values
str STRING CPU name
code sample
local cpu_name = gh_utils.cpu_get_name()
syntax
speed = gh_utils.cpu_get_speed_mhz()
parameters
none
return values
speed REAL CPU speed
code sample
local cpu_speed = gh_utils.cpu_get_speed_mhz()
syntax
gh_utils.cpu_usage_cleanup()
parameters
none
return values
none
code sample
gh_utils.cpu_usage_cleanup()
syntax
num_cores = gh_utils.cpu_usage_get_core_count()
parameters
none
return values
num_cores INTEGER number of cores
code sample
local cores = gh_utils.cpu_usage_get_core_count()
syntax
usage = gh_utils.cpu_usage_get_core_usage (
index
)
parameters
index INTEGER core index from 0 to cpu_usage_get_core_count()-1
return values
usage INTEGER core usage in percent
code sample
local core_index = 0
local usage = gh_utils.cpu_usage_get_core_usage(core_index)
syntax
ret = gh_utils.cpu_usage_init()
parameters
none
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
local ret = gh_utils.cpu_usage_init()
syntax
gh_utils.cpu_usage_update()
parameters
none
return values
none
code sample
gh_utils.cpu_usage_update()
syntax
gh_utils.curl_download_file_v1 (
curl_lib_dir,
url,
local_file
)
parameters
curl_lib_dir STRING directory of the curl dynamic libray. Can be empty.
url STRING URL of the file to download.
local_file STRING absolute path to the file on local machine.
return values
none
code sample
gh_utils.curl_download_file_v1("", "https://m.media-amazon.com/images/I/319KAiGobEL._AC_SY200_.jpg", demo_dir .. "images/319KAiGobEL._AC_SY200_.jpg")
syntax
ret = gh_utils.do_file_from_sqlite3_blob (
db_id,
column
)
parameters
db_id ID database identifier
column INTEGER index of the column
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
gh_utils.do_file_from_sqlite3_blob(db_id, column)
syntax
ret = gh_utils.do_file_from_zip (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of the zip file
filename STRING script file in the zip archive
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
zip_filename = demo_dir .. "data.zip"
gh_utils.do_file_from_zip(zip_filename, "scripts/init02.lua")
syntax
gh_utils.do_screenshot (
filename,
absolute_path
)
parameters
filename STRING relative path of the screenshot file
absolute_path BOOLEAN file path: 1 (absolute) or 0 (relative)
return values
none
code sample
gh_utils.do_screenshot("image.jpg", 0)
syntax
gh_utils.do_screenshot_v2 (
filename,
flip_image
)
parameters
filename STRING relative path of the screenshot file
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
return values
none
code sample
local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
gh_utils.do_screenshot_v2(demo_dir .. "image.jpg", flip_image)
syntax
gh_utils.do_screenshot_v3 (
filename,
x, y, width, height,
flip_image
)
parameters
filename STRING relative path of the screenshot file
x, y, width, height INTEGER zone of the viewport to save
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
return values
none
code sample
local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
local x = 0
local y = 0
gh_utils.do_screenshot_v3(demo_dir .. "image.jpg", x, y, winW, winH, flip_image)
syntax
gh_utils.do_screenshot_v4 (
filename,
x, y, width, height,
flip_image,
format,
saving_options
)
parameters
filename STRING relative path of the screenshot file
x, y, width, height INTEGER zone of the viewport to save
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
format STRING image format (.jpg, .bmp, etc) (depends on the image plugin)
saving_options STRING saving options (depends on the image plugin)
return values
none
code sample
local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
local x = 0
local y = 0
format = "jpg"
saving_options = ""
gh_utils.do_screenshot_v4(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options)
syntax
gh_utils.do_screenshot_v5 (
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
parameters
filename STRING relative path of the screenshot file
x, y, width, height INTEGER zone of the viewport to save
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
format STRING image format (.jpg, .bmp, etc) (depends on the image plugin)
saving_options STRING saving options (depends on the image plugin)
image_codec_name STRING name of the image plugin used to save the image: stb, FreeImage, ImageMagick.
return values
none
code sample
local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
local x = 0
local y = 0
format = "jpg"
saving_options = ""
image_codec_name = "FreeImage" # default codec: "stb"
gh_utils.do_screenshot_v5(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options, image_codec_name)
syntax
gh_utils.do_screenshot_v6 (
filename,
x, y, width, height,
flip_image,
format,
saving_options,
image_codec_name
)
parameters
filename STRING relative path of the screenshot file
x, y, width, height INTEGER zone of the viewport to save
flip_image BOOLEAN vertical flip of the image before saving: 1 (true) or 0 (false)
format STRING image format (.jpg, .bmp, etc) (depends on the image plugin)
saving_options STRING saving options (depends on the image plugin)
image_codec_name STRING name of the image plugin used to save the image: stb, FreeImage, ImageMagick.
return values
none
code sample
local demo_dir = gh_utils.get_demo_dir()
local flip_image = 1
local x = 0
local y = 0
format = "jpg"
saving_options = ""
image_codec_name = "FreeImage" # default codec: "stb"
gh_utils.do_screenshot_v6(demo_dir .. "image.jpg", x, y, winW, winH, flip_image, format, saving_options, image_codec_name)
syntax
filename = gh_utils.drop_files_get_file_by_index (
index
)
parameters
index INTEGER index of the file: from 0 to drop_files_get_num_files()-1
return values
filename STRING name of a dropped file
code sample
num_files = gh_utils.drop_files_get_num_files()
if (num_files > 0) then
# Gets the first dropped file:
filename = gh_utils.drop_files_get_file_by_index(0)
end
syntax
filename = gh_utils.drop_files_get_file_by_index_w (
index
)
parameters
index INTEGER index of the file: from 0 to drop_files_get_num_files()-1
return values
filename STRING name of a dropped file
code sample
num_files = gh_utils.drop_files_get_num_files()
if (num_files > 0) then
# Gets the first dropped file:
filename = gh_utils.drop_files_get_file_by_index_w(0)
end
syntax
num_dropped = gh_utils.drop_files_get_num_files()
parameters
none
return values
num_dropped INTEGER number of dropped files
code sample
num_files = gh_utils.drop_files_get_num_files()
syntax
gh_utils.dylib_frame (
dylib_id,
elapsed_time,
data
)
parameters
dylib_id ID dylib identifier
elapsed_time REAL elapsed time in seconds
data STRING user data
return values
none
code sample
gh_utils.dylib_frame(dylib_id, elapsed_time, "")
syntax
message = gh_utils.dylib_get_message (
dylib_id
)
parameters
dylib_id ID dylib identifier
return values
message STRING message
code sample
message = gh_utils.dylib_get_message(dylib_id)
syntax
dylib_id = gh_utils.dylib_load (
dylib_filename
)
parameters
dylib_filename STRING absolute path of the dynamic lib
return values
dylib_id ID dylib identifier
code sample
dylib_id = gh_utils.dylib_load("/Users/toto/my3dcode.dylib")
syntax
gh_utils.dylib_resize (
dylib_id,
width, height,
data
)
parameters
dylib_id ID dylib identifier
width, height INTEGER width and height of the 3D window
data STRING user data
return values
none
code sample
gh_utils.dylib_resize(dylib_id, width, height, "")
syntax
gh_utils.dylib_set_message (
dylib_id,
message
)
parameters
dylib_id ID dylib identifier
message STRING message
return values
none
code sample
message = "....."
gh_utils.dylib_set_message(dylib_id, message)
syntax
gh_utils.dylib_start (
dylib_id,
width, height,
data
)
parameters
dylib_id ID dylib identifier
width, height INTEGER width and height of the 3D window
data STRING user data
return values
none
code sample
gh_utils.dylib_start(dylib_id, width, height, "")
syntax
gh_utils.dylib_stop (
dylib_id,
data
)
parameters
dylib_id ID dylib identifier
data STRING user data
return values
none
code sample
gh_utils.dylib_stop(dylib_id, "")
syntax
gh_utils.dylib_unload (
dylib_id
)
parameters
dylib_id ID dylib identifier
return values
none
code sample
gh_utils.dylib_unload(dylib_id)
syntax
ret = gh_utils.exe_from_buffer (
buff_ptr,
buff_size
)
parameters
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
local demo_dir = gh_utils.get_demo_dir()
filename = demo_dir .. "assets/init_textures.lua"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
if (gh_utils.exe_from_buffer(buffer, buffer_size) == 1) then
-- ok
end
gh_utils.file_buffer_kill(buffer)
exe_script
Executes a script.
syntax
gh_utils.exe_script (
name,
threaded
)
parameters
name STRING name of the script
threaded BOOLEAN runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
return values
none
code sample
local threaded = 0
gh_utils.exe_script("init_meshes", threaded)
exe_script_v2
Executes a script.
syntax
gh_utils.exe_script_v2 (
name,
threaded,
create_worker_wind3d
)
parameters
name STRING name of the script
threaded BOOLEAN runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
create_worker_wind3d BOOLEAN creates a worker 3D window: 1 (yes) or 0 (no). The worker 3D window is required if you plan to call an OpenGL related function in the threaded script
return values
none
code sample
local threaded = 1
local create_worker_wind3d = 0
gh_utils.exe_script_v2("load_textures_cpu", threaded, create_worker_wind3d)
exe_script_v3
Executes a script.
syntax
gh_utils.exe_script_v3 (
name,
threaded,
create_worker_wind3d,
thread_affinity_mask
)
parameters
name STRING name of the script
threaded BOOLEAN runs the script in a separate system thread: 1 (enabled) or 0 (disabled)
create_worker_wind3d BOOLEAN creates a worker 3D window: 1 (yes) or 0 (no). The worker 3D window is required if you plan to call an OpenGL related function in the threaded script
thread_affinity_mask INTEGER specifies the affinity mask for the thread. Only on Windows. A thread affinity mask is a bit vector in which each bit represents a logical processor. Set this mask to 0 to disable it.
return values
none
code sample
local threaded = 1
local create_worker_wind3d = 0
local thread_affinity_mask = 0
gh_utils.exe_script_v3("load_textures_cpu", threaded, create_worker_wind3d, thread_affinity_mask)
exe_string
Executes a script.
syntax
ret = gh_utils.exe_string (
lua_python_commands
)
parameters
lua_python_commands STRING commands in Lua or Python
return values
ret BOOLEAN return code: 1 (success) or 0 (error)
code sample
gh_utils.exe_string("demo_folder = gh_utils.get_demo_dir()")
print(demo_folder)
syntax
buff_ptr, buff_size = gh_utils.file_buffer_create (
filename
)
parameters
filename STRING absolute path of the file
return values
buff_ptr POINTER pointer to the buffer
buff_size INTEGER size of the buffer in bytes
code sample
filename = gh_utils.get_demo_dir() .. "config.txt"
buffer_ptr, buffer_size = gh_utils.file_buffer_create(filename)
...
gh_utils.buffer_kill(buffer_ptr)
syntax
crc32, crc32_str = gh_utils.file_crc32 (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of a zip file. Optional
filename STRING absolute or relative path of the file
return values
crc32 INTEGER CRC32 code
crc32_str STRING string version of the CRC32 code
code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
crc32, crc32_str = gh_utils.file_crc32(zip_filename, filename)
syntax
hashcode = gh_utils.file_md5 (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of a zip file. Optional
filename STRING absolute or relative path of the file
return values
hashcode STRING hashcode of the file
code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_md5(zip_filename, filename)
syntax
data, data_size = gh_utils.file_read (
zip_filename,
filename
)
parameters
zip_filename STRING zip archive. Can be empty.
filename STRING file name (absolute path).
return values
data STRING file data
data_size INTEGER file data size
code sample
data, data_size = gh_utils.file_read(zip_filename, filename)
syntax
hashcode = gh_utils.file_sha1 (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of a zip file. Optional
filename STRING absolute or relative path of the file
return values
hashcode STRING hashcode of the file
code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha1(zip_filename, filename)
syntax
hashcode = gh_utils.file_sha256 (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of a zip file. Optional
filename STRING absolute or relative path of the file
return values
hashcode STRING hashcode of the file
code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
hashcode = gh_utils.file_sha256(zip_filename, filename)
syntax
size = gh_utils.file_size_DUP1 (
zip_filename,
filename
)
parameters
zip_filename STRING absolute path of a zip file. Optional
filename STRING absolute or relative path of the file
return values
size INTEGER size of the file in bytes
code sample
zip_filename = ""
filename = gh_utils.get_demo_dir() .. "assets/image01.jpg"
size = gh_utils.file_size(zip_filename, filename)
syntax
size = gh_utils.file_size_DUP2 (
zip_filename,
filename
)
parameters
zip_filename STRING zip archive. Can be empty.
filename STRING file name (absolute path).
return values
size INTEGER size in bytes
code sample
size = gh_utils.file_size(zip_filename, filename)
file_write
Writes data to a file.
syntax
ret = gh_utils.file_write (
filename,
data
)
parameters
filename STRING file name (absolute path).
data STRING file data
return values
ret INTEGER 0 (error) or 1 (success)
code sample
ret = gh_utils.file_write(filename, data)
font_create
Creates a new font.
syntax
font_id = gh_utils.font_create (
font_name,
height
)
parameters
font_name STRING TrueType font name, ex: Arial, Verdana
height INTEGER font height
return values
font_id ID font identifier
code sample
font_id = gh_utils.font_create("Arial", 14)
font_render
Renders (draws) a text.
syntax
gh_utils.font_render (
font_id,
x, y,
r, g, b, a,
text
)
parameters
font_id ID font identifier
x, y INTEGER X and Y start offsets in the current viewport
r, g, b, a REAL RGBA color of the text
text STRING text to render
return values
none
code sample
gh_utils.font_set_viewport_info(font_id, 0, 0, width, height)
gh_utils.font_render(font, 10, 40, 0.2, 1.0, 0.0, 1.0, string.format("Image filename: %s", texture_filename))
syntax
gh_utils.font_render3d (
font_id,
x, y, z,
r, g, b, a,
text
)
parameters
font_id ID font identifier
x, y, z REAL 3D position of the beginning of the text
r, g, b, a REAL RGBA color of the text
text STRING text to render
return values
none
code sample
gh_utils.font_render3d(font_id, 0, 20.0, -20.0, 0.2, 1.0, 0.0, 1.0, "V1")
syntax
gh_utils.font_set_viewport_info (
font_id,
x, y,
width, height
)
parameters
font_id ID font identifier
x, y INTEGER viewport offsets
width, height INTEGER viewport size
return values
none
code sample
gh_utils.font_set_viewport_info(font_id, 0, 0, width, height)
syntax
gh_utils.ftgl_font_add_text2d (
font_id,
x, y,
r, g, b, a,
text
)
parameters
font_id ID font identifier
x, y INTEGER screen coordiantes of the beginning of the text
r, g, b, a REAL color of the text
text STRING text
return values
none
code sample
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font_id, 10, 40, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line2")
syntax
gh_utils.ftgl_font_add_text3d (
font_id,
x, y, z,
r, g, b, a,
text
)
parameters
font_id ID font identifier
x, y, z REAL 3D position of the beginning of the text
r, g, b, a REAL color of the text
text STRING text
return values
none
code sample
gh_utils.ftgl_font_add_text3d(font_id, x, y, z, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line1")
gh_utils.ftgl_font_add_text2d(font_id, x+20, y-30, z-30, 1.0, 0.0, 0.0, 1.0, "GeeXLab - line2")
syntax
gh_utils.ftgl_font_clear (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_utils.ftgl_font_clear(font_id)
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font_id)
syntax
font_id = gh_utils.ftgl_font_create (
font_tex_id
)
parameters
font_tex_id ID font texture identifier
return values
font_id ID font identifier
code sample
font_id = gh_utils.ftgl_font_create(font_tex_id)
syntax
gh_utils.ftgl_font_kill (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_utils.ftgl_font_kill(font_id)
ftgl_font_render
Renders a 2D font.
syntax
gh_utils.ftgl_font_render (
font_id
)
parameters
font_id ID font identifier
return values
none
code sample
gh_utils.ftgl_font_clear(font_id)
gh_utils.ftgl_font_add_text2d(font_id, 10, 20, 1.0, 0.0, 0.0, 1.0, string.format("Elapsed time: %.3f sec.", elapsed_time))
gh_utils.ftgl_font_render(font_id)
syntax
gh_utils.ftgl_font_texture_kill (
font_tex_id
)
parameters
font_tex_id ID font texture identifier
return values
none
code sample
gh_utils.ftgl_font_texture_kill(font_tex_id)
syntax
font_tex_id = gh_utils.ftgl_font_texture_load (
filename,
height,
tex_width, tex_height,
_5, _6
)
parameters
filename STRING TrueType font file
height INTEGER height of font glyphs
tex_width, tex_height INTEGER width and height of the font texture
_5, _6 INTEGER reserved
return values
font_tex_id ID font texture identifier
code sample
font_tex_id = gh_utils.ftgl_font_texture_load(filename, 50, 1024, 1024, 0, 0)
syntax
dir = gh_utils.get_app_dir()
parameters
none
return values
dir STRING directory
code sample
app_dir = gh_utils.get_app_dir()
syntax
name = gh_utils.get_app_name()
parameters
none
return values
name STRING name of the host application
code sample
app_name = gh_utils.get_app_name()
syntax
text = gh_utils.get_app_title_bar()
parameters
none
return values
text STRING title
code sample
text = gh_utils.get_app_title_bar()
syntax
major, minor, patch, build = gh_utils.get_app_version()
parameters
none
return values
major, minor, patch, build INTEGER version of GeeXLab
code sample
major, minor, patch, build = gh_utils.get_app_version()
syntax
command_line = gh_utils.get_command_line()
parameters
none
return values
command_line STRING command line
code sample
command_line = gh_utils.get_command_line()
syntax
date = gh_utils.get_date_str()
parameters
none
return values
date STRING date (Y.M.D.h.m.s)
code sample
date = gh_utils.get_date_str()
syntax
date = gh_utils.get_date_str_v2 (
format
)
parameters
format INTEGER 0 (Y.M.D.h.m.s) or 1 (Y.M.D@h:m:s)
return values
date STRING date
code sample
date = gh_utils.get_date_str_v2(1)
syntax
dir = gh_utils.get_demo_dir()
parameters
none
return values
dir STRING directory of the current scene file
code sample
demo_dir = gh_utils.get_demo_dir()
syntax
demo_zip_filename = gh_utils.get_demo_zip_filename()
parameters
none
return values
demo_zip_filename STRING filename of the main zip archive
code sample
main_zip_filename = gh_utils.get_demo_zip_filename()
get_desktop_resolution
Gets the default / native resolution of the desktop.
For example, with a fullHD monitor, you should get 1920, 1080.
syntax
width, height = gh_utils.get_desktop_resolution()
parameters
none
return values
width, height STRING resolution of the desktop in pixels
code sample
width, height = gh_utils.get_desktop_resolution()
syntax
elapsed_time = gh_utils.get_elapsed_time()
parameters
none
return values
elapsed_time REAL elapsed time in seconds
code sample
local elapsed_time = gh_utils.get_elapsed_time()
syntax
dir = gh_utils.get_lib_dir()
parameters
none
return values
dir STRING directory
code sample
lib_dir = gh_utils.get_lib_dir()
syntax
major, minor, build, name, codename = gh_utils.get_os_info()
parameters
none
return values
major, minor, build INTEGER version of the OS
name, codename STRING string identication of the OS
code sample
name, codename, major, minor, build = gh_utils.get_os_info()
get_platform
Returns the platform: 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
syntax
platform = gh_utils.get_platform()
parameters
none
return values
platform ENUM( platform ) 1 (Windows), 2 (macOS), 3 (Linux), 4 (Raspberry Pi), 5 (ASUS Tinker Board)
code sample
platform = gh_utils.get_platform()
get_platform_name
Returns the platform name: Windows xx-bit, macOS 10.x, Linux xx-bit, Raspberry Pi.
syntax
platform_name = gh_utils.get_platform_name()
parameters
none
return values
platform_name STRING the name of the platform
code sample
platform_name = gh_utils.get_platform_name()
syntax
dt = gh_utils.get_time_step()
parameters
none
return values
dt REAL time step in seconds
code sample
local dt = gh_utils.get_time_step()
syntax
uptime = gh_utils.get_uptime()
parameters
none
return values
uptime REAL up time in seconds
code sample
local uptime = gh_utils.get_uptime()
syntax
gh_utils.global_array_char_alloc (
num_elements,
max_string_len
)
parameters
num_elements INTEGER number of elements
max_string_len INTEGER max length of a string in a the array
return values
none
code sample
num_elements = 256
max_string_len = 1024
gh_utils.global_array_char_alloc(num_elements, max_string_len)
syntax
value = gh_utils.global_array_char_get (
index
)
parameters
index INTEGER index in the array
return values
value STRING value
code sample
index = 2
value = gh_utils.global_array_char_get(index)
syntax
gh_utils.global_array_char_set (
index,
value
)
parameters
index INTEGER index in the array
value STRING value
return values
none
code sample
index = 2
value = "Hello"
gh_utils.global_array_char_set(index, value)
syntax
gh_utils.global_array_float_alloc (
num_elements
)
parameters
num_elements INTEGER number of elements
return values
none
code sample
num_elements = 256
gh_utils.global_array_float_alloc(num_elements)
syntax
value = gh_utils.global_array_float_get (
index
)
parameters
index INTEGER index in the array
return values
value REAL value
code sample
index = 2
value = gh_utils.global_array_float_get(index)
syntax
gh_utils.global_array_float_set (
index,
value
)
parameters
index INTEGER index in the array
value REAL value
return values
none
code sample
index = 2
value = 3.14
gh_utils.global_array_float_set(index, value)
syntax
gh_utils.global_array_int_alloc (
num_elements
)
parameters
num_elements INTEGER number of elements
return values
none
code sample
num_elements = 256
gh_utils.global_array_int_alloc(num_elements)
syntax
value = gh_utils.global_array_int_get (
index
)
parameters
index INTEGER index in the array
return values
value INTEGER value
code sample
index = 2
value = gh_utils.global_array_int_get(index)
syntax
gh_utils.global_array_int_set (
index,
value
)
parameters
index INTEGER index in the array
value INTEGER value
return values
none
code sample
index = 2
value = 10
gh_utils.global_array_int_set(index, value)
grid_create
Creates a grid object.
syntax
grid_id = gh_utils.grid_create()
parameters
none
return values
grid_id ID grid identifier
code sample
grid_id = gh_utils.grid_create()
syntax
gh_utils.grid_set_display_lines_options (
grid_id,
display_main_lines,
display_lines
)
parameters
grid_id ID grid identifier
display_main_lines BOOLEAN display of main lines (axis + border): 1 (enabled) or 0 (disabled)
display_lines BOOLEAN display of lines: 1 (enabled) or 0 (disabled)
return values
none
code sample
gh_utils.grid_set_display_lines_options(grid_id, 1, 1)
syntax
gh_utils.grid_set_geometry_params (
grid_id,
x_size, z_size,
x_div, z_div
)
parameters
grid_id ID grid identifier
x_size, z_size REAL size
x_div, z_div INTEGER subdivisions
return values
none
code sample
gh_utils.grid_set_geometry_params(grid_id, 20, 20, 10, 10)
grid_set_lines_color
Sets grid color.
syntax
gh_utils.grid_set_lines_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_lines_color(grid_id, 0.7, 0.7, 0.7, 1)
syntax
gh_utils.grid_set_main_lines_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_lines_color(grid_id, 1.0, 1.0, 0.0, 1)
syntax
gh_utils.grid_set_main_x_axis_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_x_axis_color(grid_id, 1.0, 0.0, 0.0, 1)
syntax
gh_utils.grid_set_main_z_axis_color (
grid_id,
r, g, b, a
)
parameters
grid_id ID grid identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.grid_set_main_z_axis_color(grid_id, 0.0, 0.0, 1.0, 1)
syntax
r, g, b = gh_utils.hex_color_to_rgb (
html_color
)
parameters
html_color STRING color in HTML style
return values
r, g, b STRING RGB color
code sample
r, g, b = gh_utils.hex_color_to_rgb("#ff0044")
syntax
state = gh_utils.is_64bit()
parameters
none
return values
state BOOLEAN 1 (64-bit) or 0 (otherwise)
code sample
app_64bit = gh_utils.is_64bit()
syntax
state = gh_utils.is_luajit()
parameters
none
return values
state BOOLEAN 1 (LuaJIT) or 0 (otherwise)
code sample
is_luajit = gh_utils.is_luajit()
syntax
state = gh_utils.is_rpi()
parameters
none
return values
state BOOLEAN 1 if RPi and 0 otherwise
code sample
rpi = gh_utils.is_rpi()
line_create
Creates a simple line.
syntax
line_id = gh_utils.line_create()
parameters
none
return values
line_id ID line identifier
code sample
line_id = gh_utils.line_create()
gh_utils.line_set_start_position(line_id, -10, -10, 0.0)
gh_utils.line_set_start_color(line_id, 1, 1, 0, 1)
gh_utils.line_set_end_position(line_id, 10, 10, 0.0)
gh_utils.line_set_end_color(line_id, 1, 1, 1, 1)
syntax
gh_utils.line_set_end_color (
line_id,
r, g, b, a
)
parameters
line_id ID line identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.line_set_end_color(line_id, 1, 1, 0, 1)
syntax
gh_utils.line_set_end_position (
line_id,
x, y, z
)
parameters
line_id ID line identifier
x, y, z REAL position
return values
none
code sample
gh_utils.line_set_end_position(line_id, 10, 10, 0.0)
syntax
gh_utils.line_set_start_color (
line_id,
r, g, b, a
)
parameters
line_id ID line identifier
r, g, b, a REAL RGBA color
return values
none
code sample
gh_utils.line_set_start_color(line_id, 1, 1, 0, 1)
syntax
gh_utils.line_set_start_position (
line_id,
x, y, z
)
parameters
line_id ID line identifier
x, y, z REAL position
return values
none
code sample
gh_utils.line_set_start_position(line_id, -10, -10, 0.0)
syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8 = gh_utils.math_from_to_rotation_matrix3x3 (
from_x, from_y, from_z,
to_x, to_y, to_z
)
parameters
from_x, from_y, from_z REAL from 3D vector
to_x, to_y, to_z REAL to 3D vector
return values
m0,m1,m2,m3,m4,m5,m6,m7,m8 REAL the 9 floats that make the 3x3 matrix
code sample
m0,m1,m2,m3,m4,m5,m6,m7,m8 = gh_utils.math_from_to_rotation_matrix3x3(from_x, from_y, from_z, to_x, to_y, to_z)
syntax
len = gh_utils.math_length_vec3 (
x, y, z
)
parameters
x, y, z REAL vector
return values
len REAL length
code sample
len = gh_utils.math_length_vec3(x, y, z)
syntax
vx, vy, vz = gh_utils.math_normalize_vec3 (
x, y, z
)
parameters
x, y, z REAL vector
return values
vx, vy, vz REAL normalized vector
code sample
vx, vy, vz = gh_utils.math_normalize_vec3(x, y, z)
syntax
qx, qy, qz, qw = gh_utils.math_quat_from_euler_angles (
pitch, yaw, roll
)
parameters
pitch, yaw, roll REAL Euler angles
return values
qx, qy, qz, qw REAL rotation quaternion
code sample
qx, qy, qz, qw = gh_utils.math_quat_from_euler_angles(pitch, yaw, roll)
syntax
qx, qy, qz, qw = gh_utils.math_quat_from_lookat (
px, py, pz,
tx, ty