TubeFrame.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, September 18, 1986 10:37:01 am PDT
DIRECTORY Controls, Imager, IO, Matrix3d, Menus, Rope, Spline3d, TubeDefs, Vector3d;
TubeFrame: CEDAR DEFINITIONS
~ BEGIN
OPEN TubeDefs;
ReScale: PUBLIC PROC [tube: Tube, scale: REAL ← 1.0, taper: REAL ← 0.0];
Resize tube.frames to scale*tube.r.
Make: PUBLIC PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale: REAL ← 1.0,
taper: REAL ← 0.0,
skin: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL
];
Create spline coefficients and reference frames for the entire tube (its descendants and
antecedants). For each tube section, points, tangents, radii, and twists are presumed defined.
scale is the amount by which a frame matrix is scaled at the base of the tree.
The scale is reduced according to distance from the tube base and taper; if taper is 0, no
tapering occurs; if taper is 1, then scale is reduced to zero after a distance of 1.
If skin is TRUE then the curve subdivison considers the variation in any associated contours
and at each frame the contour is computed.
If view is NIL, the tube is considered only in object space and epsilon is the same
discriminator as in Spline3d.FlatBezier; if view is non-NIL, epsilon is the number of pixels
the straight line approximation is permitted to deviate from the curve as transformed to
screen space.
If frameProc is non-NIL, it is used to create the each frame; otherwise a standard procedure,
return a frame consisting of a circular cross-section.
MakeFrames: PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale: REAL ← 1.0,
taper: REAL ← 0.0,
skin: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL
];
Make the frames for the tube sub-tree (tube and its descendants only).
epsilon, scale, taper, skin, view, and frameProc have the same meaning as in Make[].
MakeSectionFrames: PROC [
tube: Tube,
epsilon: REAL ← 0.03,
scale0, scale1: REAL ← 1.0,
skin: BOOLFALSE,
view: Matrix ← NIL,
frameProc: FrameProc ← NIL
];
Create a frame sequence for the tube section only.
epsilon, skin, view, and frameProc have the same meaning as in Make[].
scale0 and scale1 are the scales applied at the beginning and end of the tube section.
NFrames: PUBLIC PROC [tube: Tube] RETURNS [INTEGER];
Return the number of frames in tube.
GetFrame: PUBLIC PROC [tube: Tube, t: REAL] RETURNS [Frame];
Return the frame at parametric position t, t IN [0..1].
PutFrame: PUBLIC PROC [tube: Tube, frame: Frame];
Insert the frame in the tube.
CopyFrame: PUBLIC PROC [frames: Frame] RETURNS [Frame];
Return a copy of the input frame.
CopyFrames: PUBLIC PROC [frames: FrameSequence] RETURNS [FrameSequence];
Return a copy of the input frame sequence.
Basis: PUBLIC PROC [v, vv, rv: Triple] RETURNS [Triad];
Given tangent v along a curve, previous tangent vv, and reference vector rv, compute
vectors n and b; v, n, and b form a new set of axes; the transformation of the x, y, and z
axes to v, n, and b accomodates the twist in the curve; n and b are unitized.
RefMatrix: PUBLIC PROC [position: Triple, triad: Triad, scale, twist: REAL, out: Matrix ← NIL]
RETURNS [Matrix];
Return matrix which transforms origin to p, xaxis to x, yaxis to y and zaxis to z;
twist around z by t degrees and scale by s.
END.