home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GRAPHICS / rayshade.lzh / primobj.h < prev    next >
Text File  |  1990-05-08  |  3KB  |  150 lines

  1. /*
  2.  * primobj.h
  3.  *
  4.  * Copyright (C) 1989, Craig E. Kolb
  5.  *
  6.  * This software may be freely copied, modified, and redistributed,
  7.  * provided that this copyright notice is preserved on all copies.
  8.  *
  9.  * There is no warranty or other guarantee of fitness for this software,
  10.  * it is provided solely .  Bug reports or fixes may be sent
  11.  * to the author, who may or may not act on them as he desires.
  12.  *
  13.  * You may not include this software in a program or other software product
  14.  * without supplying the source, or without informing the end-user that the
  15.  * source is available for no extra charge.
  16.  *
  17.  * If you modify this software, you should include a notice giving the
  18.  * name of the person performing the modification, the date of modification,
  19.  * and the reason for such modification.
  20.  *
  21.  * $Id: primobj.h,v 3.0.1.1 90/04/09 13:39:59 craig Exp $
  22.  *
  23.  * $Log:    primobj.h,v $
  24.  * Revision 3.0.1.1  90/04/09  13:39:59  craig
  25.  * patch5: New Cylinder and Cone types.
  26.  * 
  27.  * Revision 3.0  89/10/27  02:06:00  craig
  28.  * Baseline for first official release.
  29.  * 
  30.  */
  31.  
  32. /*
  33.  * Cylinder
  34.  */
  35. typedef struct cylinder    {
  36.     Trans trans;
  37. } Cylinder;
  38.  
  39. typedef struct cone {
  40.     double start_dist;
  41.     Trans trans;
  42. } Cone;
  43.  
  44. /*
  45.  * Sphere
  46.  */
  47. typedef struct {
  48.     double r;        /* radius   */
  49.     double x, y, z;        /* position */
  50. } Sphere;
  51.  
  52. /*
  53.  * Box
  54.  */
  55. typedef struct {
  56.     double bounds[2][3];    /* Box corners */
  57. } Box;
  58.  
  59. /*
  60.  * Triangle
  61.  */
  62. typedef struct {
  63.     Vector nrm;        /* triangle normal */
  64.     Vector p1, p2, p3;    /* vertices */
  65.     double d;        /* plane constant  */
  66.     char index;        /* Flag used for shading/intersection test. */
  67.     Vector *vnorm;        /* Array of vertex normals */
  68.     double *b;        /* Array of barycentric coordinates */
  69.     Vector e1, e2, e3;    /* edge vectors */
  70. } Triangle;
  71.  
  72. /*
  73.  * Polygon
  74.  */
  75. typedef struct {
  76.     Vector norm;        /* Normal to polygon */
  77.     double d;        /* Plane constant */
  78.     char index;        /* Which normal coord is "dominant"? */
  79.     Vector *points;        /* Array of vertices */
  80.     int npoints;        /* Number of vertices */
  81. } Polygon;
  82.  
  83. /*
  84.  * Superquadric
  85.  */
  86. typedef struct {
  87.     double bounds[2][3];    /* bounding box */
  88.     double x, y, z;        /* Center */
  89.     double pow;        /* Superquadric power */
  90.     double a, b, c, r;
  91.     double err;        /* Error constant */
  92. } Superq;
  93.  
  94. /*
  95.  * Plane
  96.  */
  97. typedef struct {
  98.     Vector norm;    /* Plane normal. */
  99.     double d;    /* Plane constant. */
  100. } Plane;
  101.  
  102. /*
  103.  * Height field gunk.
  104.  */
  105. typedef struct hfTri {
  106.     Vector v1, v2, v3, norm;
  107.     double d;
  108.     char type;
  109.     struct hfTri *next, *prev;
  110. } hfTri;
  111.  
  112. typedef struct {
  113.     int len;
  114.     hfTri *head, *tail;
  115. } TriQueue;
  116.  
  117. typedef struct {
  118.     float **data;        /* Altitude points */
  119.     float minz, maxz;
  120.     int size, *lsize;    /* # of points/side */
  121.     int BestSize;         /* "best" division size */
  122.     float iBestSize;    /* inverse of above (for faster computation) */
  123.     int levels;        /* log base BestSize of size */
  124.     float ***boundsmax;    /* high data values at various resolutions. */
  125.     float ***boundsmin;
  126.     float *spacing;
  127.     hfTri hittri, **q;    /* hit triangle and triangle cache */
  128.     int qtail, qsize;    /* end and length of cache */
  129.     double boundbox[2][3];    /* bounding box of HF */
  130. } Hf;
  131.  
  132. /*
  133.  * Primitive object.
  134.  */
  135. typedef struct Primitive {
  136.     char type;            /* object type */
  137.     struct Surface *surf;        /* default surface */
  138.     union {
  139.         Sphere        *p_sphere;
  140.         Box         *p_box;
  141.         Triangle    *p_triangle;
  142.         Superq        *p_superq;
  143.         Plane        *p_plane;
  144.         Cylinder    *p_cylinder;
  145.         Polygon        *p_poly;
  146.         Cone        *p_cone;
  147.         Hf        *p_hf;
  148.     } objpnt;    /* Pointer to primitive */
  149. } Primitive;
  150.