<<<<<<<<<<<<<<<<<

point_picker(display) Filter point_picker(display)

NAME

point_picker - select (or pick) points (as well as picking actors)

DESCRIPTION

Point_picker allows the selection of points from any geometric representation (i.e., modeller) that has points. Usually the modeller data is display_data. Point_picker selects the point within the picking tolerance that is closest to the eye (camera position). Point_picker also selects the actor and modeller that use the point. Note that point picker may return ambiguous results when selecting actors, but is generally more reliable than picker. Point_picker is also faster than surface_picker (surface_picker performs unambiguous actor selection).

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.

SUPERCLASS

picker

INSTANCE VARIABLES

(All inherited from superclasses).

MESSAGES

renderer= renderer_name set the renderer instance variable

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.

EXAMPLE

In this example three spheres are drawn (a single sphere modeller with three actors). The spheres are separated by translating them. An xeventcontroller is set up so that picking with the left mouse button can be done in the graphics window. A green sphere is shown at the pick point when something is successfully picked, and a red sphere is used to indicate the actual pick location.

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!;

SEE ALSO

picker, surface_picker, display_data_geometry


Please send comments and suggestions to
consult@rpi.edu