< 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

  1. gh_vr.apply_controller_transform ()
  2. gh_vr.get_controller_button_state ()
  3. gh_vr.get_num_controllers ()
  4. gh_vr.get_recommended_render_target_size ()
  5. gh_vr.is_initialized ()
  6. gh_vr.submit ()
  7. gh_vr.update_cameras ()
  8. gh_vr.update_cameras_v2 ()
  9. gh_vr.update_controller_transform ()
  10. 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


Return Values


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


Return Values


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


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


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


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


Return Values


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


Return Values


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


Return Values


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


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






GeeXLab Rootard Guide | Downloads | Contact