Point_picker is implemented in conjunction with picker. Initial intersection against the actor is performed using the bounding box of the geometry. If the bounding box is hit, then projection of the points of the geometry on the intersection ray is performed. The point closest to the eye is selected (the actual point coordinates and point id), as well as the point coordinates in the modeller coordinate system.
renderer? get the renderer instance variable
selection_point=(x,y) set the selection coordinates in screen coordinates.
selection_point? get the selection coordinates.
tolerance=value set the tolerance of picking as a fraction of screen size.
tolerance? get the picking tolerance.
pick! execute picking operation.
picked? determine whether any actor was picked during the previous pick! operation.
selected_actors? the list of all actors whose bounding box was hit during the previous pick! operation.
actor? the actor intersected by the picking ray and closest to the camera.
modeller? the modeller associated with the actor returned from the actor? message.
point_id? the id of the picked geometric primitive.
pick_coords? the x,y,z coordinates of the intersection point (in world coordinates).
model_coords? the x,y,z coordinates of the intersection point (in the modeller's coordinate system)
intersect:(p1(x,y,z), p2(x,y,z), tol, actor, modeller) method to perform actual projection operation. The point coordinates p1[] and p2[] must be in modeller coordinates. tol is the tolerance in model coordinates, actor is the name of the actor, and modeller is the name of the modeller.
free! free the point_picker instance.
sphere_modeller new: asphere resolution=1 ; actor new: s1
modeller= asphere ; actor new: s2 position+(2.5,0,0) modeller= asphere ; actor new: s3 modeller= asphere position+(-2.5,0,0) ;
cube_modeller new: acube; actor new: pick_location modeller= acube color=(1,0,0) scale=(.1,.1,.1) unpickable! ; actor new: picker_point modeller= acube color=(0,1,0) scale=(.1,.1,.1) unpickable! ;
camera new: acamera range= [asphere bounds?] position= (1,1,1) default! on! ; renderer new: aren pref_size=(500,500) actors=[actor instances?] cameras=[camera instances?] render! ;
point_picker new: pick_point renderer= aren debugon! ;
/* * Create x-event controller for picking points. */ xset_window_attributes new: _ren_win_attributes disable_event:"All" ;
xdisplay new:renderer_display id=[aren display_id?]
; xwindow new: temp_window display=renderer_display id=[aren window_id?] xset_window_attributes = _ren_win_attributes change_window_attributes! free! ; renderer_display flush!;
_ren_win_attributes enable_event:"ButtonPressMask";
motif application=`VISAGE' create! ;
xdisplay id=[motif display_id?];
xwindow new: rendering_window display= xdisplay id=[aren window_id?] xset_window_attributes= _ren_win_attributes change_window_attributes! ; event new:button1_press type= `X_ButtonPress' window= [rendering_window id?] button= 1 ; xeventcontroller new:pick_controller ignore_unknown_events! transition:(start,button1_press,start,mark_pick) state=start start! ;
logic new: if; vector new: p = (325,300); scalar new: ren_height = [rendering_window actual_height?]; actions new: mark_pick tick_actions=` p @1 = [pick_controller x?] @2 = ren_height - [pick_controller y?];
pick_location position= [aren dpoint=p display_to_world! wpoint?]; if = [pick_point selection_point=p pick! point_id?] true: ` picker_point on! position= [pick_point pick_coords?]; ' false: ` picker_point off!; ' ;
aren render!; ' ;
motif event= pick_controller start!;