home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / povsrc31.zip / objects.h < prev    next >
C/C++ Source or Header  |  2000-01-10  |  8KB  |  174 lines

  1. /****************************************************************************
  2. *                   objects.h
  3. *
  4. *  This module contains all defines, typedefs, and prototypes for OBJECTS.C.
  5. *
  6. *  from Persistence of Vision(tm) Ray Tracer
  7. *  Copyright 1996,1999 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. *  NOTICE: This source code file is provided so that users may experiment
  10. *  with enhancements to POV-Ray and to port the software to platforms other
  11. *  than those supported by the POV-Ray Team.  There are strict rules under
  12. *  which you are permitted to use this file.  The rules are in the file
  13. *  named POVLEGAL.DOC which should be distributed with this file.
  14. *  If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  15. *  Team Coordinator by email to team-coord@povray.org or visit us on the web at
  16. *  http://www.povray.org. The latest version of POV-Ray may be found at this site.
  17. *
  18. * This program is based on the popular DKB raytracer version 2.12.
  19. * DKBTrace was originally written by David K. Buck.
  20. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  21. *
  22. *****************************************************************************/
  23.  
  24. /* NOTE: FRAME.H contains other object stuff. */
  25.  
  26. #ifndef OBJECTS_H
  27. #define OBJECTS_H
  28.  
  29.  
  30.  
  31. /*****************************************************************************
  32. * Global preprocessor defines
  33. ******************************************************************************/
  34.  
  35. /*
  36.  * [DB 7/94]
  37.  *
  38.  * The flag field is used to store all possible flags that are
  39.  * used for objects (up to 16).
  40.  *
  41.  * RLP 1999 there are really 32 flags, since it's an unsigned long.
  42.  * This is important, because Nathan used #17 below.
  43.  *
  44.  * The flages are manipulated using the following macros:
  45.  *
  46.  *   Set_Flag    (Object, Flag) : set    specified Flag in Object
  47.  *   Clear_Flag  (Object, Flag) : clear  specified Flag in Object
  48.  *   Invert_Flag (Object, Flag) : invert specified Flag in Object
  49.  *   Test_Flag   (Object, Flag) : test   specified Flag in Object
  50.  *
  51.  *   Copy_Flag   (Object1, Object2, Flag) : Set the Flag in Object1 to the
  52.  *                                          value of the Flag in Object2.
  53.  *   Bool_Flag   (Object, Flag, Bool)     : if(Bool) Set flag else Clear flag
  54.  *
  55.  * Object is a pointer to the object.
  56.  * Flag is the number of the flag to test.
  57.  *
  58.  */
  59.  
  60. #define NO_SHADOW_FLAG                0x00001 /* Object doesn't cast shadows            */
  61. #define CLOSED_FLAG                   0x00002 /* Object is closed                       */
  62. #define INVERTED_FLAG                 0x00004 /* Object is inverted                     */
  63. #define SMOOTHED_FLAG                 0x00008 /* Object is smoothed                     */
  64. #define CYLINDER_FLAG                 0x00010 /* Object is a cylinder                   */
  65. #define DEGENERATE_FLAG               0x00020 /* Object is degenerate                   */
  66. #define STURM_FLAG                    0x00040 /* Object should use sturmian root solver */
  67. #define OPAQUE_FLAG                   0x00080 /* Object is opaque                       */
  68. #define MULTITEXTURE_FLAG             0x00100 /* Object is multi-textured               */
  69. #define INFINITE_FLAG                 0x00200 /* Object is infinite                     */
  70. #define HIERARCHY_FLAG                0x00400 /* Object can have a bounding hierarchy   */
  71. #define HOLLOW_FLAG                   0x00800 /* Object is hollow (atmosphere inside)   */
  72. #define HOLLOW_SET_FLAG               0x01000 /* Hollow explicitly set in scene file    */
  73. /* NK 1998 */
  74. #define UV_FLAG                       0x02000 /* Object uses UV mapping                 */
  75. /* NK ---- */
  76. /* NK 1998 double_illuminate */
  77. #define DOUBLE_ILLUMINATE_FLAG        0x04000 /* Illuminate both sides of the surface   */
  78. /* NK ---- */
  79. #ifdef NoImageNoReflectionPatch
  80. #define NO_IMAGE_FLAG                 0x08000 /* Object doesn't catch camera rays    [ENB 9/97] */
  81. #define NO_REFLECTION_FLAG            0x10000 /* Object doesn't cast reflection rays [ENB 9/97] */
  82. #endif
  83. #define INVERT_NO_SHADOW_GROUP        0x20000 /* invert Lights on NO SHadow */
  84. #define INVERT_LIGHT_GROUP            0x40000 /* invert lights on LightGroup */
  85.  
  86.  
  87. #define Set_Flag(Object, Flag)     \
  88.   { (Object)->Flags |=  (Flag); }
  89.  
  90. #define Clear_Flag(Object, Flag)   \
  91.   { (Object)->Flags &= ~(Flag); }
  92.  
  93. #define Invert_Flag(Object, Flag)  \
  94.   { (Object)->Flags ^=  (Flag); }
  95.  
  96. #define Test_Flag(Object, Flag)    \
  97.   ((Object)->Flags & (Flag))
  98.  
  99. #define Copy_Flag(Object1, Object2, Flag) \
  100.   { (Object1)->Flags = (((Object1)->Flags) & (!Flag)) | \
  101.                        (((Object2)->Flags) &  (Flag)); }
  102.  
  103. #define Bool_Flag(Object, Flag, Bool) \
  104.   { if(Bool){ (Object)->Flags |=  (Flag); } else { (Object)->Flags &= ~(Flag); }}
  105.  
  106.  
  107.  
  108. /* Object types. */
  109.  
  110. #define BASIC_OBJECT            0
  111. #define PATCH_OBJECT            1 /* Has no inside, no inverse */
  112. #define TEXTURED_OBJECT         2 /* Has texture, possibly in children */
  113. #define COMPOUND_OBJECT         4 /* Has children field */
  114. #define STURM_OK_OBJECT         8 /* STRUM legal */
  115. #define WATER_LEVEL_OK_OBJECT  16 /* WATER_LEVEL legal */
  116. #define LIGHT_SOURCE_OBJECT    32 /* link me in frame.light_sources */
  117. #define BOUNDING_OBJECT        64 /* This is a holder for bounded object */
  118. #define SMOOTH_OK_OBJECT      128 /* SMOOTH legal */
  119. #define IS_CHILD_OBJECT       256 /* Object is inside a COMPOUND */
  120. #define DOUBLE_ILLUMINATE     512 /* Illuminate both sides of surface to avoid normal purturb bug */
  121. /* NK 1998 - DOUBLE_ILLUMINATE is not used anymore - use DOUBLE_ILLUMINATE_FLAG */
  122. #define HIERARCHY_OK_OBJECT  1024 /* NO_HIERARCHY legal */
  123. #define LT_SRC_UNION_OBJECT  2048 /* Union of light_source objects only */
  124. #ifdef MotionBlurPatch
  125. #define MOTION_BLUR_OBJECT  16384
  126. #define CHILDREN_FLAGS (PATCH_OBJECT+TEXTURED_OBJECT+MOTION_BLUR_OBJECT)  /* Reverse inherited flags */
  127. #else
  128. #define CHILDREN_FLAGS (PATCH_OBJECT+TEXTURED_OBJECT)  /* Reverse inherited flags */
  129. #endif
  130.  
  131.  
  132.  
  133. /*****************************************************************************
  134. * Global typedefs
  135. ******************************************************************************/
  136.  
  137.  
  138.  
  139. /*****************************************************************************
  140. * Global variables
  141. ******************************************************************************/
  142.  
  143. extern unsigned int Number_of_istacks;
  144. extern unsigned int Max_Intersections;
  145. extern ISTACK *free_istack;
  146.  
  147.  
  148.  
  149. /*****************************************************************************
  150. * Global functions
  151. ******************************************************************************/
  152.  
  153. void Default_UVCoord (UV_VECT Result, OBJECT *Object, INTERSECTION *Inter);
  154.  
  155. int Intersection (INTERSECTION *Ray_Intersection, OBJECT *Object, RAY *Ray);
  156. int Ray_In_Bound (RAY *Ray, OBJECT *Bounding_Object);
  157. int Point_In_Clip (VECTOR IPoint, OBJECT *Clip);
  158. OBJECT *Copy_Object (OBJECT *Old);
  159. void Translate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  160. void Rotate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  161. void Scale_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans);
  162. void Transform_Object (OBJECT *Object, TRANSFORM *Trans);
  163. int Inside_Object (VECTOR IPoint, OBJECT *Vector);
  164. void Invert_Object (OBJECT *Object);
  165. void Destroy_Object (OBJECT *Object);
  166. ISTACK *open_istack (void);
  167. void close_istack (ISTACK *istk);
  168. void incstack (ISTACK *istk);
  169. void Destroy_IStacks (void);
  170. void Destroy_Single_Object (OBJECT **ObjectPtr);
  171.  
  172.  
  173. #endif
  174.