GLSL Hacker
FEATURES DOWNLOAD GALLERY BLOG LEARN



» Back to Reference Guide Index

gh_object Library

Description

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: 42



gh_object.create

Description

Create a minimal object that can be rendered with a tripod (its local space).

Languages

Lua - Python

Parameters

This function has no input parameter(s).

Return Values

  • object_id [INTEGER]: object identifier

    Code sample


    gizmo = gh_object.create()



    gh_object.set_position

    Description

    Sets the relative position of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: 3D position.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_position(mesh, x, y, z)



    gh_object.get_position

    Description

    Gets the relative position of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • x, y, z [REAL]: 3D position

    Code sample


    x, y, z = gh_object.get_position(object_id)



    gh_object.get_absolute_position

    Description

    Gets the absolute position of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • x, y, z [REAL]: 3D position

    Code sample


    x, y, z = gh_object.get_absolute_position(object_id)



    gh_object.set_euler_angles

    Description

    Sets the relative orientation of an object using the Euler's angles.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • pitch, yaw, roll [REAL]: Euler's angles.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_euler_angles(object_id, pitch, yaw, roll)



    gh_object.set_transform_order

    Description

    Sets the tranformation order to build the internal tranformation matrix.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • transform_order [INTEGER]: order of internal transformation: 0 (default: translation, rotation, scale) or 1 (rotation, translation, scale).

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_transform_order(object_id, 1)



    gh_object.set_orientation

    Description

    Sets the relative orientation of an object using a quaternion.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z, w [REAL]: orientation quaternion.

    Return Values

    This function has no return value(s).

    Code sample


    q = {x=0, y=0, z=, w=1}
    gh_object.set_orientation(object_id, q.x, q.y, q.z, q.w)



    gh_object.get_orientation_euler_angles

    Description

    Gets the relative orientation of an object using the Euler's angles.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • pitch, yaw, roll [REAL]: Euler's angles.

    Code sample


    pitch, yaw, roll = gh_object.get_orientation_euler_angles(object_id)



    gh_object.get_absolute_orientation_euler_angles

    Description

    Gets the absolute orientation of an object using the Euler's angles.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • pitch, yaw, roll [REAL]: Euler's angles.

    Code sample


    pitch, yaw, roll = gh_object.get_absolute_orientation_euler_angles(object_id)



    gh_object.get_orientation_vectors

    Description

    Gets the 3 axis that describe the relative orientation of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: 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(object_id)



    gh_object.get_orientation_vector_z

    Description

    Gets the Z axis of the relative orientation of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: 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(object_id)



    gh_object.get_absolute_orientation_vectors

    Description

    Gets the 3 axis that describe the absolute orientation of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: 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(object_id)



    gh_object.get_absolute_orientation_vector_z

    Description

    Gets the Z axis of the absolute orientation of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: 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(object_id)



    gh_object.transform_update_scale

    Description

    Handy function to update the scale of the relative transformation matrix. Position is also updated.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: 3D scaling factors.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.transform_update_scale(object_id, x, y, z)



    gh_object.set_scale

    Description

    Sets the relative scale of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: 3D scaling factors.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_scale(object_id, x, y, z)



    gh_object.set_scale_vertices_position

    Description

    Scale the position of all vertices.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: 3D scaling factors.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_scale_vertices_position(object_id, x, y, z)



    gh_object.copy_transform

    Description

    Copies the local transformation from one object to another one.

    Languages

    Lua - Python

    Parameters

  • dst_object [INTEGER]: destination object identifier.
  • src_object [INTEGER]: source object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.copy_transform(dst, src)



    gh_object.flip_faces

    Description

    Flip the faces of a triangular object (a mesh).

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.flip_faces(object_id)



    gh_object.flip_vertex_normals

    Description

    Flip the normals of all vertices.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.flip_vertex_normals(object_id)



    gh_object.use_fixed_mvp_matrices

    Description

    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.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • state [INTEGER]: use (1) or not use (0) the fixed matrices.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.use_fixed_mvp_matrices(object_id, 1)



    gh_object.use_opengl21

    Description

    Specifies if an object (usually a mesh) uses the old OpenGL (with built-in vertex attributes, etc...) or not for the rendering. If built-in vertex attributes are used, a GLSL shader is not required for the rendering (old OpenGL style).

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • state [INTEGER]: use (1) or not use (0).

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.use_opengl21(object_id, 1)



    gh_object.render

    Description

    Renders an object. This function supposes that gh_camera.bind() has been called.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_camera.bind(camera)
    gh_gpu_program.bind(prog)
    gh_object.render(mesh)



    gh_object.render_geometry

    Description

    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().

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    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

    Description

    Displays (renders) the tripod of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: size of each axis of the tripod. Default value is 1.0

    Return Values

    This function has no return value(s).

    Code sample


    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

    Description

    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.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • state [INTEGER]: true (1) or false (0).

    Return Values

    This function has no return value(s).

    Code sample


    -- Display the tripod
    gh_object.set_display_tripod_state(mesh, 1)
    gh_object.render(mesh)



    gh_object.set_tripod_size

    Description

    Sets the size (length) of object tripod axis.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • x, y, z [REAL]: length of each axis.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_tripod_size(mesh, 10, 10, 10)



    gh_object.display_grid

    Description

    Displays (renders) the a reference grid linked to the object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    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

    Description

    Sets the parameters of the object reference grid.

    Languages

    Lua - Python

    Parameters

  • 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.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_grid_params(mesh_torus, 50.0, 50.0, 20, 20, 1, 1)



    gh_object.set_display_grid_state

    Description

    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.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • state [INTEGER]: true (1) or false (0).

    Return Values

    This function has no return value(s).

    Code sample


    -- Display the grid
    gh_object.set_display_grid_state(mesh, 1)
    gh_object.render(mesh)



    gh_object.get_num_vertices

    Description

    Gets the number of vertices of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • num_vertices [INTEGER]: number of vertices

    Code sample


    num_vertices = gh_object.get_num_vertices(mesh)



    gh_object.get_num_faces

    Description

    Gets the number of triangular faces of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • num_faces [INTEGER]: number of faces

    Code sample


    num_faces = gh_object.get_num_faces(mesh)



    gh_object.set_tessellation_state

    Description

    Enables the rendering with hardware tessellation (OpenGL 4+). A tessellation GPU program is also required. This function works with meshes and models.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • state [INTEGER]: true (1) or false (0).

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_tessellation_state(mesh, 1)



    gh_object.compute_faces_normal

    Description

    Computes the normal vector of all faces.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.compute_faces_normal(mesh)



    gh_object.compute_vertices_normal

    Description

    Computes the normal vector of all vertices.

    Languages

    Lua

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.compute_vertices_normal(mesh)



    gh_object.average_vertices_normal

    Description

    Average the normal vector of all vertices.

    Languages

    Lua

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.average_vertices_normal(mesh)



    gh_object.get_num_materials

    Description

    Gets the number of materials of an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

  • num_materials [INTEGER]: number of materials

    Code sample


    num_materials = gh_object.get_num_materials(mesh)



    gh_object.get_material

    Description

    Gets a material from its index (0 ; get_num_materials()-1).

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • material_index [INTEGER]: material index.

    Return Values

  • material_id [INTEGER]: material identifier

    Code sample


    material_id = gh_object.get_material(mesh, 0)



    gh_object.add_material

    Description

    Adds a material to an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • material_id [INTEGER]: material identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.add_material(mesh, material_id)



    gh_object.remove_material

    Description

    Removes a material from an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • material_id [INTEGER]: material identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.remove_material(mesh, material_id)



    gh_object.remove_all_materials

    Description

    Removes all materials from an object.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.remove_all_materials(mesh)



    gh_object.get_distance

    Description

    Returns the distance between two objects.

    Languages

    Lua - Python

    Parameters

  • object1_id [INTEGER]: Object 1 identifier.
  • object2_id [INTEGER]: Object 2 identifier.

    Return Values

  • dist [REAL]: distance

    Code sample


    dist = gh_object.get_distance(object1_id, object2_id)



    gh_object.set_automatic_uniform_state

    Description

    Set the state (enabled or disabled) of automatic uniforms. If state is 0, the automatic uniforms specified by the mask are no longer send to the current GPU program.

    Languages

    Lua - Python

    Parameters

  • object_id [INTEGER]: Object identifier.
  • uniform_type [STRING]: currently only 'camera'

    Return Values

    This function has no return value(s).

    Code sample


    gh_object.set_automatic_uniform_state(object_id, state, "camera")





    2013-2015 Geeks3D. All Rights Reserved.

    .:- G3D Network -:.