glenda.party
term% ls -F
term% cat index.txt
CPR(9.1)                                                              CPR(9.1)



NAME
       cpr, cprview - cheesy polygon renderer and viewer

SYNOPSIS
       fb/cpr [ -a aspect ] [ -c rgbaz ] [ -w nx ny ] file ...

       fb/cprview [ file ...  ]

DESCRIPTION
       Cpr  creates an image from a list of polygons in three dimensions.  Its
       output is a picture file, written to standard output.  The -w flag sets
       the  width and height of the output file.  The default size is 640Ã480.
       The -a flag indicates the aspect ratio of the image.  The  default  as‐
       pect  ratio is the ratio of the output file's width and height, in pix‐
       els.  It may be set independently to handle  displays  with  non-square
       pixels.   The  -c flag indicates which channels the output image should
       have.  Possible values are -crgb (the default), -crgba, and -crgbaz.

       Cpr's input is a simple textual command language, read from  the  input
       files named on the command line (default standard input).  Each command
       is a single character followed by arguments, separated by spaces.   The
       commands are:

       v  fov near far ex ey ez lx ly lz ux uy uz
              Set viewing parameters.  Fov is the horizontal field-of-view an‐
              gle.  (ex, ey, ez) is the eye location from which the  scene  is
              viewed.  These and all other coordinates are floating point val‐
              ues.  (lx, ly, lz) is the location the eye is  looking  at  —  a
              point  that the viewing transformation will map to the center of
              the screen.  (ux, uy, uz) indicates the up direction.  It is the
              coordinate  of  a point that the viewing transformation will map
              somewhere on the ray ascending from (lx, ly, lz) through the top
              of  the screen.  Exactly where on that ray the image of (ux, uy,
              uz) is depends on the field of view angle.  Near and far are the
              distances from the eyepoint to the near and far clipping planes.
              Objects closer than near or farther than far will  not  be  dis‐
              played.  Both near and far must be positive, with far>near.

       t  x0 y0 z0 x1 y1 z1 x2 y2 z2 c0 c1
              draw  a  triangle.  (x0, y0, z0), (x1, y1, z1), and (x2, y2, z2)
              are the corners of the triangle.  C0 and c1 are  the  colors  of
              the  two  sides  of the triangle, with c0 being the color of the
              side from which the vertices are viewed clockwise.  Color values
              are integers with absolute values no larger than 255.  Their ab‐
              solute values index a table of colors whose entries are set  us‐
              ing the c command (vide infra).  A positive color indicates that
              the object should be drawn in exactly  that  color;  a  negative
              value  means  that  the  polygon should be a shade of that color
              computed according to the light source position.

       p  c0 c1 [ x y z ]* ;
              draw a polygon.  C0 and c1 are the colors of its two sides.  The
              (x, y, z) values are its vertices.

       h  c0 c1 nx ny x0 y0 x1 y1 file
              draw  a height field from a file of z values.  C0 and c1 are its
              colors.  X0, y0, x1, and y1 give the range of x  and  y  values.
              The  file  contains an array of nx by ny floating point numbers,
              in row major order, in the native floating-point  representation
              of the machine running cpr.  This is not portable.

       s  c0 c1 x y z r
              draw  a  sphere of the given color, with center at (x, y, z) and
              radius r.

       {      push the transformation stack.  Cpr maintains a stack of  trans‐
              formation matrices.  The following transformation commands oper‐
              ate on the top of the stack.  All objects to be drawn are  oper‐
              ated on by this transformation.

       }      pop the transformation stack

       R  angle axis
              Rotate by the given angle (in degrees) about the specified axis,
              which must be 0 for x, 1 for y, or 2 for z.

       T  dx dy dz
              Translate by the given offset

       S  sx sy sz
              Scale by the given factors in the x, y, and z directions.

       M  m00 m01 m02 m03 m10 m11 ... m33
              Multiply the top of the transformation stack by  the  given  ma‐
              trix.

       c  num r g b a
              Set the red, green, blue and α components of the numbered color
              table entry.   Color  components  must  be  integers  between  0
              (black) and 255 (full on).

       l  x y z
              Set the direction that the light source shines from.

       b  r g b a
              Clear the background to the given color.

       Cprview  displays  a  wire  frame  version  of a cpr image in a window.
       Dragging with button 1 rotates the image.  Button 2 pops  up  a  reread
       menu item that causes the input files to be reread.  Button 3 pops up a
       menu containing output and exit items.  Output writes a  pic(1)  repre‐
       sentation of the display on standard output.  Exit exits.

SOURCE
       /sys/src/fb/cpr.c
       /sys/src/fb/cprview.c



                                                                      CPR(9.1)