< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_vr library
Description
gh_vr is the module that manages OpenVR functions. OpenVR allows you to render graphics into virtual reality headsets (or HMD) like HT Vive or Occulus Rift.
Number of functions: 10
- gh_vr.apply_controller_transform ()
- gh_vr.get_controller_button_state ()
- gh_vr.get_num_controllers ()
- gh_vr.get_recommended_render_target_size ()
- gh_vr.is_initialized ()
- gh_vr.submit ()
- gh_vr.update_cameras ()
- gh_vr.update_cameras_v2 ()
- gh_vr.update_controller_transform ()
- gh_vr.update_controllers_state ()
apply_controller_transform
Description
Applies the transformation matrix of the controller to the object used to visualize the controller.
Syntax
ret = gh_vr.apply_controller_transform(
controller_index,
controller_object,
hmd_object
)
Languages
Parameters
- controller_index [INTEGER]: XX identifier of the object used to visualize the controller
- controller_object [INTEGER]: platform index
- hmd_object [INTEGER]: HMD object. Can be 0 if there is no HMD object.
Return Values
- ret [BOOLEAN]: 1 (success) or 0 (error)
Code sample
ret = gh_vr.applay_controller_transform(controller_index, controller_object, hmd_object)
get_controller_button_state
Description
Returns the state of the controller button.
Syntax
button_pressed = gh_vr.get_controller_button_state(
controller_index
)
Languages
Parameters
- controller_index [INTEGER]: index of the controller (0 or 1)
Return Values
- button_pressed [BOOLEAN]: pressed: 1 (true) or 0 (false)
Code sample
button_pressed = gh_vr.get_controller_button_state(0)
get_num_controllers
Description
Returns the number of controllers.
Syntax
num_controllers = gh_vr.get_num_controllers()
Languages
Parameters
This function has no input parameter(s).
Return Values
- num_controllers [INTEGER]: number of controllers
Code sample
num_controllers = gh_vr.get_num_controllers()
get_recommended_render_target_size
Description
Returns the size of the render target required by the HMD.
Syntax
width, height = gh_vr.get_recommended_render_target_size()
Languages
Parameters
This function has no input parameter(s).
Return Values
- width, height [INTEGER]: size in pixels
Code sample
w, h = gh_vr.get_recommended_render_target_size()
is_initialized
Description
Checks if the VR initialization state.
Syntax
ret = gh_vr.is_initialized()
Languages
Parameters
This function has no input parameter(s).
Return Values
- ret [BOOLEAN]: 1 (success) or 0 (error)
Code sample
state = gh_vr.is_initialized()
submit
Description
Submit left and right render targets to the HMD and compose the VR scene.
Syntax
ret = gh_vr.submit(
rt_left_eye,
rt_right_eye
)
Languages
Parameters
- rt_left_eye [INTEGER]: left render target
- rt_right_eye [INTEGER]: right render target
Return Values
- ret [BOOLEAN]: 1 (success) or 0 (error)
Code sample
ret = gh_vr.submit(rt_left_eye, rt_right_eye)
update_cameras
Description
Updates left and right cameras according to HMD position and orientation.
Syntax
ret = gh_vr.update_cameras(
left_camera,
right_camera
)
Languages
Parameters
- left_camera [INTEGER]: left camera
- right_camera [INTEGER]: right camera
Return Values
- ret [BOOLEAN]: 1 (success) or 0 (error)
Code sample
ret = gh_vr.update_cameras(left_camera, right_camera)
update_cameras_v2
Description
Updates left and right cameras according to HMD orientation. The position is defined by the hmd_object.
Syntax
ret = gh_vr.update_cameras_v2(
left_camera,
right_camera,
hmd_object
)
Languages
Parameters
- left_camera [INTEGER]: left camera
- right_camera [INTEGER]: right camera
- hmd_object [INTEGER]: HMD object
Return Values
- ret [BOOLEAN]: 1 (success) or 0 (error)
Code sample
ret = gh_vr.update_cameras_v2(left_camera, right_camera, hmd_object)
update_controller_transform
Description
Updates the transformation matrix of the object that will be used to render a controller according to the transformation (position / orientation) of the HMD.
Syntax
gh_vr.update_controller_transform(
controller_index,
controller_id,
hmd_object_id
)
Languages
Parameters
- controller_index [INTEGER]: index of the controller
- controller_id [ID]: identifier of the object that represents a controller
- hmd_object_id [ID]: identifier of the object that represents the HMD
Return Values
This function has no return value(s).
Code sample
controller_id = gh_mesh.create_sphere()
...
gh_vr.update_controller_transform(controller_index, controller_id, hmd_object_id)
...
gh_object.render(controller_id)
update_controllers_state
Description
Updates the state of the controllers. Should be called once per frame.
Syntax
gh_vr.update_controllers_state()
Languages
Parameters
This function has no input parameter(s).
Return Values
This function has no return value(s).
Code sample
gh_vr.update_controllers_state()
| |