home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / RAYTRACE / RT / SHAPE.H < prev    next >
C/C++ Source or Header  |  1994-05-22  |  3KB  |  87 lines

  1. /*
  2.  
  3. SHAPE.H  General shape module
  4.  
  5. */
  6.  
  7. typedef byte STYPE;            /* Type (discriminant of union)      */
  8. #define    STYPE_PLANE    ((STYPE) 0)    /* Shape is a half-plane             */
  9. #define    STYPE_BIPLANE    ((STYPE) 1)    /* Shape is a bi-plane               */
  10. #define    STYPE_SPHERE    ((STYPE) 2)    /* Shape is a sphere                 */
  11. #define    STYPE_QUAD    ((STYPE) 3)    /* Shape is a quadratic solid        */
  12. #define    STYPE_UNION    ((STYPE) 4)    /* Shape is the union of 2 shapes    */
  13. #define    STYPE_ISECT    ((STYPE) 5)    /* Shape is the intersection of 2    */
  14. #define    STYPE_DIFF    ((STYPE) 6)    /* Shape is the difference of 2      */
  15. #define    STYPE_SDIFF    ((STYPE) 7)    /* Shape is the symmetric difference */
  16. #define    STYPE_EXTENT    ((STYPE) 8)    /* Shape is 1st if intersects 2nd    */
  17.  
  18. #define    SHAPE_F        struct shape_struct
  19.  
  20. typedef struct shape_struct
  21.     {
  22.     STYPE    stype;            /* Shape type                        */
  23.     union
  24.         {
  25.         PLANE    *plane;        /* Used if STYPE_PLANE               */
  26.         BIPLANE    *biplane;    /* Used if STYPE_BIPLANE             */
  27.         SPHERE    *sphere;    /* Used if STYPE_SPHERE              */
  28.         QUAD    *quad;        /* Used if STYPE_QUAD                */
  29.         SHAPE_F    *shapes[2];    /* For boolean combinations          */
  30.         } u;
  31.     BOOLEAN    overlap;        /* If boolean, could they overlap?   */
  32.     SURF    *surf;            /* Surface characteristic of shape   */
  33.     } SHAPE;
  34.  
  35. typedef struct
  36.     {
  37.     double    t;            /* t value at point of intersection  */
  38.     SHAPE    *shape;            /* Shape intersection is with        */
  39.     BOOLEAN    entering;        /* Are we entering the shape?        */
  40.     BOOLEAN    negate_normal;        /* Is normal to be negated?          */
  41.     } ISECT;
  42.  
  43. #define    N_ISECTS    50
  44.  
  45. typedef struct
  46.     {
  47.     int    n_isects;        /* How many intersections in list    */
  48.     ISECT    isects[N_ISECTS];    /* Intersections                     */
  49.     } ISECTL;
  50.  
  51. #ifndef _SHAPE_
  52.  
  53. extern SHAPE *create_plane_shape(PLANE *plane, SURF *surf);
  54. extern SHAPE *create_biplane_shape(BIPLANE *biplane, SURF *surf);
  55. extern SHAPE *create_sphere_shape(SPHERE *sphere, SURF *surf);
  56. extern SHAPE *create_quad_shape(QUAD *quad, SURF *surf);
  57. extern SHAPE *create_bin_shape(STYPE stype, SHAPE *shape0, SHAPE *shape1);
  58. extern SHAPE *copy_shape(SHAPE *shape);
  59. extern void destroy_shape(SHAPE *shape);
  60.  
  61. extern void trans_x(SHAPE *shape, double t);
  62. extern void trans_y(SHAPE *shape, double t);
  63. extern void trans_z(SHAPE *shape, double t);
  64. extern void trans(SHAPE *shape, VECTOR t);
  65. extern BOOLEAN scale_x(SHAPE *shape, double factor);
  66. extern BOOLEAN scale_y(SHAPE *shape, double factor);
  67. extern BOOLEAN scale_z(SHAPE *shape, double factor);
  68. extern BOOLEAN scale(SHAPE *shape, VECTOR factor);
  69. extern void rot_x(SHAPE *shape, double angle);
  70. extern void rot_y(SHAPE *shape, double angle);
  71. extern void rot_z(SHAPE *shape, double angle);
  72.  
  73. extern BOOLEAN is_empty_isectl(ISECTL *il);
  74. extern BOOLEAN is_solid_isectl(ISECTL *il);
  75. extern void t_after_isectl(ISECTL *il, double t);
  76.  
  77. extern ISECTL *create_isectl(int n_isects);
  78. extern void destroy_isectl(ISECTL *il);
  79.  
  80. extern void preprocess_shape(SHAPE *shape, int *n_isectls, int *n_isects);
  81. extern void intersect_shape(SHAPE *shape, VECTOR p, VECTOR q, ISECTL *ils[]);
  82. extern VECTOR normal_to_shape(SHAPE *shape, VECTOR p);
  83.  
  84. extern BOOLEAN resurf(SHAPE *shape, SURF *surf);
  85.  
  86. #endif
  87.