 Reference Guide Host-API Lua / Python
» Back to Homepage
» Back to Developer's Guide Index
gh_camera Library
gh_camera is the module that manages cameras: creation, destruction, setting the parameters (position, filed of view, etc.).
Number of functions: 12
gh_camera.create_perspective
Creates a perspective camera with default values (fov=60, znear=1, zfar=1000, aspect=win_width/win/height).
: Lua - Python
pos_x, pos_y, pos_z [REAL]: position of the camera.
lookat_x, lookat_y, lookat_z [REAL]: look at point of the camera.
camera [INTEGER]: camera identifier
:
camera = gh_camera.create_perspective(0, 20, 0, 0, 0, 0)
gh_camera.create_persp
Creates a perspective camera.
: Lua - Python
fov [REAL]: field of view in degres.
aspect [REAL]: aspect ration (usually screen_width / screen_height).
znear [REAL]: near clipping plane.
zfar [REAL]: far clipping plane.
camera [INTEGER]: camera identifier
:
camera = gh_camera.create_persp(60, 1.333, 0.1, 1000.0)
gh_camera.update_persp
Updates a perspective camera.
: Lua - Python
camera [INTEGER]: camera identifier.
fov [REAL]: field of view in degres.
aspect [REAL]: aspect ration (usually screen_width / screen_height).
znear [REAL]: near clipping plane.
zfar [REAL]: far clipping plane.
:
gh_camera.update_persp(camera, 60, 1.333, 0.1, 1000.0)
gh_camera.create_orthographic
Creates an orthographic camera with default values: left, right, top, bottom are derived from the window size.
: Lua - Python
camera [INTEGER]: camera identifier
:
camera = gh_camera.create_orthographic()
gh_camera.create_ortho
Creates an orthographic camera.
: Lua - Python
left [REAL]: left clipping plane.
right [REAL]: right clipping plane.
bottom [REAL]: bottom clipping plane.
top [REAL]: top clipping plane.
znear [REAL]: near clipping plane.
zfar [REAL]: far clipping plane.
camera [INTEGER]: camera identifier
:
w = screen_width
h = screen_height
camera = gh_camera.create_ortho(-w/2, w/2, -h/2, h/2, -1.0, 1.0)
gh_camera.update_ortho
Updates an orthographic camera.
: Lua - Python
camera [INTEGER]: camera identifier.
left [REAL]: left clipping plane.
right [REAL]: right clipping plane.
bottom [REAL]: bottom clipping plane.
top [REAL]: top clipping plane.
znear [REAL]: near clipping plane.
zfar [REAL]: far clipping plane.
:
w = screen_width
h = screen_height
gh_camera.update_ortho(camera, -w/2, w/2, -h/2, h/2, -1.0, 1.0)
gh_camera.set_viewport
Sets the camera viewport.
: Lua - Python
camera [INTEGER]: camera identifier.
x [REAL]: x offset - default: 0.
y [REAL]: y offset - default: 0.
width [REAL]: width of the viewport.
height [REAL]: height of the viewport.
:
gh_camera.set_viewport(camera, 0, 0, screen_width, screen_height)
gh_camera.set_position
Sets the camera position.
: Lua - Python
: setpos
camera [INTEGER]: camera identifier.
x, y, z [REAL]: 3D position of the camera.
:
gh_camera.set_position(camera, 0, 10, 20)
gh_camera.set_lookat
Sets the camera look at point (what point in space the camera is looking).
: Lua - Python
: setlookat
camera [INTEGER]: camera identifier.
x, y, z [REAL]: 3D position of that target point.
:
-- Look at the center of the scene:
gh_camera.set_lookat(camera, 0, 0, 0)
gh_camera.set_upvec
Sets the camera up vector.
: Lua - Python
: setupvec
camera [INTEGER]: camera identifier.
x, y, z [REAL]: direction of the up vector.
:
-- Th up vector is the unit Y axis.
gh_camera.set_upvec(camera, 0, 1, 0)
gh_camera.load_fixed_mvp_matrices
Loads the fixed projection and (model)view matrices.
: Lua - Python
camera [INTEGER]: camera identifier.
load_proj_mat [INTEGER]: 1 to load the projection matrix, 0 otherwise.
load_view_mat [INTEGER]: 1 to load the view matrix, 0 otherwise.
object_id [INTEGER]: Sets the object that will be used to update the modelview matrix. Set it to 0 to not use the object.
:
gh_camera.load_fixed_mvp_matrices(camera, load_proj_mat, load_view_mat, 0)
gh_camera.bind
Bind the camera to the renderer: the viewport and projection/view matrices are applied. Thi sfunction is useful in conjunction with the gh_object.render() function.
: Lua - Python
camera [INTEGER]: camera identifier.
:
gh_camera.bind(camera)
|