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

Sphere_modeller(modeller) LYMB Sphere_modeller(modeller)

NAME

sphere_modeller - a geometric representation of a sphere

DESCRIPTION

The sphere_modeller class implements a geometric representation of a sphere. It allows the user to manipulate a sphere without seeing the details of its internal representation. The sphere_modeller can be rendered directly on the graphics display. The default sphere has a radius of 1.0 and is centered at the origin. The sphere_model is a variable resolution modeller. By default it has a very coarse approximation to a sphere, using 8 triangles in the form of an octahedron (resolution = 1). For each increment in the resolution instance variable, each traingle is subdivided into four triangles, thus the total number of triangles that the modeller uses is;

num_triangles = 2 * 4 ^ resolution

A value of 3 or 4 for resolution gives a decent approximation.

SUPERCLASS

modeller

INSTANCE VARIABLES

num_vertices The number of vertices in the sphere geometry.

num_triangles The number of triangles in the sphere geometry.

radius The radius of the sphere.

resolution_cap Because the number of triangles can grow so rapidly, the resolution_cap instance variable limits the resolution. If the resolution is greater than the resolution_cap, a warning message is dispalyed and the resolution is restricted to the value of the resolution_cap. It can, of course, be set higher. The default value is 7.

MESSAGES

num_vertices? Get the number of vertices. Although the class interface allows this value to be set, it should not be since it is a value computed by the sphere_modeller when it builds itself.

num_triangles? Get the number of triangles. Like num_vertices, this value should not be set since it is computed by the sphere_modeller when it builds itself.

open! Sends the geomtry to the rendering primitive.

renderer_name? Returns the suffix of the class name used to draw the model on the graphics display.

generate_data! Builds the geometric representation of the sphere required by the rendering primitive.

return_data! Returns the data built by generate_data! instead of sending it to the rendering primitive. This allows another class in the system to use this geometry.

bounds? Returns the minimum and maximum x, y and z values of the sphere's vertices. This is used by the inherited "bounding_box?" method.

calculate! Recomputes all the vertices and triangles of the sphere according to the current value of "resolution", an inherited variable.

radius[=?] Sets/Gets the radius of the sphere. message.

reslution_cap[=?] Sets/Gets the resolution cap of the sphere. message.

EXAMPLES

The following LYMB script creates two sphere models, one with the default resolution of 1 (8 triangles) and the other with a resolution of 4 (512 triangles). In addition, the second sphere uses a non-symmetric scaling to tranform it into an ellipsoid.

sphere_modeller new: sphere_model1;

sphere_modeller new: sphere_model2 resolution=4 scale=(1.5, 0.7, 1.0) ;

actor new: rough_sphere modeller=sphere_model1 ;

actor new: smooth_egg modeller=sphere_model2 ;

SEE ALSO

actor, modeller, byu, cube_modeller, cylinder_modeller, hershey_text, points_modeller, polyline_modeller


Please send comments and suggestions to
consult@rpi.edu