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

surface_picker(display) Filter surface_picker(display)

NAME

surface_picker - select (or pick) surface geometry (as well as picking actors)

DESCRIPTION

Surface_picker allows the selection of geometric primitives from surface data. This surface data is usually display data, but may be any implemented surface form. Surface_picker (unlike picker) also performs unambiguous actor selection since it performs intersection against the actual geometric primitives (it is slower than picker, however).

Surface_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 intersection with the surface primitives is performed. In the case of display_data, this means lines, polygons, and triangle strips.

If one or more intersections with the geometry is found, surface picker returns the one closest to the eye (camera position) along the intersection ray. It also returns an id of the hit primitive, as well as the type. So for example, if a display_data object was hit, surface_picker might return its id (id=267) and type (type="triangle_strip"). Surface_picker also returns the name of the actor and modeller that were picked, as well as the actual intersection coordinates (pick_coords) and intersection coordinates in model space (model_coords).

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.

id? the id of the picked geometric primitive.

type? the type (a string label) of the picked geometric primitive. The type varies depending on the form of the surface data.

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 intersection 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 surface_picker instance.

EXAMPLE

In this example a simple display data is created with a triangle strip, a polygon, and a line. 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, otherwise a red sphere is used to indicate an unsuccessful pick.

display_data new: dd points=( 1,1,0, 2,1,0, 1,2,0, 2,2,0, 3,2,0, 0,0,0, 1,0,0, 0,1,0, 0,2,0, ) lines=( 2,4,5, ) polygons=( 4,1,2,4,3 ) triangle_strips=( 6,7,6,1,8,3,9, ) ; display_all new: da data_in= dd ; actor new: a modeller= da ; sphere_modeller new: asphere resolution=1 ; actor new: pick_location modeller= asphere color=(1,0,0) scale=(.050,.050,.050) unpickable! ; actor new: picker_point modeller= asphere color=(0,1,0) scale=(.050,.050,.050) unpickable! off! ; camera new: acamera range= [da bounds?] position= (1,1,1) default! on! ; renderer new: aren

pref_size=(500,500) actors=[actor instances?] cameras=[camera instances?] render! ;

surface_picker new: pick_poly renderer= aren tolerance=0.025 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=(0,0); 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_poly selection_point=p pick! picked?] true: ` pick_location off!; picker_point on! position= [pick_poly pick_coords?]; ' false: ` pick_location on!; picker_point off!; ' ; aren render!; ' ;

motif event= pick_controller start!;

SEE ALSO

picker, point_picker, display_data_geometry


Please send comments and suggestions to
consult@rpi.edu