Link Search Menu Expand Document

Class OGLCanvas_

About :

OGLCanvas implementation with GL

Class diagram of class of OGLCanvas_.

Functions

Function summury
__init__(self, parent, name=’GL window’, shared_canvas=None, at_init=None, stereo=False, app=None) Create a OGLCanvas, associated to a parant window (more…)
share_context(self, shared_canvas, key=None)  
edited(self, edited=True)  
free_context_vbos(self, key, free_context=True) Free current VBOs in graphic card (more…)
remove_vbo_key(self, key)  
set_context_data(self, key, vbo)  
set_context_sub_data(self, key, offset, data)  
set_context_colors(self, key, vbo)  
set_context_indices(self, key, vbo)  
set_context_faces(self, key, vbo)  
set_current_gl_context(self) Associate open gl context as current for any openGL action (more…)
get_gl_context(self) Get the open gl context of this canvas (more…)
new_gl_context(self) Get the open gl context of this canvas (more…)
add_texture(self, texture) Create a dictionnary of texture associated with the canvas (more…)
on_exit(self, event)  
get_frame_step_duration(self)  
get_size(self)  
on_keyboard(self, event=None) internal callback called whenever the canvas is resized (more…)
activate_keyboard(self, activate=True) activate keyboard callback (more…)
activate_mouse(self, motion=True, left=True, middle=True, right=True, wheel=True) activate mouse callback (more…)
__del__(self) when deleting a canvas, it must be removed from the App and from the scene (more…)
init_shaders(self) Create the canvas shaders (more…)
set_keyboard_focuss(self, node=None) Associate the keyboard focuss to a graphic node of the canvas scene (more…)
get_camera_space_light(self) Returns a light which enlights objects in camera space (more…)
render_single_eye(self)  
render_shutter(self)  
render_right(self)  
render_left(self)  
render(self)  
screenshot_cv2(self, filename)  
screenshot_pil(self, file_)  
screenshot(self, filename)  
get_eye_gap(self)  
set_eye_gap(self, gap) gap in meter about 0.06 to 0.07 (more…)
set_eye_main(self, main=0) main=0 : left (more…)
set_shutter(self, shutter=True, eye_main=0)  
shutter_enabled(self)  
set_cylcope(self)  
set_blind_right(self, eye_main=0)  
set_blind_left(self, eye_main=0)  
set_fish_eye(self, use=False, k=None, p=None)  
set_shape(self, use=False, transform=None, cut=False, cut_box=[-1, -1, 1, 1])  
shape_project_backward(self, x, y)  
shape_project_forward(self, x, y)  
get_props(self) get a property texture associated with a node key (more…)
before_set_property_cb(self, key, ix, iy, subdata, what)  
after_set_property_cb(self, key, ix, iy, subdata, what)  
set_viewport(self) function called by on_size (more…)
enable_drag_node(self, interactor=’mouse’, drag=True) enables dragging an individual node (more…)
enable_drag_scene(self, interactor=’mouse’, space=0, node=None) enables dragging the overall space (more…)
enable_drag_camera(self, interactor=’mouse’, drag=True) enables dragging the camera (more…)
drag_node(self, interactor=’mouse’) returns if an individual nodes are draggable (more…)
drag_scene(self, interactor=’mouse’) returns if the root of an individual picked nodes is draggable (more…)
drag_camera(self, interactor=’mouse’) returns if the camera is draggable (more…)
set_background_color(self, r=0.25, g=0.25, b=0.3, a=1) set the window background color (more…)
set_panorama(self, texture=None, use=True)  
set_panorama_use(self, use=True)  
set_panorama_transform(self)  
set_background_texture(self, texture=None, use=True)  
set_background_texture_use(self, use=True)  
set_projection_perspective(self, near=0.1, far=100, view_angle=30) set the projection by perspective parameters (more…)
set_projection_matrix(self, matrix)  
set_projection_frustum(self, l, r, b, t, near, far) set the projection by frustum parameters (more…)
set_clipping_planes(self, near, far) set the projection clipping planes only (more…)
set_projection_type(self, frustum=0) select the projection type (more…)
get_camera_frame__(self) Build the main frame associated with the camera (more…)
get_camera_frame(self)  
set_camera__(self, eye=(0, -10, 0), focal=(0, 0, 0), up=(0, 0, 1), propagate=True)  
set_camera(self, eye=(0, -10, 0), focal=(0, 0, 0), up=(0, 0, 1), propagate=True) set the model view matric respect to eye, focal and up direction of gaze (more…)
auto_scale(self, node=None, propagate=True) Move observer to make the 3D scene fit in his view point (more…)
set_sky_box(self, skybox)  
get_sky_box(self)  
set_sky_box_transform(self, transform=None)  
add_node(self, node, space=0) obj : display_list (more…)
get_nodes(self, space=0) Get the canvas graphic root nodes (more…)
get_nodes_from_path(self, space, path) From a given path provides a list of corresponding graphic nodes (more…)
remove_node(self, space=0, key=None) delete a root node from the scene. (more…)
set_ambient_light(self, r, g, b)  
add_light(self, light, key=None) Add a light to the scene (more…)
get_lights(self) Get Lights of the scene (more…)
remove_light(self, light) Remove light from the scene (more…)
activate_trackball(self, active=True) activate or disactivate default trackball events (more…)
add_picking_avatar(self, avatar) avatar is a node repreresenting the selection device. Even if it mask selected objects it should not be selected (more…)
remove_picking_avatar(self, avatar) avatar is a node repreresenting the selection device. Even if it mask selected objects it should not be selected (more…)
pick(self, x, y) Main picking function (more…)
pick_ray(self, origin, direction) Picking function if ray mode (more…)
shot(self, device=None, x=0, y=0, propagate=True) Interaction picking (more…)
shot_ray(self, device=None, origin=(0, 0, 0), direction=(1, 0, 0), propagate=True) Interaction picking in ray mode (more…)
move(self, device=None, x=0, y=0, picked=None) Interaction picking when a 2D device (like the mouse is moved’ (more…)
move_ray(self, device=None, origin=(0, 0, 0), direction=(1, 0, 0)) Interaction picking in ray mode when the device is moved (more…)
unshot(self, device=None) Interaction unpick (more…)
send_events(self, events={}) When a node emit events it call this methods that can be overloaded to modify the application content (more…)
get_font(self, name) Get a font object from its name (more…)
switch_cave_mode_P38(self, stereo=False)  
switch_cave_mode(self, stereo=False)  
cave_reset_window_positions(self)  
switch_hmd_mode(self)  
openvr(self) return the openvr instance (more…)
switch_openvr_mode(self)  
openvr_calibrate(self, pose=0, x=[0, -2, 1.7], xn=[1, 0, 0], yn=[0, 0, 1], zn=[0, -1, 0])  
slave_send(self, data=[‘background’, (1, 1, 1, 1)], answer=False) synchronize active canvas slaves (more…)
slave_wait(self)  
slave_share_array(self, key, array, data=[]) synchronize active canvas slaves (more…)
synchro_order(self, data=[‘background’, (1, 1, 1, 1)]) synchronize active canvas slaves (more…)
synchro_done(self) wait for last order to be finalised for every slaves. (more…)
synchro_set(self, state=True)  
synchro_share_array(self, array, target=[], verbose=None) synchronize an array with slaves (more…)
replace(self, last, new)  

Methods desciption :

init

def __init__(self, parent, name='GL window', shared_canvas=None, at_init=None, stereo=False, app=None)

Create a OGLCanvas, associated to a parant window This canvas may be linked to another canva context through shared context

  • → parent window
  • → canvas name which may be different from the frame name One frame may contain several canvas
  • → othercontext : the context of another canvas (canva._context) to be shared with the current one. Then they share the same opengl generated lists and textures
  • → at_init(canvas) : method to be called to initialize the scene

share_context

def share_context(self, shared_canvas, key=None)

edited

def edited(self, edited=True)

free_context_vbos

def free_context_vbos(self, key, free_context=True)

Free current VBOs in graphic card

remove_vbo_key

def remove_vbo_key(self, key)

set_context_data

def set_context_data(self, key, vbo)

set_context_sub_data

def set_context_sub_data(self, key, offset, data)

set_context_colors

def set_context_colors(self, key, vbo)

set_context_indices

def set_context_indices(self, key, vbo)

set_context_faces

def set_context_faces(self, key, vbo)

set_current_gl_context

def set_current_gl_context(self)

Associate open gl context as current for any openGL action It make this canvas currently concerned by OpenGL Calls

get_gl_context

def get_gl_context(self)

Get the open gl context of this canvas

  • ← the canvas context

new_gl_context

def new_gl_context(self)

Get the open gl context of this canvas

  • ← a new canvas context

add_texture

def add_texture(self, texture)

Create a dictionnary of texture associated with the canvas

on_exit

def on_exit(self, event)

get_frame_step_duration

def get_frame_step_duration(self)

get_size

def get_size(self)

on_keyboard

def on_keyboard(self, event=None)

internal callback called whenever the canvas is resized Keyboard event

Indeed the keyboard event is redirected a single callback associated with th OGLApp

activate_keyboard

def activate_keyboard(self, activate=True)

activate keyboard callback

  • → activate : boolean

activate_mouse

def activate_mouse(self, motion=True, left=True, middle=True, right=True, wheel=True)

activate mouse callback

  • → motion : mouse motion is tracked
  • → left : left button is tracked
  • → middle : middle button is tracked
  • → right : right button is tracked
  • → wheel : wheel button is tracked

del

def __del__(self)

when deleting a canvas, it must be removed from the App and from the scene

init_shaders

def init_shaders(self)

Create the canvas shaders

set_keyboard_focuss

def set_keyboard_focuss(self, node=None)

Associate the keyboard focuss to a graphic node of the canvas scene

  • → node : the graphic node

get_camera_space_light

def get_camera_space_light(self)

Returns a light which enlights objects in camera space

  • ← the corresponding light

render_single_eye

def render_single_eye(self)

render_shutter

def render_shutter(self)

render_right

def render_right(self)

render_left

def render_left(self)

render

def render(self)

screenshot_cv2

def screenshot_cv2(self, filename)

screenshot_pil

def screenshot_pil(self, file_)

screenshot

def screenshot(self, filename)

get_eye_gap

def get_eye_gap(self)

set_eye_gap

def set_eye_gap(self, gap)

gap in meter about 0.06 to 0.07

set_eye_main

def set_eye_main(self, main=0)

main=0 : left main=1 : right main=2 : center

set_shutter

def set_shutter(self, shutter=True, eye_main=0)

shutter_enabled

def shutter_enabled(self)

set_cylcope

def set_cylcope(self)

set_blind_right

def set_blind_right(self, eye_main=0)

set_blind_left

def set_blind_left(self, eye_main=0)

set_fish_eye

def set_fish_eye(self, use=False, k=None, p=None)

set_shape

def set_shape(self, use=False, transform=None, cut=False, cut_box=[-1, -1, 1, 1])

shape_project_backward

def shape_project_backward(self, x, y)

shape_project_forward

def shape_project_forward(self, x, y)

get_props

def get_props(self)

get a property texture associated with a node key if none then a texture is created and associated to all the canvas sharing the scene

before_set_property_cb

def before_set_property_cb(self, key, ix, iy, subdata, what)

after_set_property_cb

def after_set_property_cb(self, key, ix, iy, subdata, what)

set_viewport

def set_viewport(self)

function called by on_size

enable_drag_node

def enable_drag_node(self, interactor='mouse', drag=True)

enables dragging an individual node The boolean value acts a an overall lock on node moves

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → drag : boolean
  • → focus : a single node may be dragged : None whatever node may be dragged

enable_drag_scene

def enable_drag_scene(self, interactor='mouse', space=0, node=None)

enables dragging the overall space

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → space : dragged space index 0 -> 3D space, 1 -> camera space , 2 -> screen space. otherwise : Nothing dragged

enable_drag_camera

def enable_drag_camera(self, interactor='mouse', drag=True)

enables dragging the camera

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → drag : boolean

drag_node

def drag_node(self, interactor='mouse')

returns if an individual nodes are draggable The boolean value acts a an overall lock on node moves

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → drag : boolean
  • ← the drag node lock for the interactor

drag_scene

def drag_scene(self, interactor='mouse')

returns if the root of an individual picked nodes is draggable The boolean value acts a an overall lock on the nodes

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → drag : boolean
  • ← dragged space index for the interactor, None if no space may be dragged

drag_camera

def drag_camera(self, interactor='mouse')

returns if the camera is draggable The boolean value acts a lock on the camera motion

  • → interactor : whatever identificator of an interactor. basic mouse is identified by the string ‘mouse’
  • → drag : boolean
  • ← the drag camera lock for the interactor

set_background_color

def set_background_color(self, r=0.25, g=0.25, b=0.3, a=1)

set the window background color

  • → r : red component ([0,1])
  • → g : green component ([0,1])
  • → b : blue component ([0,1])
  • → a : transparency component ([0,1]) if the Window System allows it

set_panorama

def set_panorama(self, texture=None, use=True)

set_panorama_use

def set_panorama_use(self, use=True)

set_panorama_transform

def set_panorama_transform(self)

set_background_texture

def set_background_texture(self, texture=None, use=True)

set_background_texture_use

def set_background_texture_use(self, use=True)

set_projection_perspective

def set_projection_perspective(self, near=0.1, far=100, view_angle=30)

set the projection by perspective parameters

  • → n : near plane
  • → f : far plane
  • → viewangle : global view angle from bottom to top

set_projection_matrix

def set_projection_matrix(self, matrix)

set_projection_frustum

def set_projection_frustum(self, l, r, b, t, near, far)

set the projection by frustum parameters

  • → l : left side of screen
  • → r : right side of screen
  • → b : bottom side of screen
  • → t : top side of screen
  • → near : near plane
  • → far : far plane

set_clipping_planes

def set_clipping_planes(self, near, far)

set the projection clipping planes only

  • → near : near plane
  • → far : far plane

set_projection_type

def set_projection_type(self, frustum=0)

select the projection type

  • → frustum_view : 1 frustum oblique parameters are used 0 perspective mode is used. 2 a specific projection matrix is used

get_camera_frame__

def get_camera_frame__(self)

Build the main frame associated with the camera

  • ← a tuple (xe,ye,ze,f) where :
  • xe,ye,ze if the eye main directions
  • xe is the right direction from the camera
  • ye is the up direction
  • ze is the gaze direction
  • f is the focal distance from eye

get_camera_frame

def get_camera_frame(self)

set_camera__

def set_camera__(self, eye=(0, -10, 0), focal=(0, 0, 0), up=(0, 0, 1), propagate=True)

set_camera

def set_camera(self, eye=(0, -10, 0), focal=(0, 0, 0), up=(0, 0, 1), propagate=True)

set the model view matric respect to eye, focal and up direction of gaze

  • → eye : eye position
  • → focal : focal point
  • → up : up vector
  • → propagate : boolean : propagate the camera to the observer (oboslete should be removed) The observer uses False to avoid recursive update of camera

auto_scale

def auto_scale(self, node=None, propagate=True)

Move observer to make the 3D scene fit in his view point

set_sky_box

def set_sky_box(self, skybox)

get_sky_box

def get_sky_box(self)

set_sky_box_transform

def set_sky_box_transform(self, transform=None)

add_node

def add_node(self, node, space=0)
  • → obj : display_list
  • → space
  • O : 3D modelview position
  • 1: 3D camera position
  • 2 : 2D screen position
  • → transform None => identity by default
  • → texture_key : None by default

get_nodes

def get_nodes(self, space=0)

Get the canvas graphic root nodes

  • ← a dictinary of the scene root nodes

get_nodes_from_path

def get_nodes_from_path(self, space, path)

From a given path provides a list of corresponding graphic nodes

  • → space : concerned space : 0 -> 3D, 1 -> Camera Space, 2 -> Screen Space
  • → path : a list of graphic node keys
  • ← L,T where :
  • L is the list of corresponding nodes
  • T is the cobine transformation matrix from all ancestor nodes before the last node of the stack L

remove_node

def remove_node(self, space=0, key=None)

delete a root node from the scene.

  • → key : node key

set_ambient_light

def set_ambient_light(self, r, g, b)

add_light

def add_light(self, light, key=None)

Add a light to the scene

  • → light : OGLLigth

get_lights

def get_lights(self)

Get Lights of the scene

  • ← a list of lights

remove_light

def remove_light(self, light)

Remove light from the scene

  • → a list to be removed

activate_trackball

def activate_trackball(self, active=True)

activate or disactivate default trackball events

add_picking_avatar

def add_picking_avatar(self, avatar)

avatar is a node repreresenting the selection device. Even if it mask selected objects it should not be selected then it must hidden at picking

remove_picking_avatar

def remove_picking_avatar(self, avatar)

avatar is a node repreresenting the selection device. Even if it mask selected objects it should not be selected then it must hidden at picking

pick

def pick(self, x, y)

Main picking function

  • → x,y the pixel coordinates x and y in the window framework
  • ← a dictionary with the following fields :
  • ‘window’ : a pointer to the window itself
  • ‘space’ : 0 -> 3D space, 1 Camera space, 2, Screen space
  • ‘path-id’ : a list of keys from root compound to selected node
  • ‘path-node’ : a list of nodes from root compound to selected node
  • ‘face-id’ : the id of the face
  • ‘path-transform’ : the combined transformation matrix of the path nodes excluded the last one
  • ‘local-point’ : the selected 3D point in the local frame of the selected object. To get the global selected point we need to multiply : [‘path-transform’][‘path-node’[-1]] {‘local-point’}
  • ‘face-weight’ : 3 weights of the selected points respect to the selected triangle face

pick_ray

def pick_ray(self, origin, direction)

Picking function if ray mode indeed it calls the pick function with a relocated eye respect to the ray definition

  • → : origin of the ray : a 3D point
  • → : direction of the ray : a 3D vector
  • ← the same dictionary as the pick method

shot

def shot(self, device=None, x=0, y=0, propagate=True)

Interaction picking indeed it calls the pick function with a relocated eye respect to the ray definition

  • → : device : identification of the device calling the shot. for a mouse computer the string ‘mouse’ identifies the device this enable several device to interact simultaneously on the scene
  • → : x,y, mouse position
  • → : propagate=True by default : the picked object apply its on_shot method This parameter should be let to True, False value is for internal use to avoid recursive shot
  • ← select,events
  • select : the dictionary of the pick function
  • events : a dictionary of events produced on graphic nodes if a graphic node g react to when picked then events[g] is a dictionary with events and values

shot_ray

def shot_ray(self, device=None, origin=(0, 0, 0), direction=(1, 0, 0), propagate=True)

Interaction picking in ray mode indeed it calls the pick function with a relocated eye respect to the ray definition

  • → : device : identification of the device calling the shot. for a mouse computer the string ‘mouse’ identifies the device this enable several device to interact simultaneously on the scene
  • → : origin of the ray : a 3D point
  • → : direction of the ray : a 3D vector
  • → : propagate=True by default : the picked object apply its on_shot methodmethod This parameter should be let to True, False value is for internal use to avoid recursive shot
  • ← select,events
  • select : the dictionary of the pick function
  • events : a dictionary of events produced on graphic nodes if a graphic node g react to when picked then events[g] is a dictionary with events and values

move

def move(self, device=None, x=0, y=0, picked=None)

Interaction picking when a 2D device (like the mouse is moved’ indeed it calls the pick function with a relocated eye respect to the ray definition

  • → : device : identification of the device calling the shot. for a mouse computer the string ‘mouse’ identifies the device this enable several device to interact simultaneously on the scene
  • → : x,y, mouse position
  • ← select,events
  • select : the dictionary of the pick function
  • events : a dictionary of events produced on graphic nodes if a graphic node g react to when picked then events[g] is a dictionary with events and values

move_ray

def move_ray(self, device=None, origin=(0, 0, 0), direction=(1, 0, 0))

Interaction picking in ray mode when the device is moved indeed it calls the pick function with a relocated eye respect to the ray definition

  • → : device : identification of the device calling the shot. for a mouse computer the string ‘mouse’ identifies the device this enable several device to interact simultaneously on the scene
  • → : origin of the ray : a 3D point
  • → : direction of the ray : a 3D vector
  • → : propagate=True by default : the picked object apply its on_shot methodmethod This parameter should be let to True, False value is for internal use to avoid recursive shot
  • ← select,events
  • select : the dictionary of the pick function
  • events : a dictionary of events produced on graphic nodes if a graphic node g react to when picked then events[g] is a dictionary with events and values

unshot

def unshot(self, device=None)

Interaction unpick when shot is finalized this method is applied for the corresponding device

send_events

def send_events(self, events={})

When a node emit events it call this methods that can be overloaded to modify the application content

  • → events : dictionary of dictionary a value event is in : events[device][‘event-name’]

get_font

def get_font(self, name)

Get a font object from its name

switch_cave_mode_P38

def switch_cave_mode_P38(self, stereo=False)

switch_cave_mode

def switch_cave_mode(self, stereo=False)

cave_reset_window_positions

def cave_reset_window_positions(self)

switch_hmd_mode

def switch_hmd_mode(self)

openvr

def openvr(self)

return the openvr instance if None no hmd is connected

switch_openvr_mode

def switch_openvr_mode(self)

openvr_calibrate

def openvr_calibrate(self, pose=0, x=[0, -2, 1.7], xn=[1, 0, 0], yn=[0, 0, 1], zn=[0, -1, 0])

slave_send

def slave_send(self, data=['background', (1, 1, 1, 1)], answer=False)

synchronize active canvas slaves

slave_wait

def slave_wait(self)

slave_share_array

def slave_share_array(self, key, array, data=[])

synchronize active canvas slaves

synchro_order

def synchro_order(self, data=['background', (1, 1, 1, 1)])

synchronize active canvas slaves

synchro_done

def synchro_done(self)

wait for last order to be finalised for every slaves.

synchro_set

def synchro_set(self, state=True)

synchro_share_array

def synchro_share_array(self, array, target=[], verbose=None)

synchronize an array with slaves

  • → array to be shared
  • → target : list of parameters to identify the target

replace

def replace(self, last, new)