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