< GeeXLab Reference Guide />
> 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: 52
- gh_object.add_material ()
- gh_object.average_vertices_normal ()
- gh_object.compute_faces_normal ()
- gh_object.compute_vertices_normal ()
- gh_object.copy_transform ()
- gh_object.create ()
- gh_object.flip_faces ()
- gh_object.flip_vertex_normals ()
- gh_object.get_absolute_orientation ()
- gh_object.get_absolute_orientation_euler_angles ()
- gh_object.get_absolute_orientation_vector_z ()
- gh_object.get_absolute_orientation_vectors ()
- gh_object.get_absolute_position ()
- gh_object.get_distance ()
- gh_object.get_material ()
- gh_object.get_num_faces ()
- gh_object.get_num_faces_v2 ()
- gh_object.get_num_materials ()
- gh_object.get_num_vertices ()
- gh_object.get_num_vertices_v2 ()
- gh_object.get_orientation ()
- gh_object.get_orientation_euler_angles ()
- gh_object.get_orientation_vector_z ()
- gh_object.get_orientation_vectors ()
- gh_object.get_plane_equation ()
- gh_object.get_position ()
- gh_object.get_transform ()
- gh_object.remove_all_materials ()
- gh_object.remove_material ()
- gh_object.render ()
- gh_object.render_geometry ()
- gh_object.render_geometry_draw ()
- gh_object.render_geometry_finish ()
- gh_object.render_geometry_prepare ()
- gh_object.rotate_vertices_position ()
- gh_object.rotate_vertices_position_euler_xyz ()
- gh_object.scale_vertices_position ()
- gh_object.set_absolute_transform_update_mode ()
- gh_object.set_automatic_uniform_state ()
- gh_object.set_euler_angles ()
- gh_object.set_materials_texture_unit_offset ()
- gh_object.set_orientation ()
- gh_object.set_position ()
- gh_object.set_scale ()
- gh_object.set_tessellation_state ()
- gh_object.set_transform ()
- gh_object.set_transform_order ()
- gh_object.set_vertices_color ()
- gh_object.smooth_vertices_normal ()
- gh_object.transform_update_scale ()
- gh_object.translate_vertices_position ()
- gh_object.update_automatic_uniforms ()
add_material
Description
Adds a material to a mesh.
Syntax
gh_object.add_material(
mesh_id,
mat_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- mat_id [ID]: material identifier
Return Values
This function has no return value(s).
Code sample
gh_object.add_material(mesh_id, mat_id)
average_vertices_normal
Description
Average the normal vector of all vertices.
Syntax
gh_object.average_vertices_normal(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.average_vertices_normal(mesh_id)
compute_faces_normal
Description
Computes the normal vector of all faces.
Syntax
gh_object.compute_faces_normal(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.compute_faces_normal(mesh_id)
compute_vertices_normal
Description
Computes the normal vector of all vertices.
Syntax
gh_object.compute_vertices_normal(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.compute_vertices_normal(mesh_id)
copy_transform
Description
Copies the local transformation from one object to another one.
Syntax
gh_object.copy_transform(
dst_obj_id,
src_obj_id
)
Languages
Parameters
- dst_obj_id [ID]: destination object identifier
- src_obj_id [ID]: source object identifier
Return Values
This function has no return value(s).
Code sample
gh_object.copy_transform(dst, src)
create
Description
Create a minimal object that can be rendered with a tripod (its local space).
Syntax
object_id = gh_object.create()
Languages
Parameters
This function has no input parameter(s).
Return Values
- object_id [ID]: object identifier
Code sample
gizmo = gh_object.create()
flip_faces
Description
Flip the faces of a triangular object (a mesh).
Syntax
gh_object.flip_faces(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.flip_faces(mesh_id)
flip_vertex_normals
Description
Flip the normals of all vertices.
Syntax
gh_object.flip_vertex_normals(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.flip_vertex_normals(mesh_id)
get_absolute_orientation
Description
Gets the quaternion that represents the absolute orientation of an object.
Syntax
x, y, z, w = gh_object.get_absolute_orientation(
obj_id
)
Languages
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)
get_absolute_orientation_euler_angles
Description
Gets the absolute orientation of an object using the Euler's angles.
Syntax
pitch, yaw, roll = gh_object.get_absolute_orientation_euler_angles(
obj_id
)
Languages
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)
get_absolute_orientation_vector_z
Description
Gets the Z axis of the absolute orientation of an object.
Syntax
x,y,z = gh_object.get_absolute_orientation_vector_z(
obj_id
)
Languages
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)
get_absolute_orientation_vectors
Description
Gets the 3 axis that describe the absolute orientation of an object.
Syntax
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_absolute_orientation_vectors(
obj_id
)
Languages
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)
get_absolute_position
Description
Gets the absolute position of an object.
Syntax
x, y, z = gh_object.get_absolute_position(
obj_id
)
Languages
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)
get_distance
Description
Returns the distance between two objects.
Syntax
dist = gh_object.get_distance(
obj1_id,
obj2_id
)
Languages
Parameters
- obj1_id [ID]: object 1 identifier
- obj2_id [ID]: object 2 identifier
Return Values
Code sample
dist = gh_object.get_distance(object1_id, object2_id)
get_material
Description
Gets a material from its index (0 ; get_num_materials()-1).
Syntax
mat_id = gh_object.get_material(
mesh_id,
material_index
)
Languages
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)
get_num_faces
Description
Gets the number of triangular faces of an object.
Syntax
num_faces = gh_object.get_num_faces(
mesh_id
)
Languages
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)
get_num_faces_v2
Description
Gets the number of triangular faces of an object and its whole hierarchy.
Syntax
num_faces = gh_object.get_num_faces_v2(
mesh_id
)
Languages
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)
get_num_materials
Description
Gets the number of materials of an object.
Syntax
num_materials = gh_object.get_num_materials(
mesh_id
)
Languages
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)
get_num_vertices
Description
Gets the number of vertices of an object.
Syntax
num_vertices = gh_object.get_num_vertices(
mesh_id
)
Languages
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)
get_num_vertices_v2
Description
Gets the number of vertices of an object and its whole hierarchy.
Syntax
num_vertices = gh_object.get_num_vertices_v2(
mesh_id
)
Languages
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)
get_orientation
Description
Gets the relative orientation quaternion of an object.
Syntax
x, y, z, w = gh_object.get_orientation(
obj_id
)
Languages
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)
get_orientation_euler_angles
Description
Gets the relative orientation of an object using the Euler's angles.
Syntax
pitch, yaw, roll = gh_object.get_orientation_euler_angles(
obj_id
)
Languages
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)
get_orientation_vector_z
Description
Gets the Z axis of the relative orientation of an object.
Syntax
x,y,z = gh_object.get_orientation_vector_z(
obj_id
)
Languages
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)
get_orientation_vectors
Description
Gets the 3 axis that describe the relative orientation of an object.
Syntax
x0,y0,z0, x1,y1,z1, x2,y2,z2 = gh_object.get_orientation_vectors(
obj_id
)
Languages
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)
get_plane_equation
Description
Gets the plane equation related to the object orientation.
Syntax
a, b, c, d = gh_object.get_plane_equation(
obj_id
)
Languages
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)
get_position
Description
Gets the relative position of an object.
Syntax
x, y, z = gh_object.get_position(
obj_id
)
Languages
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)
get_transform
Description
Gets the relative transformation matrix of an object.
Syntax
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 = gh_object.get_transform(
obj_id
)
Languages
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)
remove_all_materials
Description
Removes all materials from an object.
Syntax
gh_object.remove_all_materials(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.remove_all_materials(mesh_id)
remove_material
Description
Removes a material from an object.
Syntax
gh_object.remove_material(
mesh_id,
mat_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- mat_id [ID]: material identifier
Return Values
This function has no return value(s).
Code sample
gh_object.remove_material(mesh_id, mat_id)
render
Description
Renders an object.
Syntax
gh_object.render(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_camera.bind(cam_id)
gh_gpu_program.bind(gpuprog_id)
gh_object.render(mesh_id)
render_geometry
Description
Renders only the object geometry. Automatic uniforms are not updated and you have to call gh_object.update_automatic_uniforms() before calling render_geometry().
Syntax
gh_object.render_geometry(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
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
Description
Draws the geometry.
Syntax
gh_object.render_geometry_draw(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
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)
render_geometry_finish
Description
Finishes the geometry drawing.
Syntax
gh_object.render_geometry_finish(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
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)
render_geometry_prepare
Description
Prepares the geometry drawing.
Syntax
gh_object.render_geometry_prepare(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
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)
rotate_vertices_position
Description
Rotates the position of all vertices by a rotation quaternion.
Syntax
gh_object.rotate_vertices_position(
mesh_id,
x, y, z, w
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- x, y, z, w [REAL]: quaternion
Return Values
This function has no return value(s).
Code sample
gh_object.rotate_vertices_position(mesh_id, x, y, z, w)
rotate_vertices_position_euler_xyz
Description
Rotates the position of all vertices using Euler's angles.
Syntax
gh_object.rotate_vertices_position_euler_xyz(
mesh_id,
pitch, yaw, roll
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- pitch, yaw, roll [REAL]: Euler's angles
Return Values
This function has no return value(s).
Code sample
gh_object.rotate_vertices_position_euler_xyz(mesh_id, pitch, yaw, roll)
scale_vertices_position
Description
Scales the position of all vertices by a scaling vector.
Syntax
gh_object.scale_vertices_position(
mesh_id,
x, y, z
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- x, y, z [REAL]: scaling vector
Return Values
This function has no return value(s).
Code sample
gh_object.scale_vertices_position(mesh_id, x, y, z)
set_absolute_transform_update_mode
Description
Sets the transformation mode (or order) to build the absolute transformation matrix: 0 (parent * object) or 1 (object * parent).
Syntax
gh_object.set_absolute_transform_update_mode(
obj_id,
transform_mode
)
Languages
Parameters
- obj_id [ID]: object identifier
- transform_mode [ENUM]: order of internal transformation: default 0 (parent * object) or 1 (object * parent)
Return Values
This function has no return value(s).
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)
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.
Syntax
gh_object.set_automatic_uniform_state(
obj_id,
state,
uniform_type
)
Languages
Parameters
- obj_id [ID]: object identifier
- state [BOOLEAN]: 1 (enabled) or 0 (disabled)
- uniform_type [STRING]: currently only 'camera'
Return Values
This function has no return value(s).
Code sample
gh_object.set_automatic_uniform_state(obj_id, state, "camera")
set_euler_angles
Description
Sets the relative orientation of an object using the Euler's angles.
Syntax
gh_object.set_euler_angles(
obj_id,
pitch, yaw, roll
)
Languages
Parameters
- obj_id [ID]: 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(obj_id, pitch, yaw, roll)
set_materials_texture_unit_offset
Description
Specifies an offset to apply to material texture units. Useful with shadow mapping for example.
Syntax
gh_object.set_materials_texture_unit_offset(
mesh_id,
offset
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- offset [INTEGER]: texture unit offset
Return Values
This function has no return value(s).
Code sample
offset = 1
gh_object.set_materials_texture_unit_offset(mesh_id, offset)
set_orientation
Description
Sets the relative orientation of an object using a quaternion.
Syntax
gh_object.set_orientation(
obj_id,
x, y, z, w
)
Languages
Parameters
- obj_id [ID]: 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=0, w=1}
gh_object.set_orientation(obj_id, q.x, q.y, q.z, q.w)
set_position
Description
Sets the relative position of an object.
Syntax
gh_object.set_position(
obj_id,
x, y, z
)
Languages
Parameters
- obj_id [ID]: object identifier
- x, y, z [REAL]: 3D position
Return Values
This function has no return value(s).
Code sample
gh_object.set_position(obj_id, x, y, z)
set_scale
Description
Sets the relative scale of an object.
Syntax
gh_object.set_scale(
obj_id,
x, y, z
)
Languages
Parameters
- obj_id [ID]: object identifier
- x, y, z [REAL]: 3D scaling factors
Return Values
This function has no return value(s).
Code sample
gh_object.set_scale(obj_id, x, y, z)
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.
Syntax
gh_object.set_tessellation_state(
mesh_id,
tessellation
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- tessellation [BOOLEAN]: tessellation enabled: 1 (true) or 0 (false)
Return Values
This function has no return value(s).
Code sample
gh_object.set_tessellation_state(mesh_id, 1)
set_transform
Description
Sets the relative transformation matrix of an object.
Syntax
gh_object.set_transform(
obj_id,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
Languages
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
This function has no return value(s).
Code sample
gh_object.set_transform(obj_id, m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
set_transform_order
Description
Sets the transformation order to build the internal transformation matrix.
Syntax
gh_object.set_transform_order(
obj_id,
transform_order
)
Languages
Parameters
- obj_id [ID]: object identifier
- transform_order [ENUM]: order of internal transformation: default 0 (translation, rotation, scale), 1 (rotation, translation, scale), 2 and 3
Return Values
This function has no return value(s).
Code sample
gh_object.set_transform_order(obj_id, 1)
set_vertices_color
Description
Sets the color of all vertices.
Syntax
gh_object.set_vertices_color(
mesh_id,
r, g, b, a
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- r, g, b, a [REAL]: RGBA color
Return Values
This function has no return value(s).
Code sample
gh_object.set_vertices_color(mesh_id, r, g, b, a)
smooth_vertices_normal
Description
Average the normal vector of all vertices.
Syntax
gh_object.smooth_vertices_normal(
mesh_id
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
Code sample
gh_object.smooth_vertices_normal(mesh_id)
transform_update_scale
Description
Handy function to update the scale of the relative transformation matrix. Position is also updated.
Syntax
gh_object.transform_update_scale(
obj_id,
x, y, z
)
Languages
Parameters
- obj_id [ID]: 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(obj_id, x, y, z)
translate_vertices_position
Description
Translates the position of all vertices by a translation vector.
Syntax
gh_object.translate_vertices_position(
mesh_id,
x, y, z
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
- x, y, z [REAL]: translation vector
Return Values
This function has no return value(s).
Code sample
gh_object.translate_vertices_position(mesh_id, x, y, z)
update_automatic_uniforms
Description
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
)
Languages
Parameters
- mesh_id [ID]: mesh identifier
Return Values
This function has no return value(s).
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)
| |