< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_mesh library

Description

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.


Number of functions: 65

  1. gh_mesh.alloc_mesh_data ()
  2. gh_mesh.create_box ()
  3. gh_mesh.create_box_8v ()
  4. gh_mesh.create_cylinder ()
  5. gh_mesh.create_cylinder_xyz ()
  6. gh_mesh.create_disc ()
  7. gh_mesh.create_ellipse ()
  8. gh_mesh.create_gear ()
  9. gh_mesh.create_icosphere ()
  10. gh_mesh.create_plane ()
  11. gh_mesh.create_plane_v3 ()
  12. gh_mesh.create_quad ()
  13. gh_mesh.create_sphere ()
  14. gh_mesh.create_terrain ()
  15. gh_mesh.create_torus ()
  16. gh_mesh.create_triangle ()
  17. gh_mesh.create_v2 ()
  18. gh_mesh.get_face_normal ()
  19. gh_mesh.get_face_vertex_indices ()
  20. gh_mesh.get_vertex_absolute_position ()
  21. gh_mesh.get_vertex_color ()
  22. gh_mesh.get_vertex_normal ()
  23. gh_mesh.get_vertex_position ()
  24. gh_mesh.get_vertex_tangent ()
  25. gh_mesh.get_vertex_uv ()
  26. gh_mesh.instancing_attrib_buffer_get ()
  27. gh_mesh.instancing_attrib_buffer_update_needed ()
  28. gh_mesh.instancing_get_color ()
  29. gh_mesh.instancing_get_orientation ()
  30. gh_mesh.instancing_get_position ()
  31. gh_mesh.instancing_get_scale ()
  32. gh_mesh.instancing_init ()
  33. gh_mesh.instancing_set_axis_angle ()
  34. gh_mesh.instancing_set_color ()
  35. gh_mesh.instancing_set_orientation ()
  36. gh_mesh.instancing_set_orientation_v2 ()
  37. gh_mesh.instancing_set_position ()
  38. gh_mesh.instancing_set_position_v2 ()
  39. gh_mesh.instancing_set_scale ()
  40. gh_mesh.resize_box ()
  41. gh_mesh.resize_plane ()
  42. gh_mesh.resize_quad ()
  43. gh_mesh.ribbon_add_point ()
  44. gh_mesh.ribbon_create ()
  45. gh_mesh.ribbon_set_cross_vector ()
  46. gh_mesh.set_face_vertex_indices ()
  47. gh_mesh.set_vertex_color ()
  48. gh_mesh.set_vertex_normal ()
  49. gh_mesh.set_vertex_position ()
  50. gh_mesh.set_vertex_tangent ()
  51. gh_mesh.set_vertex_uv ()
  52. gh_mesh.set_vertices_color ()
  53. gh_mesh.voxelize ()
  54. gh_mesh.meshlet_generate ()
  55. gh_mesh.meshlet_get_count ()
  56. gh_mesh.meshlet_get_vertex_count ()
  57. gh_mesh.meshlet_get_index_count ()
  58. gh_mesh.meshlet_get_vertex ()
  59. gh_mesh.meshlet_get_index ()
  60. gh_mesh.set_vertex_alloc_params_separate_vertex_arrays ()
  61. gh_mesh.vertices_to_gpu_buffer ()
  62. gh_mesh.vertices_from_gpu_buffer ()
  63. gh_mesh.vertices_position_to_gpu_buffer ()
  64. gh_mesh.vertices_position_from_gpu_buffer ()
  65. gh_mesh.set_vertex_source ()



alloc_mesh_data

Description

Allocates memory for mesh data (vertices and faces lists).


Syntax

