< GeeXLab Reference Guide />

> Back to Reference Guide Index


gh_camera library

Description

gh_camera is the module that manages cameras: creation, destruction, setting the parameters (position, filed of view, etc.).


Number of functions: 38

  1. gh_camera.bind (Lua - Python)
  2. gh_camera.bind_v2 (Lua - Python)
  3. gh_camera.create_ortho (Lua - Python)
  4. gh_camera.create_orthographic (Lua - Python)
  5. gh_camera.create_persp (Lua - Python)
  6. gh_camera.create_persp_v2 (Lua - Python)
  7. gh_camera.create_persp_v3 (Lua - Python)
  8. gh_camera.create_perspective (Lua - Python)
  9. gh_camera.frustum_check_object_aa_box (Lua - Python)
  10. gh_camera.frustum_check_object_sphere (Lua - Python)
  11. gh_camera.frustum_check_point (Lua - Python)
  12. gh_camera.frustum_check_sphere (Lua - Python)
  13. gh_camera.frustum_update (Lua - Python)
  14. gh_camera.get_euler_angles (Lua - Python)
  15. gh_camera.get_fov (Lua - Python)
  16. gh_camera.get_position (Lua - Python)
  17. gh_camera.get_view (Lua - Python)
  18. gh_camera.get_view_quaternion (Lua - Python)
  19. gh_camera.get_up_vector (Lua - Python)
  20. gh_camera.reset_reflection_matrix (Lua - Python)
  21. gh_camera.set_fov (Lua - Python)
  22. gh_camera.set_lookat (Lua - Python)
  23. gh_camera.set_orientation_cubemap (Lua - Python)
  24. gh_camera.set_pitch (Lua - Python)
  25. gh_camera.set_position (Lua - Python)
  26. gh_camera.set_reflection_matrix_v1 (Lua - Python)
  27. gh_camera.set_reflection_matrix_v2 (Lua - Python)
  28. gh_camera.set_roll (Lua - Python)
  29. gh_camera.set_upvec (Lua - Python)
  30. gh_camera.set_view_matrix_4x4 (Lua - Python)
  31. gh_camera.get_view_matrix_4x4 (Lua - Python)
  32. gh_camera.set_projection_matrix_4x4 (Lua - Python)
  33. gh_camera.get_projection_matrix_4x4 (Lua - Python)
  34. gh_camera.set_viewport (Lua - Python)
  35. gh_camera.set_yaw (Lua - Python)
  36. gh_camera.update_ortho (Lua - Python)
  37. gh_camera.update_persp (Lua - Python)
  38. gh_camera.update_persp_v2 (Lua - Python)



bind

Description

Bind the camera to the renderer: the viewport and projection/view matrices are applied. This function is useful in conjunction with the gh_object.render() function.


Syntax

