The display_data object represents geometry as points, lines, triangle strips and/or polygons. In addition, the points (and hence other geometry that indexes into the points) may be supplemented by scalar, vector, normal, and texture coordinate data. The scalar data is a single value for each point, the vector data is a triplet of values representing a vector at each point, the normal data is a triplet at each point representing a normal at the point, and the texture coordinate data is a doublet at each point representing the coordinates into a texture map.
Display data may be used either from a LYMB script, or as a developer, internally from classes. From a LYMB script, display data is passed on the argument stack either as a list of values, or as a pointer to either the whole structure (i.e., data=) or pointers to the components of display_data.
data=display_data pointer set the object's data to the display data pointer provided (at the current time). Note: when used in networks the data is not updated as the network re- executes. It is possible to use either the lymb_filter object or start_actions of a filter object to maintain consistency as the network executes.
compute_range! compute the min/max scalar range.
range? get min/max scalar range.
compute_max_length! compute the maximum length of vector data.
max_length? get vector max_length.
compute_properties! convienience routine which sends "compute_range!" and "compute_max_length!" messages to itself. It then returns superclass responsibility so that geometric properties can be computed by its superclass.
points=+ data Set/add points data. The argument data may be either a list of x,y,z triplets or a pointer to array of floats containing x.y,z triplets (i.e., a LYMB FPTR).
points? returns a pointer (FPTR) to the list of points.
no_points? returns the number of points in the list.
point_values? returns a list of x,y,z triplets on the argument stack (one for each point).
normals=+ data Set/add normals data. The argument data may be either a list of x,y,z triplets or a pointer to array of floats containing x.y,z triplets (i.e., a LYMB FPTR).
normals? returns a pointer to the list of normals.
no_normals? returns the number of normals in the list.
normal_values? returns a list of x,y,z triplets on the argument stack (one for each point).
scalars=+ data Set/add scalars data. The argument data may be either a list of scalar values or a pointer to array of floats containing a scalar value for each point (i.e., a LYMB FPTR).
scalars? returns a pointer to the list of scalars.
no_scalars? returns the number of scalars in the list.
scalar_values? returns a list of scalar values on the argument stack.
vectors=+ data Set/add vectors data. The argument data may be either a list of x,y,z triplets or a pointer to array of floats containing x.y,z triplets (i.e., a LYMB FPTR).
vectors? returns a pointer (FPTR) to the list of vectors.
no_vectors? returns the number of vectors in the list.
vector_values? returns a list of x,y,z triplets on the argument stack (one for each point).
texture_coords=+ data Set/add texture coordinates data. The argument data may be either a list of s,t doublets or a pointer to array of floats containing s,t doublets (i.e., a LYMB FPTR).
texture_coords? returns a pointer (FPTR) to the list of texture coordinates.
no_texture_coords? returns the number of texture coordinates in the list.
texture_coord_values? returns a list of s,t doublets on the argument stack (one doublet for each point).
lines=+( n,p11,p12,...,p1n,m,p21,p22,...,p2m,...) Set/add lines to the display data. Lines are defined by a count (i.e., number of points defining the line) and a list of indices into the point data (1-offset). More that one line may be defined by including additional data. It is also possible to set the lines to a pointer value (i.e., a LYMB IPTR) representing the same information.
lines? returns a pointer (IPTR) to the lines.
no_lines? returns the number of lines in the list.
line_values? returns the values of the line indicies on the argument stack.
polygons=+ (n,p11,p12,...,p1n,m,p21,p22,...,p2m,...) Set/add polygons to the display data. Polygons are defined by a count (i.e., number of points defining the polygon) and a list of indices into the point data (1-offset). More that one polygon may be defined by including additional data. It is also possible to set the polygons to a pointer value (i.e., a LYMB IPTR) representing the same information.
polygons? returns a pointer (IPTR) to the polygons.
no_polygons? returns the number of polygons.
polygon_values? returns the indicies of the polygons on the argument stack
triangle_strips=+ (n,p11,p12,...,p1n,m,p21,p22,...,p2m,...) Set/add triangle strips to the display data. Triangle strips are defined by a count (i.e., number of points defining the triangle strip) and a list of indices into the point data (1-offset). More that one triangle strip may be defined by including additional data. Note that the number of triangles in a triangle strip is defined by (n-2) where n is the number of points defining the triangle strip. It is also possible to set the triangle_strips to a pointer value (i.e., a LYMB (IPTR) representing the same information.
triangle_strips? returns a pointer (IPTR) to the triangle_strips data.
no_triangle_strips? returns the number of triangle strips.
triangle_strip_values? returns the indicies of the triangle strips on the argument stack
output! prints out a list of all of the data using Unix
more command (or equivalent).
release! frees all internal storage for display_data.
free! frees all internal storage for display_data and then destroys the object.
initialize! set the display data to its initial data (i.e., no data defined).
/* * Script creates display data and places cones at each point */ /* * Create display data and filter network */ display_data new: dd points=(-.5,-.5,-.5,.5,.5,.5,1,1,1) lines=(3,1,2,3) scalars=(.5,1,2) vectors=(1,0,0,0,1,0,0,0,1) ;
cone_modeller new:cm resolution=8 ; transform_filter new: xform data_in= cm scale=(.1,.2,.3) ; data_primitive new:cones data_in=dd source=xform scale_by_scalar! scale_factor=3 range=(0,2) ; display_all new: da data_in= cones range=(0,2) ; actor new:cone_actor modeller=da ;
/* * The thread to hold the cones together
*/ display_lines new: thread scalar_data_off! data_in=dd ; actor new: thread_actor color=(1,1,1) modeller=thread ; /* * set up cameras and lights */ camera new: acamera view_up=(0,0,1) position=(1,0,0) x_range=(-1,1) y_range=(-1,1) z_range=(-1,1) default! on!;
light new: l1 position=([acamera position?]) on!;
/* * define the renderers */ environment new: _env variable="LYMB_RENDERER"; string new: current_renderer = [_env value?]; object# current_renderer new: main_renderer actors=([actor instances?]) cameras=acamera lights=l1;
/* * Draw the picture */ main_renderer render!;