gh_mesh.alloc_mesh_data(
 mesh_id,
 num_vertices,
 num_faces
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


mesh_triangle = gh_mesh.create()

gh_mesh.alloc_mesh_data(mesh_triangle, 3, 1)
			


create_box

Description

Creates a mesh box.


Syntax

mesh_id = gh_mesh.create_box(
 width, height, depth,
 wsegs, hsegs, dsegs
)

Languages


Parameters


Return Values


Code sample


mesh_box = gh_mesh.create_box(10.0, 10.0, 10.0, 4, 4, 4)
			


create_box_8v

Description

Creates a mesh box with 8 vertices.


Syntax

mesh_id = gh_mesh.create_box_8v(
 width, height, depth
)

Languages


Parameters


Return Values


Code sample


mesh_box = gh_mesh.create_box_8v(10.0, 10.0, 10.0)
			


create_cylinder

Description

Creates a mesh cylinder.


Syntax

mesh_id = gh_mesh.create_cylinder(
 radius,
 height,
 stacks,
 slices
)

Languages


Parameters


Return Values


Code sample


mesh_cyl = gh_mesh.create_cylinder(radius, height, stacks, slices)
			


create_cylinder_xyz

Description

Creates a mesh cylinder.


Syntax

mesh_id = gh_mesh.create_cylinder_xyz(
 central_axis,
 radius,
 height,
 stacks,
 slices
)

Languages


Parameters


Return Values


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

Description

Creates a mesh disc.


Syntax

mesh_id = gh_mesh.create_disc(
 radius,
 thickness,
 slices
)

Languages


Parameters


Return Values


Code sample


mesh_disc = gh_mesh.create_disc(radius, thickness, slices)
			


create_ellipse

Description

Creates a mesh ellipse.


Syntax

mesh_id = gh_mesh.create_ellipse(
 major_radius,
 minor_radius,
 slices,
 radius_segments,
 opening_angle
)

Languages


Parameters


Return Values


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

Description

Creates a mesh gear.


Syntax

mesh_id = gh_mesh.create_gear(
 inner_radius,
 outer_radius,
 tooth_depth,
 num_teeth,
 width
)

Languages


Parameters


Return Values


Code sample


mesh_gear = gh_mesh.create_gear(1.0, 4.0,  1.0, 10,  2.0)
			


create_icosphere

Description

Creates an ico-sphere mesh.


Syntax

mesh_id = gh_mesh.create_icosphere(
 radius,
 recursion_level
)

Languages


Parameters


Return Values


Code sample


mesh_icosphere = gh_mesh.create_icosphere(10.0, 2)
			


create_plane

Description

Creates a mesh plane.


Syntax

mesh_id = gh_mesh.create_plane(
 width, height,
 wsegs, hsegs
)

Languages


Parameters


Return Values


Code sample


mesh_plane = gh_mesh.create_plane(20.0, 10.0, 4, 4)
			


create_plane_v3

Description

Creates a mesh plane with an initial rotation.


Syntax

mesh_id = gh_mesh.create_plane_v3(
 width, height,
 wsegs, hsegs,
 pitch, yaw, roll
)

Languages


Parameters


Return Values


Code sample


mesh_plane = gh_mesh.create_plane_v3(20.0, 10.0, 4, 4, 45.0, 0, 0)
			


create_quad

Description

Creates a mesh quad. A quad is a mesh plane with only 4 vertices.


Syntax

mesh_id = gh_mesh.create_quad(
 width, height
)

Languages


Parameters


Return Values


Code sample


mesh_quad = gh_mesh.create_quad(20.0, 10.0)
			


create_sphere

Description

Creates a mesh sphere.


Syntax

mesh_id = gh_mesh.create_sphere(
 radius,
 stacks, slices
)

Languages


Parameters


Return Values


Code sample


mesh_sphere = gh_mesh.create_sphere(10.0, 20, 20)
			


create_terrain

Description

Creates a mesh terrain from a height map.


Syntax

mesh_id = gh_mesh.create_terrain(
 tex_id,
 num_subdivisions,
 vertical_scale,
 terrain_size,
 height_threshold
)

Languages


Parameters


Return Values


Code sample


mesh_terrain = gh_mesh.create_terrain(tex_id, num_subdivisions, vertical_scale, terrain_size, height_threshold)
			


create_torus

Description

Creates a mesh torus.


Syntax

mesh_id = gh_mesh.create_torus(
 outer_radius,
 inner_radius,
 slices
)

Languages


Parameters


Return Values


Code sample


mesh_torus = gh_mesh.create_torus(10.0, 4.0, 20)
			


create_triangle

Description

Creates a mesh triangle. Vertices are positioned in the range [-1.0;+1.0].


Syntax

mesh_id = gh_mesh.create_triangle()

Languages


Parameters

This function has no input parameter(s).


Return Values


Code sample


mesh_triangle = gh_mesh.create_triangle()
			


create_v2

Description

Creates a mesh.


Syntax

mesh_id = gh_mesh.create_v2()

Languages


Parameters

This function has no input parameter(s).


Return Values


Code sample


mesh_id = gh_mesh.create_v2()
			


get_face_normal

Description

Gets the normal vector of a face. Be sure that gh_object.compute_faces_normal() has been called before.


Syntax

x, y, z = gh_mesh.get_face_normal(
 mesh_id,
 face_index
)

Languages


Parameters


Return Values


Code sample


x, y, z = gh_mesh.get_face_normal(mesh_id, face_index)
			


get_face_vertex_indices

Description

Gets the vertex indices of a particular face.


Syntax

a, b, c = gh_mesh.get_face_vertex_indices(
 mesh_id,
 face_index
)

Languages


Parameters


Return Values


Code sample


a, b, c = gh_mesh.get_face_vertex_indices(mesh_id, face_index)
			


get_vertex_absolute_position

Description

Gets the absolute position of a particular vertex.


Syntax

x, y, z = gh_mesh.get_vertex_absolute_position(
 mesh_id,
 vertex_index
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
x, y, z = gh_mesh.get_vertex_absolute_position(mesh_id, vertex_index)
			


get_vertex_color

Description

Gets the RGBA color of a particular vertex.


Syntax

r, g, b, a = gh_mesh.get_vertex_color(
 mesh_id,
 vertex_index
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
r, g, b, a = gh_mesh.get_vertex_color(mesh_id, vertex_index)
			


get_vertex_normal

Description

Gets the normal vector of a particular vertex.


Syntax

x, y, z = gh_mesh.get_vertex_normal(
 mesh_id,
 vertex_index
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
x, y, z = gh_mesh.get_vertex_normal(mesh_id, vertex_index)
			


get_vertex_position

Description

Gets the relative position of a particular vertex.


Syntax

x, y, z, w = gh_mesh.get_vertex_position(
 mesh_id,
 vertex_index
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_position(mesh_id, vertex_index)
			


get_vertex_tangent

Description

Gets the tangent vector of a particular vertex.


Syntax

x, y, z, w = gh_mesh.get_vertex_tangent(
 mesh_id,
 vertex_index
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
x, y, z, w = gh_mesh.get_vertex_tangent(mesh_id, vertex_index)
			


get_vertex_uv

Description

Gets the texcoord of a particular vertex.


Syntax

x, y, z, w = gh_mesh.get_vertex_uv(
 mesh_id,
 vertex_index,
 tex_unit
)

Languages


Parameters


Return Values


Code sample


vertex_index = 0
tex_unit = 0

x, y, z, w = gh_mesh.get_vertex_uv(mesh_id, vertex_index, tex_unit)
			


instancing_attrib_buffer_get

Description

Returns the memory buffer of a particular vertex attrib. The pointer returned can be used with gh_utils.buffer_read_xxx() and gh_utils.buffer_write_xxx() functions.


Syntax

buff_ptr, buff_size = gh_mesh.instancing_attrib_buffer_get(
 mesh_id,
 va_index
)

Languages


Parameters


Return Values


Code sample


va_index = 0
position_ptr, size = gh_mesh.instancing_attrib_buffer_get(mesh_id, va_index)
			


instancing_attrib_buffer_update_needed

Description

Notifies GeeXLab that a vertex attrib buffer has been updated and needs to be uploaded on the GPU.


Syntax

gh_mesh.instancing_attrib_buffer_update_needed(
 mesh_id,
 va_index
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


va_index = 0
gh_mesh.instancing_attrib_buffer_update_needed(mesh_id, va_index)
			


instancing_get_color

Description

Gets the color of a particular instance.


Syntax

r, g, b, a = gh_mesh.instancing_get_color(
 mesh_id,
 index
)

Languages


Parameters


Return Values


Code sample


r, g, b, a = gh_mesh.instancing_get_color(mesh_id, instance)
			


instancing_get_orientation

Description

Gets the orientation of a particular instance.


Syntax

x, y, z, w = gh_mesh.instancing_get_orientation(
 mesh_id,
 index
)

Languages


Parameters


Return Values


Code sample


x, y, z, w = gh_mesh.instancing_get_orientation(mesh_id, instance)
			


instancing_get_position

Description

Gets the position of a particular instance.


Syntax

x, y, z, w = gh_mesh.instancing_get_position(
 mesh_id,
 index
)

Languages


Parameters


Return Values


Code sample


x, y, z, w = gh_mesh.instancing_get_position(mesh_id, instance)
			


instancing_get_scale

Description

Gets the scale of a particular instance.


Syntax

x, y, z, w = gh_mesh.instancing_get_scale(
 mesh_id,
 index
)

Languages


Parameters


Return Values


Code sample


x, y, z, w = gh_mesh.instancing_get_scale(mesh_id, instance)
			


instancing_init

Description

Initializes the geometry instancing rendering.


Syntax

gh_mesh.instancing_init(
 mesh_id,
 num_instances
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_axis_angle

Description

Sets the rotation axis and the angle of rotation around this axis for a particular instance.


Syntax

gh_mesh.instancing_set_axis_angle(
 mesh_id,
 index,
 x, y, z,
 angle
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_color

Description

Sets the color of a particular instance.


Syntax

gh_mesh.instancing_set_color(
 mesh_id,
 index,
 r, g, b, a
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_orientation

Description

Sets the orientation of a particular instance using Euler's angles.


Syntax

gh_mesh.instancing_set_orientation(
 mesh_id,
 index,
 pitch, yaw, roll
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_orientation_v2

Description

Sets the orientation of a particular instance with a quaternion.


Syntax

gh_mesh.instancing_set_orientation_v2(
 mesh_id,
 index,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_position

Description

Sets the position of a particular instance.


Syntax

gh_mesh.instancing_set_position(
 mesh_id,
 index,
 x, y, z
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_position_v2

Description

Sets the position of a particular instance.


Syntax

gh_mesh.instancing_set_position_v2(
 mesh_id,
 index,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


instancing_set_scale

Description

Sets the scaling factor of a particular instance.


Syntax

gh_mesh.instancing_set_scale(
 mesh_id,
 index,
 x, y, z
)

Languages


Parameters


Return Values

This function has no return value(s).


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
			


resize_box

Description

Updates the size of the mesh box (update the position of all vertices).


Syntax

gh_mesh.resize_box(
 width, height, depth,
 mesh_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.resize_box(mesh_id, 10.0, 10.0, 10.0)
			


resize_plane

Description

Updates the width and height of a mesh plane.


Syntax

gh_mesh.resize_plane(
 mesh_id,
 width, height
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.resize_plane(mesh_id, 20.0, 15.0)
			


resize_quad

Description

Updates the width and height of a mesh quad.


Syntax

gh_mesh.resize_quad(
 mesh_id,
 width, height
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.resize_quad(mesh_id, 20.0, 15.0)
			


ribbon_add_point

Description

Adds a new point to the ribbon. Each new point will generate the real geometry.


Syntax

gh_mesh.ribbon_add_point(
 mesh_id,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.ribbon_add_point(mesh_id, x, y, z, 1.0)
			


ribbon_create

Description

Creates a mesh ribbon. Once the ribbon object is created you need to call ribbon_add_point() to create vertices.


Syntax

mesh_id = gh_mesh.ribbon_create(
 thickness
)

Languages


Parameters


Return Values


Code sample


mesh_id = gh_mesh.ribbon_create(2.0)
			


ribbon_set_cross_vector

Description

Sets the cross vector that tunes the orientation of the ribbon.


Syntax

gh_mesh.ribbon_set_cross_vector(
 mesh_id,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.ribbon_set_cross_vector(mesh_id, x, y, z)
			


set_face_vertex_indices

Description

Sets the vertex indices of a particular face.


Syntax

gh_mesh.set_face_vertex_indices(
 mesh_id,
 face_index,
 a, b, c
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.set_face_vertex_indices(mesh_id, face_index, a, b, c)
			


set_vertex_color

Description

Sets the RGBA color of a particular vertex.


Syntax

gh_mesh.set_vertex_color(
 mesh_id,
 vertex_index,
 r, g, b, a
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


vertex_index = 0
gh_mesh.set_vertex_color(mesh_id, vertex_index, r, g, b, a)
			


set_vertex_normal

Description

Sets the normal vector of a particular vertex.


Syntax

gh_mesh.set_vertex_normal(
 mesh_id,
 vertex_index,
 x, y, z
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


vertex_index = 0
gh_mesh.set_vertex_normal(mesh_id, vertex_index, x, y, z)
			


set_vertex_position

Description

Sets the relative position of a particular vertex.


Syntax

gh_mesh.set_vertex_position(
 mesh_id,
 vertex_index,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


vertex_index = 0
gh_mesh.set_vertex_position(mesh_id, vertex_index, x, y, z, 1.0)
			


set_vertex_tangent

Description

Sets the tangent vector of a particular vertex.


Syntax

gh_mesh.set_vertex_tangent(
 mesh_id,
 vertex_index,
 x, y, z, w
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


vertex_index = 0
gh_mesh.set_vertex_tangent(mesh_id, vertex_index, x, y, z, w)
			


set_vertex_uv

Description

Sets the texcoord of a particular vertex.


Syntax

gh_mesh.set_vertex_uv(
 mesh_id,
 vertex_index,
 x, y, z, w,
 tex_unit
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


vertex_index = 0
tex_unit = 0

gh_mesh.set_vertex_uv(mesh_id, vertex_index, x, y, z, w, tex_unit)
			


set_vertices_color

Description

Sets the RGBA color of all vertices.


Syntax

gh_mesh.set_vertices_color(
 mesh_id,
 r, g, b, a
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.set_vertices_color(mesh_id, r, g, b, a)
			


voxelize

Description

Voxelizes a mesh.


Syntax

gh_mesh.voxelize(
 mesh_id,
 voxelsizex,
 voxelsizey,
 voxelsizez
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.voxelize(mesh_id, 4, 4, 4)
			


meshlet_generate

Description

Meshletizes (generates meshlets from) a regular mesh. Useful with mesh shaders.


Syntax

ret = gh_mesh.meshlet_generate(
 mesh_id,
 max_vertices,
 max_indices
)

Languages


Parameters


Return Values


Code sample


ret = gh_mesh.meshlet_generate(mesh_id, 64, 126)
			


meshlet_get_count

Description

Returns the number of meshlets of a mesh.


Syntax

n = gh_mesh.meshlet_get_count(
 mesh_id
)

Languages


Parameters


Return Values


Code sample


n = gh_mesh.meshlet_get_count(mesh_id)
			


meshlet_get_vertex_count

Description

Returns the number of vertices of a particular meshlet.


Syntax

num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count(
 mesh_id,
 meshlet_index
)

Languages


Parameters


Return Values


Code sample


num_meshlet_vertices = gh_mesh.meshlet_get_vertex_count(mesh_id)
			


meshlet_get_index_count

Description

Returns the number of indices of a particular meshlet.


Syntax

num_meshlet_indices = gh_mesh.meshlet_get_index_count(
 mesh_id,
 meshlet_index
)

Languages


Parameters


Return Values


Code sample


num_meshlet_indices = gh_mesh.meshlet_get_index_count(mesh_id)
			


meshlet_get_vertex

Description

Returns a index relative to the mesh (yes mesh) vertices list. This index is usually used to fill a GPU buffer for rendering with mesh shaders


Syntax

mesh_vertex_index = gh_mesh.meshlet_get_vertex(
 mesh_id,
 meshlet_index,
 meshlet_vertex_index
)

Languages


Parameters


Return Values


Code sample


mesh_vertex_index = gh_mesh.meshlet_get_vertex(mesh_id, meshlet_index, meshlet_vertex_index)
			


meshlet_get_index

Description

Returns a index relative to the meshlet (yes meshlet) indices list. This index is usually used to fill a GPU buffer for rendering with mesh shaders.


Syntax

mesh_face_index = gh_mesh.meshlet_get_index(
 mesh_id,
 meshlet_index,
 meshlet_primitive_index
)

Languages


Parameters


Return Values


Code sample


mesh_face_index = gh_mesh.meshlet_get_index(mesh_id, meshlet_index, meshlet_primitive_index)
			


set_vertex_alloc_params_separate_vertex_arrays

Description

Tells GeeXLab to create the next meshes with separate vertex arrays (state=1) or with an interleaved vertex array (state=0).


Syntax

gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(
 state
)

Languages


Parameters


Return Values

This function has no return value(s).


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)
			


vertices_to_gpu_buffer

Description

Copies the whole vertex array of a mesh to a GPU buffer. The mesh must have been created with an interleaved vertex array. Call gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(0) before creating the mesh. The GPU buffer must use a an interleaved vertex structure too.


Syntax

gh_mesh.vertices_to_gpu_buffer(
 mesh_id,
 gpu_buffer_id,
 gpu_buffer_offset
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.vertices_to_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset)
			


vertices_from_gpu_buffer

Description

Copies the vertex array from a GPU buffer to the mesh. The mesh must have been created with an interleaved vertex array. Call gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(0) before creating the mesh. The GPU buffer must use a an interleaved vertex structure too.


Syntax

gh_mesh.vertices_from_gpu_buffer(
 mesh_id,
 gpu_buffer_id,
 gpu_buffer_offset,
 size,
 update_cpu,
 update_gpu
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.vertices_from_gpu_buffer(mesh_id, gpu_buffer_id, gpu_buffer_offset, size, update_cpu, update_gpu)
			


vertices_position_to_gpu_buffer

Description

Copies the position of all vertices to a GPU buffer. The mesh can have an interleaved vertex array or separate vertex arrays.


Syntax

gh_mesh.vertices_position_to_gpu_buffer(
 mesh_id,
 gpu_buffer_id,
 gpu_buffer_offset,
 gpu_buffer_stride
)

Languages


Parameters


Return Values

This function has no return value(s).


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)
			


vertices_position_from_gpu_buffer

Description

Updates the position attribute of the mesh from a GPU buffer. The mesh can have an interleaved vertex array or separate vertex arrays.


Syntax

gh_mesh.vertices_position_from_gpu_buffer(
 mesh_id,
 gpu_buffer_id,
 gpu_buffer_offset,
 gpu_buffer_stride,
 size,
 update_cpu,
 update_gpu
)

Languages


Parameters


Return Values

This function has no return value(s).


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)
			


set_vertex_source

Description

Sets a GPU buffer as the source of vertices for a mesh. The mesh must have been created with an interleaved vertex array. Call gh_mesh.set_vertex_alloc_params_separate_vertex_arrays(0) before creating the mesh. The GPU buffer must use a an interleaved vertex structure too.


Syntax

gh_mesh.set_vertex_source(
 mesh_id,
 gpu_buffer_id
)

Languages


Parameters


Return Values

This function has no return value(s).


Code sample


gh_mesh.set_vertex_source(mesh_id, gpu_buffer_id)
			






GeeXLab Rootard Guide | Downloads | Contact