gh_camera.bind(
 camera
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.bind(camera)
            


bind_v2

Description

Bind the camera to the renderer: the viewport and projection/view matrices are applied. This function is useful in conjunction with the gh_object.render() function.


Syntax

gh_camera.bind_v2(
 camera,
 update_viewport,
 update_scissor,
 update_proj_mat,
 update_view_mat,
 update_fixed_pipeline
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


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(camera, update_viewport, update_scissor, update_proj_mat, update_view_mat, update_fixed_pipeline)
            


create_ortho

Description

Creates an orthographic camera.


Syntax

camera = gh_camera.create_ortho(
 left,
 right,
 bottom,
 top,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
w = screen_width
h = screen_height
camera = gh_camera.create_ortho(-w/2, w/2, -h/2, h/2, -1.0, 1.0)
            


create_orthographic

Description

Creates an orthographic camera with default values: left, right, top, bottom are derived from the window size.


Syntax

camera = gh_camera.create_orthographic()

Languages

Lua - Python


Parameters

This function has no input parameter(s).


Return Values


Code sample

    
camera = gh_camera.create_orthographic()
            


create_persp

Description

Creates a perspective camera.


Syntax

camera = gh_camera.create_persp(
 fov,
 aspect,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
camera = gh_camera.create_persp(60, 1.333, 0.1, 1000.0)
            


create_persp_v2

Description

Creates a perspective camera.


Syntax

camera = gh_camera.create_persp_v2(
 fov,
 is_vertical_fov,
 aspect,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
camera = gh_camera.create_persp_v2(60, 1, 1.333, 0.1, 1000.0)
            


create_persp_v3

Description

Creates a perspective camera.


Syntax

camera = gh_camera.create_persp_v3(
 fov_x,
 fov_y,
 aspect,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
camera = gh_camera.create_persp_v3(60, 70, 1.333, 0.1, 1000.0)
            


create_perspective

Description

Creates a perspective camera with default values (fov=60, znear=1, zfar=1000, aspect=win_width/win/height).


Syntax

camera = gh_camera.create_perspective(
 pos_x, pos_y, pos_z,
 lookat_x, lookat_y, lookat_z
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
camera = gh_camera.create_perspective(0, 20, 0, 0, 0, 0)
            


frustum_check_object_aa_box

Description

Checks the collision between the camera frustum and the aligned bounding box of an object.


Syntax

collision = gh_camera.frustum_check_object_aa_box(
 camera,
 obj
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
collision = gh_camera.frustum_check_object_aa_box(camera, obj)
            


frustum_check_object_sphere

Description

Checks the collision between the camera frustum and the bounding sphere of an object.


Syntax

collision = gh_camera.frustum_check_object_sphere(
 camera,
 obj
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
collision = gh_camera.frustum_check_object_sphere(camera, obj)
            


frustum_check_point

Description

Checks the collision between the camera frustum and a point.


Syntax

collision = gh_camera.frustum_check_point(
 camera,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
collision = gh_camera.frustum_check_point(camera, x, y, z)
            


frustum_check_sphere

Description

Checks the collision between the camera frustum and a sphere.


Syntax

collision = gh_camera.frustum_check_sphere(
 camera,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
collision = gh_camera.frustum_check_sphere(camera, radius, x, y, z)
            


frustum_update

Description

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


Syntax

gh_camera.frustum_update(
 camera
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.frustum_update(camera)
            


get_euler_angles

Description

Gets the Euler's angles.


Syntax

pitch, yaw, roll = gh_camera.get_euler_angles(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
pitch, yaw, roll = gh_camera.get_euler_angles(camera)
            


get_fov

Description

Gets the camera field of view (fov).


Syntax

fov = gh_camera.get_fov(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
fov = gh_camera.get_fov(camera)
            


get_position

Description

Gets the camera position.


Syntax

x, y, z = gh_camera.get_position(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z = gh_camera.get_position(camera)
            


get_view

Description

Gets the camera direction (z axis or view vector).


Syntax

x, y, z = gh_camera.get_view(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z = gh_camera.get_view(camera)
            


get_view_quaternion

Description

Gets the camera view quaternion.


Syntax

x, y, z, w = gh_camera.get_view_quaternion(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z, w = gh_camera.get_view_quaternion(camera)
            


get_up_vector

Description

Gets the camera up vector (y axis).


Syntax

x, y, z = gh_camera.get_up_vector(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
x, y, z = gh_camera.get_up_vector(camera)
            


reset_reflection_matrix

Description

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

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.reset_reflection_matrix(camera)
            


set_fov

Description

Sets the camera field of view (fov).


Syntax

gh_camera.set_fov(
 camera,
 fov
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_fov(camera, 90)
            


set_lookat

Description

Sets the camera look at point (what point in space the camera is looking).


Syntax

gh_camera.set_lookat(
 camera,
 x, y, z, w
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
-- Look at the center of the scene:            
gh_camera.set_lookat(camera, 0, 0, 0, 1)
            


set_orientation_cubemap

Description

Sets the camera orientation according to a cubemap face.


Syntax

gh_camera.set_orientation_cubemap(
 camera,
 face
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
for face=0, 5 do
  gh_camera.set_orientation_cubemap(camera, face)
  ...
end  
            


set_pitch

Description

Sets the camera pitch angle (x axis).


Syntax

gh_camera.set_pitch(
 camera,
 pitch
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_pitch(camera, pitch)
            


set_position

Description

Sets the camera position.


Syntax

gh_camera.set_position(
 camera,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_position(camera, 0, 10, 20)
            


set_reflection_matrix_v1

Description

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(
 camera,
 px, py, pz,
 nx, ny, nz,
 y
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_reflection_matrix_v1(camera, 0, 10, 0, 0, 0, 1)
            


set_reflection_matrix_v2

Description

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(
 camera,
 a, b, c, d
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
a, b, c, d = gh_object.get_plane_equation(mirror_plane)
gh_camera.set_reflection_matrix_v2(camera, a, b, c, d)
            


set_roll

Description

Sets the camera roll angle (z axis).


Syntax

gh_camera.set_roll(
 camera,
 roll
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_roll(camera, roll)
            


set_upvec

Description

Sets the camera up vector.


Syntax

gh_camera.set_upvec(
 camera,
 x, y, z
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
-- Th up vector is the unit Y axis.
gh_camera.set_upvec(camera, 0, 1, 0)
            


set_view_matrix_4x4

Description

Sets the camera view matrix.


Syntax

gh_camera.set_view_matrix_4x4(
 camera,
 m00 ... m15
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_view_matrix_4x4(camera, m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15)
                    


get_view_matrix_4x4

Description

Gets the camera view matrix.


Syntax

m00 ... m15 = gh_camera.get_view_matrix_4x4(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15 = gh_camera.get_view_matrix_4x4(camera)
                    


set_projection_matrix_4x4

Description

Sets the camera projection matrix.


Syntax

gh_camera.set_projection_matrix_4x4(
 camera,
 m00 ... m15
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_projection_matrix_4x4(camera, m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15)
                    


get_projection_matrix_4x4

Description

Gets the camera projection matrix.


Syntax

m00 ... m15 = gh_camera.get_projection_matrix_4x4(
 camera
)

Languages

Lua - Python


Parameters


Return Values


Code sample

    
m00, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12, m13, m14, m15 = gh_camera.get_projection_matrix_4x4(camera)
                    


set_viewport

Description

Sets the camera viewport.


Syntax

gh_camera.set_viewport(
 camera,
 x,
 y,
 width,
 height
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_viewport(camera, 0, 0, screen_width, screen_height)
            


set_yaw

Description

Sets the camera yaw angle (y axis).


Syntax

gh_camera.set_yaw(
 camera,
 yaw
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.set_yaw(camera, yaw)
            


update_ortho

Description

Updates an orthographic camera.


Syntax

gh_camera.update_ortho(
 camera,
 left,
 right,
 bottom,
 top,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
w = screen_width
h = screen_height
gh_camera.update_ortho(camera, -w/2, w/2, -h/2, h/2, 1.0, -1.0)
            


update_persp

Description

Updates a perspective camera.


Syntax

gh_camera.update_persp(
 camera,
 fov,
 aspect,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

    
gh_camera.update_persp(camera, 60, 1.333, 0.1, 1000.0)
            


update_persp_v2

Description

Updates a perspective camera.


Syntax

gh_camera.update_persp_v2(
 camera,
 fov,
 is_vertical_fov,
 aspect,
 znear,
 zfar
)

Languages

Lua - Python


Parameters


Return Values

This function has no return value(s).


Code sample

 
local is_vertical_fov = 1            
gh_camera.update_persp_v2(camera, 60, is_vertical_fov, 1.333, 0.1, 1000.0)
            






GeeXLab Rootard Guide | Downloads | Contact | Newsletter