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

texture_map_cut_quadric(texture)Texturetexture_map_cut_quadric(texture)

NAME

texture_map_cut_quadric - generate texture coordinates to cut with quadrics

DESCRIPTION

The texture_map_cut_quadric object takes as input a display_data object that must contain points. Each point is assigned a texture coordinate by calculating its distance to quadric. A special texture map exits for use with this object in: textures/cut.texture.map. Also, the boolean_texture object will generate appropriate textures for cutting. Any actors that use this object will be cut by the quadric. The quadric is defined using 10 coefficients in the following symmetric matrix: | a b c d | | c e f g | | c f h i | | d g i j | This general matrix defines all quadrics including: spheres, ellipsoids, cylinders, cones, hyperboloids and paraboloids. The defined quadric can be transformed using transform object messages. The coefficients are set with the coefficients= message. Admittedly, although general, creating quadrics this way is awkward. As we gain more experience with this object, we expect to add more usable subclasses for the quadrics. For the time being, the following coefficients will define surfaces more familiar to most of us:

A sphere of radius R, centered at the (0,0,0): coefficients=(1,0,0,0, 1,0,0, 1,0, -r^2).

A cylinder of infinite extent with radius R, centered at (0,0,0) coefficients=(1,0,0,0, 1,0,0, 0,0, -r^2).

A cone of infinite extent with apex at (0,0,0) and radius r at a distance of d from the apex: coefficients=(1,0,0,0, 1,0,0, -r/d, 0, 0).

A plane with normal nx,ny,nz passing through (0,0,0): coefficients=(0,0,0,nx, 0,0,ny, 0,nz, 0).

A special texture map exits for use with this object in: textures/cut.texture.map.

SUPERCLASS

display_filter

INSTANCE VARIABLES

coefficients are the 10 coefficients that define a quadric to be used as a cutter.

scale_factor is a scale factor used to scale the distances from the planes. The resulting texture coordinates may be outside the 0 to 1 interval. If so, the texture will repeat unless repeat_off! is sent to the texture instance being used by the actor.

MESSAGES

All transform messages are valid.

algebraic_distance_on/off! sets the distance metric for the quadrics. Normally, the algebraic distance, f(x,y,z), is used to calculate distance. If algebraic_distance_off! , the euclidean distance is calculated. This is about four times slower that the algebraic distance and is usually only needed if accurate outlining of cut boundaries is required.

EXAMPLE

/* Illustrate the texture_map_cut_quadric display data filter */ /* In: scripts/texture/texture_map_cut_quadric.scr */

<boolean.scr

/* We use spheres as models, but any model will do */ sphere_modeller new: aSphereModel resolution=5 ; /* Define an elliptical cylinder */ texture_map_cut_quadric new: qcyl data_in=aSphereModel s_coefficients=(1,0,0,0, 2,0,0, 0,0, -.202) t_coefficients=(3,0,0,0, 1,0,0, 0,0, -.16) scale_factor=5 ; /* Need a display all for rendering */ display_all new: aDa data_in= qcyl ; /* This is a special cutting texture.

NOTE: no interpolation is specified. This is important!! */

/* Two spheres, yellow one inside a white one */ property new: bprop color=(1,0,0); property new: bprop2 color=(1,0,1); actor new: anactor modeller=aDa texture=case_7 backface_property=bprop ; actor new: another modeller=aDa texture=case_7 scale=(.9,.9,.9) color=(1,1,0) backface_property=bprop2 ; /* A third sphere that we'll follow with our quadric cutter. It's blue */ actor new: cutter modeller=aSphereModel scale=(.447,.447,.447) color=(0,1,1) ; /* a camera to watch the magic unfold */ camera new: c1 position=(0,0,1) focal_point=(0,0,0) range=(-1,1,-1,1,-1,1) default! on! ; /* A renderer. For now, only the SGI supports texture */ renderer new: aren actors=(cutter,another,anactor) cameras=c1 ; /* We need a person to watch the small sphere. We'll use this helper's transformation to transform the quadric, keeping an "eye" on the small sphere */ person new: helper; /* We keep a vector from the camera to the small sphere */ vector new: `along' dimension=3; /* Now a loop to have the small sphere move through the two bigger ones

under the watchful eye of the helper, who in turn provides a

a transformation for the quadric */ cue new: follow resolution=1 start_actions=" cutter position=(-2,0,0); " tick_actions=" cutter position+ (.1,0,0); along = [cutter position?] - [c1 position?]; helper position=[c1 position?] up=[c1 view_up?] front=along; qcyl matrix=[helper composite_matrix?];

aren render!; " duration=15 ; ! send follow start! to see the action

cue new: twist resolution=1 start=15 duration=30 tick_actions=`qcyl rotate_z:12;' ;

cue new: spin resolution=1 start=30 duration=60 tick_actions=`c1 azimuth:12;' ;

scene new: ascene resolution=1 cues=(follow,spin,twist) renderers=aren;

SEE ALSO

boolean_texture, display_feature, display_filter, data_geometry, display_data, texture_map_cut_planes, texture_map_to_plane, texture, actor, transform


Please send comments and suggestions to
consult@rpi.edu