 Reference Guide Host-API Lua / Python
» Back to Homepage
» Back to Developer's Guide Index
gh_object Library
gh_object is the module that manages all renderable nodes, in other terms the objects. A mesh or a camera is an object while a texture is not an object (it's a resource).
Number of functions: 26
gh_object.create
Create a minimal object that can be rendered with a tripod (its local space).
: Lua - Python
object_id [INTEGER]: object identifier
:
gizmo = gh_object.create()
gh_object.set_position
Sets the relative position of an object.
: Lua - Python
: setpos
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: 3D position.
:
gh_object.set_position(mesh, x, y, z)
gh_object.get_position
Gets the relative position of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: 3D position
:
x, y, z = gh_object.get_position(object_id)
gh_object.get_absolute_position
Gets the absolute position of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: 3D position
:
x, y, z = gh_object.get_absolute_position(object_id)
gh_object.set_euler_angles
Sets the relative orientation of an object using the Euler's angles.
: Lua - Python
object_id [INTEGER]: Object identifier.
pitch, yaw, roll [REAL]: Euler's angles.
:
gh_object.set_euler_angles(object_id, pitch, yaw, roll)
gh_object.set_scale
Sets the relative scale of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: 3D scaling factors.
:
gh_object.set_scale(object_id, x, y, z)
gh_object.use_fixed_mvp_matrices
Tells GLSL Hacker to update OpenGL fixed matrices (modelview) with the object transform matrice when this object is rendered. By default GLSL Hacker expects an OpenGL 3+ (full shader) rendering.
: Lua - Python
object_id [INTEGER]: Object identifier.
state [INTEGER]: use (1) or not use (0) the fixed matrices.
:
gh_object.use_fixed_mvp_matrices(object_id, 1)
gh_object.use_gl2_vertex_array
Specifies if an object (usually a mesh) uses built-in vertex attributes or not for the rendering. If built-in vertex attributes are used, a GLSL shader is not required for the rendering (old OpenGL style).
: Lua - Python
object_id [INTEGER]: Object identifier.
state [INTEGER]: use (1) or not use (0).
:
gh_object.use_gl2_vertex_array(object_id, 1)
gh_object.render
Renders an object. This function supposes that gh_camera.bind() (or gh_camera.bind_ptr) has been called.
: Lua - Python
object_id [INTEGER]: Object identifier.
:
gh_camera.bind(camera)
gh_object.render(mesh)
gh_object.render_geometry
Renders only the object geometry. Transformation matrix or material/textures/gpu program are not bound, you have to manually bind them before calling render_geometry().
: Lua - Python
object_id [INTEGER]: Object identifier.
:
gh_gpu_program.bind(gpu_program)
gh_texture.bind(texture, 0)
gh_gpu_program.update_mvp_matrix(gpu_program, "gxl3d_ModelViewProjectionMatrix", camera, mesh_plane)
gh_object.render_geometry(mesh_plane)
gh_object.display_tripod
Displays (renders) the tripod of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: size of each axis of the tripod. Default value is 1.0
:
gh_gpu_program.bind(gpu_program)
gh_texture.bind(texture, 0)
gh_gpu_program.update_mvp_matrix(gpu_program, "gxl3d_ModelViewProjectionMatrix", camera, mesh_plane)
gh_object.render_geometry(mesh_plane)
gh_object.display_tripod(mesh_plane, 10, 10, 10)
gh_object.set_display_tripod_state
Sets the display state of the object tripod. This function has a meaning when the render() function is used to render an object. If you use render_geometry(), you have to use display_tripod() to draw the tripod.
: Lua - Python
object_id [INTEGER]: Object identifier.
state [INTEGER]: true (1) or false (0).
:
-- Display the tripod
gh_object.set_display_tripod_state(mesh, 1)
gh_object.render(mesh)
gh_object.set_tripod_size
Sets the size (length) of object tripod axis.
: Lua - Python
object_id [INTEGER]: Object identifier.
x, y, z [REAL]: length of each axis.
:
gh_object.set_tripod_size(mesh, 10, 10, 10)
gh_object.display_grid
Displays (renders) the a reference grid linked to the object.
: Lua - Python
object_id [INTEGER]: Object identifier.
:
gh_gpu_program.bind(gpu_program)
gh_texture.bind(texture, 0)
gh_gpu_program.update_mvp_matrix(gpu_program, "gxl3d_ModelViewProjectionMatrix", camera, mesh_torus)
gh_object.render_geometry(mesh_torus)
gh_object.set_grid_params(mesh_torus, 50.0, 50.0, 20, 20, 1, 1)
gh_object.display_grid(mesh_torus)
gh_object.set_grid_params
Sets the parameters of the object reference grid.
: Lua - Python
object_id [INTEGER]: Object identifier.
width, depth [REAL]: size of the grid. Default value is 10.0
nsegs_x, nsegs_z [INTEGER]: number of segments on the X and Z axis. Default value is 10.
display_lines [INTEGER]: enables (1) or disables (0) the display of grid inside lines.
display_outlines [INTEGER]: enables (1) or disables (0) the display of grid outlines.
:
gh_object.set_grid_params(mesh_torus, 50.0, 50.0, 20, 20, 1, 1)
gh_object.set_display_grid_state
Sets the display state of the object grid. This function has a meaning when the render() function is used to render an object. If you use render_geometry(), you have to use display_grid() to draw the grid.
: Lua - Python
object_id [INTEGER]: Object identifier.
state [INTEGER]: true (1) or false (0).
:
-- Display the grid
gh_object.set_display_grid_state(mesh, 1)
gh_object.render(mesh)
gh_object.get_num_vertices
Gets the number of vertices of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
num_vertices [INTEGER]: number of vertices
:
num_vertices = gh_object.get_num_vertices(mesh)
gh_object.get_num_faces
Gets the number of triangular faces of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
num_faces [INTEGER]: number of faces
:
num_faces = gh_object.get_num_faces(mesh)
gh_object.set_tessellation_state
Enables the rendering with hardware tessellation (OpenGL 4+). A tessellation GPU program is also required. This function works with meshes and models.
: Lua - Python
object_id [INTEGER]: Object identifier.
state [INTEGER]: true (1) or false (0).
:
gh_object.set_tessellation_state(mesh, 1)
gh_object.compute_faces_normal
Computes the normal vector of all faces.
: Lua - Python
object_id [INTEGER]: Object identifier.
:
gh_object.compute_faces_normal(mesh)
gh_object.compute_vertices_normal
Computes the normal vector of all vertices.
: Lua
object_id [INTEGER]: Object identifier.
:
gh_object.compute_vertices_normal(mesh)
gh_object.get_num_materials
Gets the number of materials of an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
num_materials [INTEGER]: number of materials
:
num_materials = gh_object.get_num_materials(mesh)
gh_object.get_material
Gets a material from its index (0 ; get_num_materials()-1).
: Lua - Python
object_id [INTEGER]: Object identifier.
material_index [INTEGER]: material index.
material_id [INTEGER]: material identifier
:
material_id = gh_object.get_material(mesh, 0)
gh_object.add_material
Adds a material to an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
material_id [INTEGER]: material identifier.
:
gh_object.add_material(mesh, material_id)
gh_object.remove_material
Removes a material from an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
material_id [INTEGER]: material identifier.
:
gh_object.remove_material(mesh, material_id)
gh_object.remove_all_materials
Removes all materials from an object.
: Lua - Python
object_id [INTEGER]: Object identifier.
:
gh_object.remove_all_materials(mesh)
|