home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / spline-patch.tar.gz / spline-patch.tar / patch / patch.h < prev    next >
Text File  |  1991-11-18  |  3KB  |  86 lines

  1. /*
  2.  *   File     : patch.h
  3.  *   Author   : Sean Graves
  4.  *
  5.  *   Computer : Any 
  6.  *   Date     : 6/21/90 
  7.  *
  8.  *   Contains function prototypes for the routines in patch.c.
  9.  *   Also defines data structures used in the definition of patches and
  10.  *   the computations used to calculate intersections.
  11.  *
  12.  *   Important data structures:
  13.  *     Patch, PatchPtr - Contains the definition of a patch, and precomputed
  14.  *                       intermediate values.
  15.  *     TreeNode        - A node in the hierarchical bounding box tree for
  16.  *                       a patch.
  17.  *     ListNode, ListPtr - An entry in the intersection list for a patch.
  18.  *                         This intersection list is only used internally
  19.  *                         within the intersection algorithm.
  20.  *     Isectrec          - A record returned by the intersection algorithm
  21.  *                         containing t, u and v, and the actual point.
  22.  *                         If there was no intersection, t = -1.0.
  23.  *
  24.  * Copyright (c) 1990, by Sean Graves and Texas A&M University
  25.  *
  26.  * Permission is hereby granted for non-commercial reproduction and use of
  27.  * this program, provided that this notice is included in any material copied
  28.  * from it. The author assumes no responsibility for damages resulting from
  29.  * the use of this software, however caused.
  30.  *
  31.  */
  32.  
  33. typedef struct { float x,y,z;           } POINT,VECTOR;
  34. typedef struct { POINT org; VECTOR dir; } RAY;
  35. typedef float MATRIX[4][4];
  36.  
  37. /*********************************************************************/
  38.  
  39. typedef struct tnode *TreePtr;   /* Pointer to a tree node */
  40.  
  41. typedef struct {
  42.    MATRIX geomx, geomy, geomz;   /* Geometry matrices */
  43.    MATRIX M, MT;                 /* Spline basis, transpose */
  44.    MATRIX Md, MdT;               /* Deriv. spline basis, transpose */
  45.    MATRIX Mx, My, Mz;            /* Blending matrices (MGMT) */
  46.    MATRIX Mxdu, Mxdv;            /* For calculation of surface normals */
  47.    MATRIX Mydu, Mydv;
  48.    MATRIX Mzdu, Mzdv;
  49.    TreePtr tree;                 /* Points to bounding-box hierarchy */
  50. } Patch, *PatchPtr;
  51.  
  52. /*********************************************************************/
  53.  
  54. typedef struct tnode {           /* A node in the bnding-box hierarchy */
  55.    float u_mid, v_mid;           /* Approximate guess for u, v */
  56.    POINT box_min, box_max;       /* Extent of box */
  57.    TreePtr child[4];             /* Pointers to four children of node */
  58. } TreeNode;
  59.  
  60. /*******************************************************************/
  61.  
  62. typedef struct lnode *ListPtr;     /* Pointer to intersection list elt */
  63.  
  64. typedef struct lnode {             /* Intersection list elt */
  65.    float t;                        /* Distance from ray origin to int */
  66.    TreePtr node;                   /* Pointer to box node */
  67.    ListPtr next;                   /* Next element in list */
  68. } ListNode; 
  69.  
  70. /*********************************************************************/
  71.  
  72. typedef struct {                   /* Intersection record returned */
  73.    POINT isect;
  74.    float t, u, v;
  75. } Isectrec;
  76.  
  77. /******************* Function Prototypes ***************************/
  78.  
  79. PatchPtr NewPatch();
  80. void DefPatch();
  81. void FreePatch();
  82. float BoxIntersect();     /* Probably should be moved */
  83. VECTOR NormalPatch();
  84. Isectrec IsectPatch ();  
  85.  
  86.