home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / povsrc31.zip / isoblob.h < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  147 lines

  1. /****************************************************************************
  2. *                   isoblob.h
  3. *
  4. *  This module contains all defines, typedefs, and prototypes for ISOBLOB.C.
  5. *
  6. *  By Lummox JR, July 1999
  7. *
  8. *  Almost all of the functions and structures were based on blob
  9. *  functions by Dieter Bayer and Alexander Enzmann, and some on
  10. *  isosurface functions created by R. Suzuki, D. Skarda, and T. Bily.
  11. *  Almost all have been modified somewhat from their original versions.
  12. *
  13. *****************************************************************************/
  14.  
  15.  
  16. #ifndef ISOBLOB_H
  17. #define ISOBLOB_H
  18.  
  19. #include "bsphere.h"
  20.  
  21. #ifndef ISOSURFACE_OBJECT
  22. #include "isosrf.h"
  23. #endif
  24.  
  25.  
  26. /*****************************************************************************
  27. * Global preprocessor defines
  28. ******************************************************************************/
  29.  
  30. #define ISOBLOB_OBJECT (HIERARCHY_OK_OBJECT)
  31.  
  32. /* Bounding object types */
  33.  
  34. #define ISOBLOB_SPHERE            2
  35. #define ISOBLOB_CYLINDER          4
  36.  
  37. /* Define max. number of isoblob components. */
  38.  
  39. #define MAX_ISOBLOB_COMPONENTS 1000000
  40.  
  41. /* Generate additional isoblob statistics. */
  42.  
  43. #define ISOBLOB_EXTRA_STATS 1
  44.  
  45.  
  46.  
  47. /*****************************************************************************
  48. * Global typedefs
  49. ******************************************************************************/
  50.  
  51. typedef struct Isoblob_Struct ISOBLOB;
  52. typedef struct Isoblob_Element_Struct ISOBLOB_ELEMENT;
  53. typedef struct Isoblob_Data_Struct ISOBLOB_DATA;
  54. typedef struct Isoblob_List_Struct ISOBLOB_LIST;
  55. typedef struct Isoblob_Interval_Struct ISOBLOB_INTERVAL;
  56. typedef struct Isoblob_Function_List_Struct ISOBLOB_FUNC_LIST;
  57.  
  58. struct Isoblob_Element_Struct
  59. {
  60.   short Type;       /* Type of bounding object                         */
  61.   int index;
  62.   DBL len;          /* Cylinder's length or box length along Z axis    */
  63.   DBL rad2;         /* Sphere's/Cylinder's radius^2                    */
  64.   VECTOR BC;        /* Bounding object center                          */
  65.   DBL str;          /* Strength setting                                */
  66.   FUNCTION *Func;   /* Density function                                */
  67.   TEXTURE *Texture; /* Component's texture                             */
  68.   TRANSFORM *Trans; /* Component's transformation                      */
  69.   VECTOR PP;        /* Temporary storage for ray origin, transformed   */
  70.   VECTOR DD;        /* Temporary storage for ray direction, transformed */
  71.   ISOBLOB_ELEMENT *nextelement; /* Pointer to next element to evaluate  */
  72. };
  73.  
  74. struct Isoblob_Data_Struct
  75. {
  76.   int References;               /* Number of references     */
  77.   int Number_Of_Components;     /* Number of components     */
  78.   DBL Threshold;                /* Isoblob threshold        */
  79.   DBL accuracy;                 /* Isoblob function accuracy    */
  80.   int max_trace;                /* Isoblob function maximum number of traces */
  81.   char normal_type;             /* Isoblob function normal method */
  82.   ISOBLOB_ELEMENT *Entry;       /* Array of isoblob components  */
  83.   ISOBLOB_INTERVAL* Intervals;  /* Intervals used during intersection testing */
  84.   BSPHERE_TREE *Tree;           /* Bounding hierarchy       */
  85.   ISOBLOB_FUNC_LIST *firstfunc; /* First function in list   */
  86. };
  87.  
  88. struct Isoblob_Struct
  89. {
  90.   OBJECT_FIELDS
  91.   TRANSFORM *Trans;
  92.   ISOBLOB_DATA *Data;       /* Pointer to isoblob data  */
  93.   TEXTURE **Element_Texture;
  94. };
  95.  
  96. struct Isoblob_List_Struct
  97. {
  98.   ISOBLOB_ELEMENT elem;     /* Current element          */
  99.   ISOBLOB_LIST *next;       /* Pointer to next element  */
  100. };
  101.  
  102. struct Isoblob_Interval_Struct
  103. {
  104.   int type;
  105.   DBL bound;
  106.   ISOBLOB_ELEMENT *Element;
  107.   VECTOR normal;
  108. };
  109.  
  110. /* Allows functions to be listed and then referred to by number */
  111. struct Isoblob_Function_List_Struct
  112. {
  113.   FUNCTION *func;           /* Current function          */
  114.   ISOBLOB_FUNC_LIST *next;  /* Pointer to next function  */
  115. };
  116.  
  117.  
  118.  
  119. /*****************************************************************************
  120. * Global variables
  121. ******************************************************************************/
  122.  
  123. extern METHODS Isoblob_Methods;
  124.  
  125.  
  126.  
  127. /*****************************************************************************
  128. * Global functions
  129. ******************************************************************************/
  130.  
  131. void Init_Isoblob_Queue (void);
  132. ISOBLOB *Create_Isoblob (void);
  133. void Make_Isoblob (ISOBLOB *isoblob, DBL threshold, DBL accuracy, int max_trace, char normal_type, ISOBLOB_FUNC_LIST *isoblobfunclist, ISOBLOB_LIST *isobloblist, int npoints);
  134. ISOBLOB_LIST *Create_Isoblob_List_Element (void);
  135. ISOBLOB_FUNC_LIST *Create_Isoblob_Func_Element (void);
  136. void Create_Isoblob_Element_Texture_List (ISOBLOB *Isoblob, ISOBLOB_LIST *IsoblobList, int npoints);
  137. void Determine_Isoblob_Textures (ISOBLOB *Isoblob, VECTOR P, int *Count, TEXTURE **Textures, DBL *Weights);
  138. void Test_Isoblob_Opacity (ISOBLOB *Isoblob);
  139.  
  140. void Translate_Isoblob_Element (ISOBLOB_ELEMENT *Element, VECTOR Vector);
  141. void Rotate_Isoblob_Element (ISOBLOB_ELEMENT *Element, VECTOR Vector);
  142. void Scale_Isoblob_Element (ISOBLOB_ELEMENT *Element, VECTOR Vector);
  143. void Invert_Isoblob_Element (ISOBLOB_ELEMENT *Element);
  144. void Transform_Isoblob_Element (ISOBLOB_ELEMENT *Element, TRANSFORM *Trans);
  145. void Destroy_Isoblob_Queue (void);
  146.  
  147. #endif