www.pudn.com > CG2Programs.rar > bicycle.c
/* bicycle, Chapter 7, p. 267-68 */
#include "graphics.h"
/* EXAMPLE STARTS HERE */
void main ()
{
enum { Frame, Wheel, Bicycle };
int nPts;
wcPt2 pts[256];
pMatrix3 m;
/* Routines to generate geometry */
extern void getWheelVertices (int * nPts, wcPt2 pts);
extern void getFrameVertices (int * nPts, wcPt2 pts);
/* Make the wheel structure */
getWheelVertices (nPts, pts);
openStructure (Wheel);
setLineWidth (2.0);
polyline (nPts, pts);
closeStructure;
/* Make the frame structure */
getFrameVertices (nPts, pts);
openStructure (Frame);
setLineWidth (2.0);
polyline (nPts, pts);
closeStructure;
/* Make the bicycle */
openStructure (Bicycle);
/* Include the frame */
executeStructure (Frame);
/* Position and include rear wheel */
matrixSetIdentity (m);
m[0,2] := -1.0; m[1,2] := -0.5;
setLocalTransformationMatrix (m, REPLACE);
executeStructure (Wheel);
/* Position and include front wheel */
m[0,2] := 1.0; m[1,2] := -0.5;
setLocalTransformationmatrix (m, REPLACE);
executeStructure (Wheel);
closeStructure;
}
/* EXAMPLE ENDS HERE */